Select to view content in your preferred language

Discrepancy in measured distance between two point features and distance between point geometries built from their coordinates

428
5
07-23-2024 01:13 PM
Labels (2)
Glasnoct
Regular Contributor

I can't quite figure out how to reconcile the difference in reported footage between the following two methods. e.g.

 

feature1.distanceTo(feature2) -> 1,810 feet

 

and using the point returned by .firstPoint for each of the features:

 

        def get_dist(coord1: tuple, coord2: tuple):
            sr = arcpy.SpatialReference(3418)
            p1 = arcpy.PointGeometry(arcpy.Point(coord1[0], coord1[1]), sr)
            p2 = arcpy.PointGeometry(arcpy.Point(coord2[0], coord1[1]), sr)
            return round(p1.distanceTo(p2), 3) -> ~1,760 feet

 

 

method 1 agrees with the measure distance tool but the second is off ~60 feet. This looks like a projection issue and I'm guessing that even though I build the point geometries with the same spatial reference as the features, that the coordinates returned from .firstPoint (lacking a spatial reference) are wrong. I don't need to do it this way very often but sometimes coordinates are what I have on hand at a certain point in the code and so I'm just trying to "rebuild" the feature's location to then get the distance from.

How can I keep the position I received from the feature accurate for when I rebuild the geometry?

0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

what is the spatial reference of the map if you are using the distance tool?


... sort of retired...
0 Kudos
Glasnoct
Regular Contributor

map and feature layers are all using 4813 NAD 1983 StatePlane Iowa South FIPS 1402 (US Feet)

0 Kudos
DanPatterson
MVP Esteemed Contributor

I can't see anything here

Measure—ArcGIS Pro | Documentation

that would account for that difference if you are using 2d planar distance measurements


... sort of retired...
0 Kudos
Glasnoct
Regular Contributor

I'm using the geodesic option, which agrees with the original geometry method.

edit: the reconstructed point distance is now reporting a distance identical to the original geometry distance. I don't believe I changed anything between yesterday and today. Perhaps when ArcPro was restarted this morning something ironed itself out. Glad I don't have to chase down this particular issue anymore. Thanks!

0 Kudos
DanPatterson
MVP Esteemed Contributor

I don't know what your point coordinates are, so do a hand calculation of the distance between the two points using pythagorean method and report which one it gives,

Also in

PointGeometry—ArcGIS Pro | Documentation

gives an alternate method which explicitly allows for geodesic distance calculation, give it a try as well

angleAndDistanceTo (other, {method})


... sort of retired...
0 Kudos