I need to measure distances from areas, represented by polygons, to rail stations, represented by points. I use the Near tool, but the issue is that many stations are within the polygons and the distance is zero. I'd like to measure the distances from stations (points) to the centroids of the polygons instead. Is there a way to switch to this method of measurement?
Solved! Go to Solution.
So, as you discovered, if a point is within a polygon, NEAR_DIST will be zero.
There's no way to switch to centroid in the Near tool. You have to do an extra step:
Use Feature To Point (Data Management)—ArcGIS Pro | Documentation to get the centroids of the polygons. Then run the Near tool with these centroids.
While this results in NEAR_DIST > 0, it loses the relationship to the polygons, because NEAR_FID uses the ObjectID of the centroids and you can't switch that to ORIG_FID (the ObjectID of the polygons).
If you need the OBJECTIDs of the polygons, you have to use Join Field (Data Management)—ArcGIS Pro | Documentation, joining Centroids.ORIG_FID to the station fc with the relation Centroids.OBJECTID = stations.NEAR_FID
So, as you discovered, if a point is within a polygon, NEAR_DIST will be zero.
There's no way to switch to centroid in the Near tool. You have to do an extra step:
Use Feature To Point (Data Management)—ArcGIS Pro | Documentation to get the centroids of the polygons. Then run the Near tool with these centroids.
While this results in NEAR_DIST > 0, it loses the relationship to the polygons, because NEAR_FID uses the ObjectID of the centroids and you can't switch that to ORIG_FID (the ObjectID of the polygons).
If you need the OBJECTIDs of the polygons, you have to use Join Field (Data Management)—ArcGIS Pro | Documentation, joining Centroids.ORIG_FID to the station fc with the relation Centroids.OBJECTID = stations.NEAR_FID
Dear Johannes, great, thank you so much! I followed your advice and obtained the results I was looking for.