Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/17/2014 in all areas

  1. 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
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.

Disable-Adblock.png

 

If you enjoy our contents, support us by Disable ads Blocker or add GIS-area to your ads blocker whitelist