[postgis-users] changing srid

Nicolas Ribot nicky666 at gmail.com
Wed Jun 29 09:52:44 PDT 2005


On 6/29/05, Mark Fenbers <Mark.Fenbers at noaa.gov> wrote:
> I have discovered this morning that data that I've loaded into the DB
> using shp2pgsql was imported with the wrong SRID specified.  Some of the
> tables have been modified since importing them, so merely re-importing
> them with the correct SRID is not going to be a simple solution.
> 
> Now I'm trying to change the SRID for these tables but I am running into
> some headaches.  Basically, the data now is incorrectly stored as
> SRID=4326 and I want to change the SRID to 4269 without transforming any
> of the actual geometries.  I've gotten all tied in knots as to how to
> formulate a proper query to do this.
> 
> Logically, I want to do this:
> 
> update mytable set SRID = 4269 where SRID(the_geom) = 4326;
> 
> What's really throwing me off is that the setSRID() function only takes
> one argument (geometry) instead of the two that seems more logical to me
> -- as in setSRID(the_geom, 4269).  If this were the case, I could
> probably run this:
> 
> select setSRID(the_geom,4269) from myTable where SRID(the_geom) = 4326;
> 
> Anyone know the RIGHT WAY to do what I need to do?
> 
> Mark
> 

Hello,
You should first change the SRID in the postgis metadata
(geometry_columns table).
Try this function:

select updategeometrysrid('your_table', 'geom_col', <new_srid>);

Then, use setSRID to change geometries internal SRID:

select setsrid(geom_col, <new_srid>) from your_table;

By the way you should have the 2-arguments setSRID function.
If not you should check your postgis version.

Nicolas



More information about the postgis-users mailing list