4

I have discovered a problem related to the output of an ogr2ogr command line call. My resulting polygon features are 12 miles (.18 degrees) due north of where they should be, but the longitude is correct. The polygon dimensions are also preserved.

The desired output is a shapefile that has been projected using EPSG 4326. The input comes from a postgres database with postgis where the polygon were digitized in EPSG 900913 (the Google Web Mercator prj).

Below is the command line call that I am using:

ogr2ogr -where " gid = 3 " -f "ESRI Shapefile" E:\Web_Data_Storage\dfr_map_shapes\DFRmap_Tract_3_4326.shp -t_srs EPSG:4326 PG:"user=dfr_webmap dbname=denr host=ipaddress password=xxx port=5433" Tracts2

If I convert the coordinates of a corner of a polygon using gdaltransform I get the correct coordinates.

gdaltransform -s_srs EPSG:900913 -t_srs EPSG:4326 -8853154 4197094.5

Why is this happening and how do I fix it?

Thanks.

  • 1
    Why don't you add the -s_srs EPSG:900913 parameter in your ogr2ogr command? – mrg Sep 12 '11 at 8:36
4

I had a similar problem which I solved by replacing the 900913 SRID definition in the spatial_ref_sys table of the originating database with this one (to which I was directed by the TileStache.Vector documentation).

0

You simply need to tell ogr2ogr what projection your data is in, as suggested by mrg. In my case it was -s_srs EPSG:3785.

You shouldn't have to redefine a standard projection in your database! This is not a clean solution and can have unexpected consequences later on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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