Median Center (Spatial Statistics)

License Level:BasicStandardAdvanced

Summary

Identifies the location that minimizes overall Euclidean distance to the features in a dataset.

Learn more about how_Median_Center_works

Illustration

Median Center illustration

Usage

Syntax

MedianCenter_stats (Input_Feature_Class, Output_Feature_Class, {Weight_Field}, {Case_Field}, {Attribute_Field})
ParameterExplanationData Type
Input_Feature_Class

A feature class for which the median center will be calculated.

Feature Layer
Output_Feature_Class

A point feature class that will contain the features representing the median centers of the input feature class.

Feature Class
Weight_Field
(Optional)

The numeric field used to create a weighted median center.

Field
Case_Field
(Optional)

Field used to group features for separate median center calculations. The case field can be of integer, date, or string type.

Field
Attribute_Field
(Optional)

Numeric field(s) for which the data median value will be computed.

Field

Code Sample

MedianCenter Example (Python Window)

The following Python Window script demonstrates how to use the MedianCenter tool.

import arcpy
arcpy.env.workspace = r"C:\data"
arcpy.MedianCenter_stats("coffee_shops.shp", "coffee_MEDIANCENTER.shp", "NUM_EMP", "#", "#")
MedianCenter Example (Stand-alone Python script)

The following stand-alone Python script demonstrates how to use the MedianCenter tool.

# Measure geographic distribution characteristics of coffee house locations weighted by the number of employees
 
# Import system modules
import arcpy
 
# Local variables...
workspace = "C:/data"
input_FC = "coffee_shops.shp"
CF_output = "coffee_CENTRALFEATURE.shp"
MEAN_output = "coffee_MEANCENTER.shp"
MED_output = "coffee_MEDIANCENTER.shp"
weight_field = "NUM_EMP"
 
try:
    # Set the workspace to avoid having to type out full path names
    arcpy.env.workspace = workspace
 
    # Process: Central Feature...
    arcpy.CentralFeature_stats(input_FC, CF_output, "Euclidean Distance", weight_field, "#", "#")
 
    # Process: Mean Center...
    arcpy.MeanCenter_stats(input_FC, MEAN_output, weight_field, "#", "#")

    # Process: Median Center...
    arcpy.MedianCenter_stats(input_FC, MED_output, weight_field, "#", "#")
 
except:
    # If an error occurred when running the tool, print out the error message.
    print arcpy.GetMessages()

Environments

Output Coordinate System

Feature geometry is projected to the Output Coordinate System prior to analysis. All mathematical computations are based on the Output Coordinate System spatial reference.

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
8/26/2014