Incompatible Spatial References

10-29-2020 09:04 AM
New Contributor III

In the Pro SDK API, I am getting the "Incompatible spatial references" error when performing Geometry Engine operations like Distance or Difference on two geometries. The first geometry comes from a feature in an enterprise geodatabase feature class contained in a feature dataset. The second feature comes from a file geodatabase feature class created programmatically, with the spatial reference copied from the SDE feature class. When I look at spatial references of both geometry objects in debug mode, they have identical WKT strings. The workaround I found was to convert both geometries to JSON and re-create them from the JSON strings. The Geometry Engine operations no longer fail.  

My understanding is that as long as spatial reference WKT strings for two geometries are identical, their spatial references are the same. Is there something I am missing? Could this possibly be a bug? 

I am using Pro 2.6 SDK. Thanks.

2 Replies
Occasional Contributor

I'm seeing exactly the same thing in pro 3.1.0, two features with the same spatial reference. The layers have the same spatial reference, I check they have the same WKID in code just to be sure, still fails.

Feels like a bug in the code of the geometry engine  " at ArcGIS.Core.Geometry.GeometryEngine.CheckForEqualSpatialReferences(SpatialReference sr1, SpatialReference sr2)\

To me its feels like the code might be they are checking that they are the same instance of spatial reference object, rather than that they are the same?

My workaround therefore was to use the SR of on of the layers to rebuild the geometry of the other. In my case I used the SR of the polygon layer to create a new point

var point = new MapPointBuilderEx(inPoint.X, inPoint.Y, polyLayer.GetDefinition().GetSpatialReference()).ToGeometry();



New Contributor II

I'm seeing the same thing with 3.0. I hope they eventually fix it!

0 Kudos