Switch to centroids in the Near tool

520
2
Jump to solution
01-17-2023 08:03 PM
Labels (3)
Mikhail
Occasional Contributor

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?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

So, as you discovered, if a point is within a polygon, NEAR_DIST will be zero.JohannesLindner_0-1674024491020.png

 

 

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.

JohannesLindner_1-1674024759061.png

 

 

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

JohannesLindner_2-1674025077298.png

 


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

So, as you discovered, if a point is within a polygon, NEAR_DIST will be zero.JohannesLindner_0-1674024491020.png

 

 

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.

JohannesLindner_1-1674024759061.png

 

 

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

JohannesLindner_2-1674025077298.png

 


Have a great day!
Johannes
Mikhail
Occasional Contributor

Dear Johannes, great, thank you so much! I followed your advice and obtained the results I was looking for.

0 Kudos