Select to view content in your preferred language

SpatialReference differs between ArcGIS Pro and ArcGIS Pro SDK

202
3
Wednesday
TorbjørnDalløkken2
Frequent Contributor

I have a filegeodatabase containinig a dataset and some featureclasses. The dataset is originally created with the spatial reference ETRS 1989 UTM Zone 32N.

One of the features in the add-in is to change the spatial reference of this dataset based on some values from a list. The code runs the "Define Projection" tool and the dataset is being updated with the new spatial reference. ETRS 1989 UTM Zone 32N to ETRS 1989 UTRM Zone 33N (or 35N).

When I try to get the spatial reference of one of the featureclasses through ArcGIS Pro SDK:

await QueuedTask.Run(() => 
{
  using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(uri)))
using (FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>("JSRGrensepunkt"))
{
    var featureclassDefinition = featureClass.GetDefinition();
    var sr = featureclassDefinition.GetSpatialReference();
    /* more code ...*/
});

GetSpatialReference() returns the original spatial reference (32N) and not the current one (33N):

sr_debug.png

If I look at the same featureclass in ArcGIS Pro, I can see that the featureclass indeed is in 33N:

Featureclass Properties.png

What might be wrong here?

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

Define Projection is used when the coordinate system is not known.  If you want the data to be in a new coordinate system, then you have to call the Project tool


... sort of retired...
0 Kudos
TorbjørnDalløkken2
Frequent Contributor

@DanPatterson Define Projection might also be used if the dataset has a incorrect coordinate system defined Define Projection. At this point in the add-in, there's no data in the dataset or the featureclasses, so the Project tool is not of any use. One workaround as I see it might be to create a new geodatabase and import the correct xml-schema for the coordinatesystem.

0 Kudos
DanPatterson
MVP Esteemed Contributor

correct, I omitted the case of incorrect coordinate system

Define Projection (Data Management)—ArcGIS Pro | Documentation

and the cases where it can't be used include (in Pro 3.5) are:

The tool does not support the following:

A feature class in an enterprise geodatabase
A feature class in a feature dataset
A feature dataset that contains a feature class

As well as several paragraphs clarifying other exemptions and suggests creating a new gdb under some circumstances.


... sort of retired...
0 Kudos