Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

While importing my shapefile data to PostGIS, I did not select the proper Projection.

How do I now change the SRID of the data, without transforming the Coordinates?

share|improve this question

1 Answer 1

up vote 35 down vote accepted

There is a single line function which does this for you. Just use the following SQL query:

select UpdateGeometrySRID('Schema Name', 'mytable', 'the_geom', newSRID) ;

But, if you are like me, you would be interested in the low level, miniature steps. Logically speaking, the above function is equivalent to the following four step process:

  1. In the geometry_columns table, update the SRID to the required value.

  2. Drop the contraint on the table, by using the following SQL statement

    ALTER TABLE mytable DROP CONSTRAINT enforce_srid_the_geom;

  3. Update the SRID'd of the geometry by using the following SQL statement

    UPDATE mytable SET the_geom = ST_SetSRID(the_geom, newSRID);

  4. Add the contraint back by using the following SQL statement

    ALTER TABLE mytable

    ADD CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = (newSRID));

share|improve this answer
1  
See postgis.org/docs/ST_SetSRID.html for more info and links –  BradHards Oct 1 '12 at 9:12
    
@devdatta your 1 line solution worked the best! Didn't have to worry about handling the SRID as a constraint...very simple... –  mapBaker Jun 20 '13 at 22:24
    
Just a thought: show the single-step solution first. –  martin f Feb 27 at 17:21
    
@martinf: I agree it's better with the single step solution at the top. Hence edited. Thanks! –  Devdatta Tengshe Feb 28 at 2:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.