Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Wolfram Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • System Modeler
  • Wolfram Player
  • Finance Platform
  • Wolfram Engine
  • Enterprise Private Cloud
  • Application Server
  • Wolfram|Alpha Notebook Edition
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

WolframConsulting.com

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Wolfram Notebook Assistant + LLM Kit
    • System Modeler
    • Wolfram Player
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Wolfram Engine
    • Enterprise Private Cloud
    • Application Server
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
SpatialMedian
  • See Also
    • Mean
    • Median
    • TrimmedMean
    • WinsorizedMean
    • BiweightLocation
    • CentralFeature
    • DistanceMatrix
  • Related Guides
    • Descriptive Statistics
    • Spatial Statistics
    • Spatial Point Collections
    • Robust Descriptive Statistics
    • Locations, Paths, and Routing
    • See Also
      • Mean
      • Median
      • TrimmedMean
      • WinsorizedMean
      • BiweightLocation
      • CentralFeature
      • DistanceMatrix
    • Related Guides
      • Descriptive Statistics
      • Spatial Statistics
      • Spatial Point Collections
      • Robust Descriptive Statistics
      • Locations, Paths, and Routing

SpatialMedian[{x1,x2,…}]

gives the spatial median of the elements .

SpatialMedian[data]

gives the spatial median for several different forms of data.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
DistanceFunction  
Method  
Applications  
Properties & Relations  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • Mean
    • Median
    • TrimmedMean
    • WinsorizedMean
    • BiweightLocation
    • CentralFeature
    • DistanceMatrix
  • Related Guides
    • Descriptive Statistics
    • Spatial Statistics
    • Spatial Point Collections
    • Robust Descriptive Statistics
    • Locations, Paths, and Routing
    • See Also
      • Mean
      • Median
      • TrimmedMean
      • WinsorizedMean
      • BiweightLocation
      • CentralFeature
      • DistanceMatrix
    • Related Guides
      • Descriptive Statistics
      • Spatial Statistics
      • Spatial Point Collections
      • Robust Descriptive Statistics
      • Locations, Paths, and Routing

SpatialMedian

SpatialMedian[{x1,x2,…}]

gives the spatial median of the elements .

SpatialMedian[data]

gives the spatial median for several different forms of data.

Details and Options

  • SpatialMedian is also known as geometric median, median center and 1-median.
  • SpatialMedian is a robust location measure. It gives a point with minimum total distance to every point in the data.
  • SpatialMedian is equivalent to x^*=ArgMin[sum_(i=1)^nd(x,x_i),x] for the unweighted case and x^*=ArgMin[sum_(i=1)^nw_i d(x,x_i),x] for the weighted case.
  • The data data has the following forms and interpretations:
  • {x1,x2,…}univariate numerical data
    {{x1,y1,…},{x2,y2,…},…}multivariate numerical data
    {GeoPosition[…],GeoPosition[…],…}list of geodetic positions
    GeoPosition[…]array of geodetic positions
    WeightedData[…]data with weights
  • Under Euclidean distance, SpatialMedian coincides with median in the one-dimensional case. In the multidimensional case, spatial median is unique whenever the points are not collinear.
  • The following options can be given:
  • AccuracyGoalAutomaticthe accuracy sought
    DistanceFunction Automaticthe distance metric to use
    MaxIterationsAutomaticmaximum number of iterations to use
    Method Automaticmethod to use
    PrecisionGoalAutomaticthe precision sought
    WorkingPrecisionAutomaticthe precision used in internal computations
  • By default, the following distance functions are used for different types of elements:
  • EuclideanDistancenumeric data
    GeoDistancegeospatial data
  • The setting Method{"InitialPoint"{x0,y0,…}} allows for a custom initial point for computing SpatialMedian.

Examples

open all close all

Basic Examples  (3)

Find the spatial median of a list of vectors:

Find the spatial median of a list of vectors with given weights:

Compute the spatial median of geo locations:

Scope  (5)

Same inputs with different precisions:

Spatial median works with WeightedData:

Spatial median of a large array:

Weighted spatial median:

Spatial median of data involving quantities:

Compute the spatial median of geodetic positions:

Options  (4)

DistanceFunction  (2)

By default, EuclideanDistance is used for numerical data:

The ChessboardDistance only takes into account the dimension with the largest separation:

DistanceFunction can be given as a symbol:

Or as a pure function:

Method  (2)

Specify the initial point for the iterative procedure of spatial median:

"NMinimize" and the method options of FindMinimum can be used:

Use with specified DistanceFunction:

Applications  (8)

Obtain a robust estimate of a multivariate location when outliers are present:

Extreme values have a large influence on the Mean:

Consider data from a Gaussian mixture distribution:

Estimate the center with Mean:

The sample mean estimator has a large spread for non-Gaussian data. The standard deviation of the estimator is:

Estimate the center with SpatialMedian:

Assess the spread via bootstrapping. The spatial median has a smaller spread compared to the mean:

Consider the stock prices of five companies: GOOG, MSFT, FB, AAPL and INTC in 2015 as five-dimensional data:

Compute the log returns and estimate the center using Mean and SpatialMedian:

Fit the data with MultivariateTDistribution and extract the location parameters:

Spatial median estimator gives a closer estimate to the location parameters of multivariate t distribution than the empirical mean with the given stock data:

With the number of points equal to 3, spatial median is also the Fermat point:

Create equilateral triangles on each side:

Construct the Fermat point geometrically and compare it with the result of SpatialMedian (red):

Sample points from a convex polygon:

Estimate the center of the polygon by computing the spatial median of random points:

Find the spatial median of California based on the locations of cities:

Find the spatial median of California based on the locations of cities, weighted by population:

Draw the city locations (gray), unweighted spatial median (red) and weighted spatial median (black):

For geo locations that are far enough apart on the surface of the Earth, the spatial median depends significantly on the choice of the distance function:

The spatial median under GeoPosition:

The spatial median of the projected coordinates under EuclideanDistance:

Show the locations of the spatial medians and the cities:

Centroids of geographic entities can be approximated by the spatial median of the uniformly sampled geo locations. Obtain the country polygon of Spain:

Sample points from the region and compute the corresponding spatial median:

Find the closest city from the spatial median:

Visualize the results:

Properties & Relations  (5)

SpatialMedian is a multivariate location measure:

Compute the spatial median:

Mean is also a location measure:

Visualize the data points with spatial median and mean:

SpatialMedian is the L1 location estimator of spatial points:

Compute SpatialMedian from the definition with FindMinimum:

Visualize the sum of distances function:

Mean (or spatial mean) is the L2 location estimator of spatial points:

Compute Mean from the definition with FindMinimum:

Visualize the sum of distances function:

SpatialMedian is the same as Median for univariate data:

SpatialMedian under ManhattanDistance for multivariate data is the same as Median:

SpatialMedian finds a point in the domain that minimizes the sum of distances:

CentralFeature finds a point that belongs to the data that minimizes the sum of distances:

The sum of distances with respect to CentralFeature is greater than or equal to the one with respect to SpatialMedian:

See Also

Mean  Median  TrimmedMean  WinsorizedMean  BiweightLocation  CentralFeature  DistanceMatrix

Related Guides

    ▪
  • Descriptive Statistics
  • ▪
  • Spatial Statistics
  • ▪
  • Spatial Point Collections
  • ▪
  • Robust Descriptive Statistics
  • ▪
  • Locations, Paths, and Routing

History

Introduced in 2017 (11.1)

Wolfram Research (2017), SpatialMedian, Wolfram Language function, https://reference.wolfram.com/language/ref/SpatialMedian.html.

Text

Wolfram Research (2017), SpatialMedian, Wolfram Language function, https://reference.wolfram.com/language/ref/SpatialMedian.html.

CMS

Wolfram Language. 2017. "SpatialMedian." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SpatialMedian.html.

APA

Wolfram Language. (2017). SpatialMedian. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SpatialMedian.html

BibTeX

@misc{reference.wolfram_2025_spatialmedian, author="Wolfram Research", title="{SpatialMedian}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SpatialMedian.html}", note=[Accessed: 01-December-2025]}

BibLaTeX

@online{reference.wolfram_2025_spatialmedian, organization={Wolfram Research}, title={SpatialMedian}, year={2017}, url={https://reference.wolfram.com/language/ref/SpatialMedian.html}, note=[Accessed: 01-December-2025]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Player
  • Wolfram Engine

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2025 Wolfram
© 2025 Wolfram | Legal & Privacy Policy |
English