ArcPy – Get Shortest Distance Between Two Geometries

arcpydistancegeometry

I'm using ArcPy and using a cursor to step through one polygon feature class. For each of these 'source' polygons, I am creating a SearchCursor to find all polygons in a second feature class that share a common attribute. For each of these matching polygons, I want to measure the distance between it and the search polygon. I also plan on measuring other geometry differences (to determine if it has just been shifted, rotated, scaled, etc).

The purpose of this work is to build up a change history between polygon datasets representing features at different times.

I've seen the ReturnDistance method mentioned in ArcObjects, but can't figure out how to run this using ArcPy. Is it possible, and if so, can anyone help with some rough sample code? If not, I'll probably resort to measuring the change in centroid position between the polygons.

Thanks, Steve

Best Answer

This answer is 3 years late so you've probably got a workaround by now. But for completeness, here's an arcpy method to measure the distance between 2 objects.

Geometry has a method distanceTo which:

Returns the minimum distance between two geometries. If the geometries intersect, the minimum distance is 0.

Both geometries must have the same projection.