Select to view content in your preferred language

Incompatible Spatial References

1952
11
10-29-2020 09:04 AM
AlexZlotin1
Emerging Contributor

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.

11 Replies
DavidWilton
Frequent 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();

DavidWilton_0-1686825546270.png

 

DaveWilcox
Occasional Contributor

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

0 Kudos
MK13
by
Frequent Contributor

I am having the same issue at 3.3. @UmaHarano @Wolf @CharlesMacleod 

0 Kudos
AquanuityDevelopment
Occasional Contributor

I am having this issue now and then from our users.  Just hope Pro dev team can look into this.

0 Kudos
RadekMandovec
Regular Contributor

I still have the same issue at 3.5.4, fortunately I use the solution by @DaveWilcox 

0 Kudos
AnnetteLocke
Esri Contributor

Hi Radek. I was just made aware of this issue. Can you check the xy-tolerances of the spatial references to see if they are the same? Thanks.

0 Kudos
RadekMandovec
Regular Contributor

Hi Annette, the XYTolerance values are different. While the first feature has XYTolerance = 0.0002, the second one has 0.0001.

0 Kudos
AnnetteLocke
Esri Contributor

The tolerances being different is the reason that the exception is thrown. I will look into changing the behavior so that if only the tolerances are different, then the operation will succeed. I need to test for unexpected repercussions before I can commit to the change, though. I will reply to this thread with the outcome.

0 Kudos
AnnetteLocke
Esri Contributor

Radek, I will change this in the next release.