Select to view content in your preferred language

Updating SRID values used by Feature Classes

4439
4
04-28-2017 10:26 AM
mpboyle
Frequent Contributor

I have noticed since upgrading to ArcGIS 10.4, the SRID values of our feature classes have changed.  All of our production feature classes use NAD 1983 (2011) Iowa State Plane North and are managed in SQL Server 2014 Standard using Geometry as the shape.  The SRID for this spatial reference in 10.3 and prior is 103045.  Starting at 10.4 the SRID is now 6463.  Granted, our end users will never know the difference, and all the properties of the spatial reference are identical.  However, I notice a huge difference when trying to run the same spatial queries within SQL Server that use multiple tables, most notably, for those feature classes that are created in 10.4, trying to apply the same spatial query doesn't work at all because the SRID value of the feature class created in 10.4 is different from those created in previous versions.

Below are examples trying to execute an intersect spatial query using a point feature class created in 10.3 (103045) and one created in 10.4 (6463) against an underlying polygon feature class created in 10.3 or prior (103045).

Is there any way of updating the SRID of a feature class without having to re-create the feature class in a current version?  This wouldn't be too terrible except any relationships based on Esri system fields, for example, the GlobalID field when using attachments, would be very difficult to re-create because they would be re-generated for the new feature class.

One of the benefits of us maintaining our data in SQL Server is the ability to do these type of spatial queries within the database.  By having multiple SRID values for the same coordinate system, we are losing the ability to run these types of queries.

Both feature classes (point shown below and underlying polygon) both have 103045 as SRID --- values are returned in the spatial query where features intersect

Same point feature class, however, created in 10.4 with SRID equal to 6463 and underlying polygon in 103045...no records are returned

4 Replies
mpboyle
Frequent Contributor

Hopefully, someone from Esri can chime in on this...but I found the following workflow seems to work in changing the SRID stored for a feature class from one that was prior to 10.4 to one that is current.  I'm sure if someone from Esri does chime in, they will mention that this workflow is not supported since you're monkeying around with back-end tables, but I don't see any other solution that doesn't involve re-creating the feature class, and loading data into it.  And, while this may work for some, we use a fair amount of attachments and related tables which often use a GlobalID field as the parent key.  These GlobalID values will get assigned new values when loading into a new feature class, so then you are stuck with trying to create a cross-reference between old and new features, personally, not an ideal scenario.

In our situation, most of our enterprise feature classes were created prior to 10.4 and have a SRID value of 103045.  Starting at 10.4, the same coordinate system (NAD 1983 (2011) Iowa State Plane North) now has a SRID value of 6463.  To our end users, they will likely never notice the difference, however, as an admin and someone that uses spatial queries within Sql Server for a fair amount of analysis and querying, I notice this as a big issue, because queries involving geometries within Sql Server only return values when the tables have the same SRID.  So...it is very important for us to have our feature classes using the same SRID values across the board.

With that being said...here is the workflow I found that seems to work (I apologize for the length, but for anyone who may stumble across this when searching for a similar issue, I wanted to be as detailed as possible)...

  • I created a test feature class (using Desktop 10.3) that uses the old SRID for NAD 1983 (2011) Iowa State Plane North ... 103045.  I created a few points in order to demonstrate that the feature class and features are indeed using the SRID equal to 103045.  I registered the feature class as versioned, and enabled archiving to mimic our production environment.  I did this to make sure all bases are covered when it comes time to create/edit new features (delta table inserts/updates) and archive data.

  • If I query Sql Server to expose the SRID used by the features, I can also confirm that the SRID being used is 103045.

  • So...this is how I went about changing the SRID being used by the feature class from 103045 to 6463...first of all, you need to do a little research on the SDE tables within your database.  These are the tables you need to make a few notes on:

  • SDE_table_registry: only needed if your feature class is versioned.  This table will tell you numbers of the associated delta (a, d) tables.  In this example, the delta tables associated with my test feature class are 'a15059' and 'd15059'.

  

  • SDE_spatial_references: this table will tell you the spatial references used within the database.  The 'srid' field is the primary key on the table which is a foreign key in tables below.  The 'auth_srid' is the SRID that is used by the feature class.  The 'srtext' field is a text description of the SRID.  In this example, the srid values of '3' and '4' are the two entries for the different NAD 1983 (2011) Iowa State Plane North coordinate systems, with '3' being the 103045 SRID and '4' being the 6463 SRID.

       SDE_spatial_references table

  • SDE_layers: this table contains which SRID is being used for the base table and archive table within the 'srid' column (the layer_id column value will correspond to the SDE_GEOMETRY*** table).  Note the layer_id.  This is the primary key for the table and can be used later when updating to key on the rows.

  • SDE_geometry_columns: this table also contains which SRID is being used for the base table and archive table within the 'srid' column.

  • Now that you have the following: delta table names (the 'a' table is all that's needed), srid values (3 (old), 4 (new) in this example), and what tables store these SRID values (SDE_layers, SDE_geometry_columns), you can start updating tables to migrate to the desired SRID value (6463 (4) in this example).

  • The first thing to do is modify the constraint on the base table, 'a' delta table (if applicable), and archive table (if applicable).  The constraint will only allow features to contain a SRID value equal to what was defined when the feature class was created, in this case 103045.  On each of the base table, 'a' delta table, and archive table:
    • Expand the table properties to view the constraints.  Right-click on the constraint and select 'Modify'.

      

  • Change the highlighted properties from 'Yes' to 'No'.  Also, note the constraint value is forcing any records within the table to have a SRID value equal to the SRID defined when creating the feature class.  Change the SRID value to the new value (second screenshot).  Close and save the table.  Do the same for the 'a' delta table (if applicable) and archive table (if applicable).

  • With the constraint modified to NOT check existing data, and NOT enforce on inserts and updates, you can run update queries to update the SRID values within the base table, archive table (if applicable), and SRID key values within the SDE_layers and SDE_geometry_columns tables.  You can run an series of update queries like what is shown below.
    • Update the 'srid' value within the SDE_layers table to the new SRID value referenced in the SDE_spatial_references table using a where clause based on the layer_id values found from the SDE_layers table.
    • Update the 'srid' value within the SDE_geometry_columns table to the new SRID value referenced in the SDE_spatial_references table using a where clause based on the table names.
    • Update the SRID value being stored by all features within the base table to the new SRID value (actual wkid)
    • Update the SRID value being stored by all features within the archive table to the new SRID value (actual wkid) --- if applicable.

      

  • Check the affected table to verify the updates: 

  • Base table SRID values are updated from 103045 to 6463

         

  • Archive table SRID values are updated from 103045 to 6463

         

  • SDE_geometry_columns table 'srid' values are updated from 3 (103045) to 4 (6463) based on SDE_spatial_references table

  • SDE_layers table 'srid' values are updated from 3 (103045) to 4 (6463) based on SDE_spatial_references table

        

 

  • Change the constraints values back to 'Yes' on the base table, 'a' delta table (if applicable), and archive table (if applicable).  Make sure the SRID value has been updated to the new srid.  Close and save the table.

  • Check your feature class properties.  The feature class should now show that the Geometry being stored is in the new SRID.

  • Try adding / updating / deleting features within ArcMap.  You shouldn't encounter and constraint errors.  Query your delta table (if applicable) and archive table (if applicable).  You should see that the features are using the new SRID value.

This seems to have worked for me in migrating existing features from a previous SRID to the current SRID.  This is pretty hacky in that you are messing with back-end tables, but this seems to prevent having to try and load features from one feature class to another.  If any Esri folks want to chime in and tell me of a better way, I'm all ears ... or if this will cause some sort of catastrophe within our geodatabase, I'd appreciate that as well.

NicolasGIS
Frequent Contributor

Hello @mpboyle ,

Thanks for sharing ! Interesting. 6 (!) years later, did you face issue with this non supported workflow ? I have been waiting for a year for the following BUG to be solved: 

BUG-000152217: In ArcGIS Pro, the Define Projection tool fails to assign a projected coordinate system for Oracle geodatabase feature classes.

Considering some alternatives...

 

0 Kudos
mpboyle
Frequent Contributor

6 years later and haven't had issues.  Pretty sure I mention this in my reply, but be sure to test this workflow first!

AllanBenvin_yyc
Regular Contributor

Thanks for this post. We have a similar issue with Oracle. For various reasons I won't get in to our data is defined as a custom 3TM WGS84 114 but the coordinates are actually NAD83 3TM 114. This issue is not noticed internally as all our data matches. It is only when we share externally that we see the issue. We need to correct the spatial reference of all our data but retain the current correct coordinates.

A re-project is not valid as it would move the data so the DefineProjection tool looks promising at first. However, in testing I have found that it only partially changes the spatial reference of a layer. It seems to update the layer definition in the GDB_ITEMS table but the SRID in the registration tables and on the features still have the old SRID. 

I have found that doing a DefineProjection and then a subsequent copy/paste will correct the SRID on the registration tables as well as on the features. Unfortunately, doing a copy/paste on our 4000+ datasets which include complex data types, versioning, archiving, topology, relationship classes and networks would create a total mess. It turns out I came up with the same method as the original poster here, but in my case my testing was done with Oracle. We also have SQL Server but Oracle hosts our most complex data sets.

The attached document details my testing, processes and the various registration values, but I'll include a bit of info in the text here.

As mentioned, the DefineProjection tool only updates the layer definition in GDB_ITEMS but the SRID remains the same. The process below shows proposed method on how to update the SRID without altering geometry for data in Oracle SDE.

Manual update using SQL 

 This fixes the registration and the geometry without having to alter archiving, versioning, relations classes etc.

Proposed Process:

1) DefineProjection to define as WKID 3776

2) Delete spatial indexes

3) Update SRID on features to same geometry but change the SRID

UPDATE AB_CAL3TM_CHANGE SET SHAPE = SDE.ST_GEOMFROMWKB(SDE.ST_ASBINARY(SHAPE) , 3776);

4) Update the ST_GEOMETRY_COLUMNS to the correct SRID

update SDE.ST_GEOMETRY_COLUMNS SET SRID = 3776 WHERE TABLE_NAME = 'AB_CAL3TM_CHANGE';

  • Update SDE.LAYERS to a SRID that has the same SR as well as M, Z tolerance etc, see section below named  Gettting Layer SRID in document.

UPDATE SDE.LAYERS SET SRID = 86 WHERE TABLE_NAME = ' AB_CAL3TM_CHANGE’; --(this is the srid of a valid nad83 layer)

So far I have only tested this process on a few layers but the results have been good. The one question I have is how do I know which SRID to use for the SDE.LAYERS  table? In my testing I have been reading the SDE.LAYERS table to find a record with the desired spatial reference and matching xyzm values. If there is no matching record my next course of action would be to create a layer that has my desired properties via ArcPy and then find the LAYERS.SRID value from that. 

If this process proves valid I would script it to handle versioning, archiving, fabric etc.

See the attached document for the full process and please let me know your thoughts or suggestions on this process.

0 Kudos