Try this python script: ------
import arcpy
import math
# Change these first four variables to suit your data
# 1. points is the raw point file
# 2. medianPoints is a point file of median points using ArcMap's 'Median Center' tool
# 3. sharedNameField is the name of the field that both points and medianPoints share
# 4. distanceFieldName is the name of the field that will be created to store distances
points = r'C:\give your file path\your data.shp'
medianPoints = r'C:\give output file path\points_median_center.shp'
sharedNameField = 'name of the field'
distanceFieldName = "pointDist"
# add field to point dataset that will store distances corresponding to median point
arcpy.AddField_management(points, distanceFieldName, "DOUBLE")
# loop through median points, get x,y coords and field value
medianPointCursor = arcpy.SearchCursor(medianPoints)
for medianPoint in medianPointCursor:
medPointXY = medianPoint.getValue('Shape').getPart()
x1,y1 = medPointXY.X, medPointXY.Y
fieldValue = medianPoint.getValue(sharedNameField)
# query the point file for only points that match the sharedNameField value
query = "{0} = '{1}'".format(sharedNameField, fieldValue)
pointCursor = arcpy.UpdateCursor(points, query)
for point in pointCursor:
pointXY = point.getValue('Shape').getPart()
x2,y2 = pointXY.X, pointXY.Y
distanceToMedianPt = math.hypot(x2 - x1, y2 - y1)
point.setValue(distanceFieldName, distanceToMedianPt)
pointCursor.updateRow(point)
del point, pointCursor
del medianPoint, medianPointCursor