[Gdal-dev] RE: ogr2ogr to PostGIS gives wrong SRID?

Randy George rkgeorge at cadmaps.com
Wed Feb 21 16:43:24 EST 2007


Hi,

 

I am attempting to use ogr2ogr to load some shp files into PostGIS

When translating a .shp file that is in EPSG:2239 and reprojecting to
EPSG:4326 like this:

 

ogr2ogr -f PostgreSQL PG:"user=user dbname=GA host=localhost password=pass
port=5432" 06_ZoneA.shp -s_srs EPSG:2239 -t_srs EPSG:4326 -nln test -append

 

The resulting table has correct coords but not a valid srid:

"SRID=32771;LINESTRING(-81.3993398544517 31.4233644295052,-81.4019931984873
31.4217494430945,-81.4036082752935 31.4205958831135,-81.4047618947201
31.4192116162976,-81.4062616063205 31.4179427019781,-81.407645959851
31.4171352080714,-81.4096071087392 31.4144 (..)"

 

The geometry_columns:

"";"public";"test";"wkb_geometry";"2";"32771";"LINESTRING"

 

The SRID constraint:

ALTER TABLE test  ADD CONSTRAINT enforce_srid_wkb_geometry CHECK
(srid(wkb_geometry) = 32771);

 

Adding -a_srs EPSG:4326 to the cmd line doesn't seem to change the result.

 

Is there another parameter required to set the SRID?

 

My convoluted work around:

ALTER TABLE "test" DROP CONSTRAINT enforce_srid_wkb_geometry;

UPDATE "test" SET wkb_geometry = setsrid(wkb_geometry,4326);

ALTER TABLE "test"  ADD CONSTRAINT enforce_srid_wkb_geometry CHECK
(srid(wkb_geometry) = 4326);

UPDATE "geometry_columns" SET srid=4326 WHERE f_table_name='test';

 

Thanks

randy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070221/8f91777e/attachment.html


More information about the Gdal-dev mailing list