Select to view content in your preferred language

Need convert to Projection CoordinateSystem before geometry.equals for Geographical CoordinateSystem?

527
2
11-23-2022 07:27 PM
pyfans
by
New Contributor II

I find when two same geometries with geographical coordinate system compared with geometry.equals(), SOME times return False, but after convert to projection coordinate system, it returns True. I want to know if it needed to convert projection coordinate system before using geometry.equals() every time?

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

From this protracted discussion from several years ago

What can I expect from ArcPy Geometry .equals meth... - Esri Community

I tend to check esri geometries (and those from other sources) by calculating the centroid, area (for polygons) and length/perimeter(for poly* features) then use numpy to compare the two geometry centroids as indicated in my first post there.  A similar comparison using `allclose` can be used with whatever tolerance you want for the remaining geometry properties.  You are less reliant on what goes on with what affect projecting the data has than on numeric representation.

 

Now... if the features are all in the same featureclass, have a look at

Find Identical (Data Management)—ArcGIS Pro | Documentation

including just the geometry field.  Perhaps there is some different magic applied in the tool that doesn't exist in arcpy itself


... sort of retired...
0 Kudos
DavidSolari
Occasional Contributor III

My naïve guess is Find Identical grabs the XY tolerance for the input features and uses that as a delta while Geometry.equals doesn't. I've never run into this as I also use the numpy method in conjunction with the feature's tolerance (or just a quick abs(a.X - b.X) < tolerance style check) but it really should be documented.

0 Kudos