Skip to main content
Solved

Updating SRID from null to SRID 27700

  • July 13, 2016
  • 7 replies
  • 221 views

Exporting a Database in 12c , the SRID is set to null , is there a way that FME can update all SRID to correct coordinate system within FME , would it be Feature class by Feature class or can it be doen for the whole Schema ?

Best answer by mark_f

@mantmania definitely a task for SQL in Oracle and have done exactly this in recent months.

 

  1. Drop the Spatial Index
  2. Update USER_SDO_GEOM_METADATA with SRID = 27700
  3. Update the SRID for each row in each table, but check it has a geometry.I would use: 

     

    update<YOUR_TABLE> t set t.<YOUR_GEOMETRY_COLUMN>.sdo_srid = 27700 where t.<

    YOUR_GEOMETRY_COLUMN> is not null;

  4. Rebuild the Spatial Index

Tricky parts include making sure any tablespace parameters specified for the Spatial Index are maintained during the Drop/Create index. Remember to manage the commit through the update of the various tables.

 

 

To check what tables to update:

 

select table_name, column_name from user_tab_cols where data_type = 'SDO_GEOMETRY';

To check index names and tablespaces:

select SDO_INDEX_NAME,SDO_TABLESPACE from user_sdo_index_info i, user_sdo_index_metadata m where i.index_name = m.sdo_index_name and i.table_name = 'FIELDIM' and i.column_name = 'GEOMETRY';

You can wrap it up in a PL/SQL block

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

david_r
Celebrity
  • 8394 replies
  • July 13, 2016

You can specify the coordinate system on the writer, this will affect all the features that exit that particular writer. Example:

You can also leave it blank on the writer and use the CoordinateSystemSetter transformer instead, then you can specify the coordinate system per feature of feature class.


erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • July 13, 2016

And you can do it by using SQL in the Oracle database. After creating the table you can populate the MDSYS.USER_SDO_GEOM_METADATA using the SRID. FME will detect this record and use it to populate the SRID on the geometries.


erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • July 13, 2016

And if you loaded data into the table and want to use SQL to add the SRID this will be the SQL statement:

Update table t set t.geom.sdo_srid = 27700;

Where table is your table name and geom is your geometry column name.

You have to use the table name alias (I used t) for this to work.


Forum|alt.badge.img+2
  • 325 replies
  • Best Answer
  • July 14, 2016

@mantmania definitely a task for SQL in Oracle and have done exactly this in recent months.

 

  1. Drop the Spatial Index
  2. Update USER_SDO_GEOM_METADATA with SRID = 27700
  3. Update the SRID for each row in each table, but check it has a geometry.I would use: 

     

    update<YOUR_TABLE> t set t.<YOUR_GEOMETRY_COLUMN>.sdo_srid = 27700 where t.<

    YOUR_GEOMETRY_COLUMN> is not null;

  4. Rebuild the Spatial Index

Tricky parts include making sure any tablespace parameters specified for the Spatial Index are maintained during the Drop/Create index. Remember to manage the commit through the update of the various tables.

 

 

To check what tables to update:

 

select table_name, column_name from user_tab_cols where data_type = 'SDO_GEOMETRY';

To check index names and tablespaces:

select SDO_INDEX_NAME,SDO_TABLESPACE from user_sdo_index_info i, user_sdo_index_metadata m where i.index_name = m.sdo_index_name and i.table_name = 'FIELDIM' and i.column_name = 'GEOMETRY';

You can wrap it up in a PL/SQL block


Forum|alt.badge.img
  • 9 replies
  • November 5, 2017

Hi Mark @mark_1spatial

When trying to update SRID to 27700 by running the below SQL query, oracle is throwing

atomic null violation error. Could you please suggest how to update SRID to 27700 when SRID is NULL currently.

update<YOUR_TABLE> t set t.<YOUR_GEOMETRY_COLUMN>.sdo_srid = 27700 where t.<

YOUR_GEOMETRY_COLUMN> is null;


Forum|alt.badge.img+2
  • 325 replies
  • November 5, 2017

Hi @anilkb1105

Do you have any geometries with a null value?

select count(*) from my_table where geometry is null;

In my original answer the update is where geometry is NOT null. Your reply looks like you are trying IS null!,

Forum|alt.badge.img
  • 9 replies
  • November 6, 2017

Hi @anilkb1105

Do you have any geometries with a null value?

select count(*) from my_table where geometry is null;

In my original answer the update is where geometry is NOT null. Your reply looks like you are trying IS null!,
Hi @mark_1spatial

 

 

Yes, out of 7 million records, i got some 31 records as GEOMETRY NULL(which is a bug in our utility data model, i'll try to fix it) and this was the reason update query was throwing atomic null violation error. 

 

 

Your below query has worked absolutely fine, thanks for your help.  

 

update<YOUR_TABLE> t set t.<YOUR_GEOMETRY_COLUMN>.sdo_srid = 27700 where t.<YOUR_GEOMETRY_COLUMN> is not null;