1

I am using ogr2ogr to reproject shapefiles. For example:

ogr2ogr -s_srs EPSG:1234 -t_srs EPSG:3857 dest.shp srs.shp

ogr2ogr then creates dest.shp, dest.shx, dest.dbf and dest.prj as expected.

The problem occurs when I try to find the EPSG code of dest.shp using GDAL. GDAL cannot identify that the file is in EPSG 3857.

Why can't GDAL identify a prj's EPSG when it created the prj from a EPSG?

Please note that I am using GDAL C# library.

  • Probably there is some error in how you are using GDAL/OGR. Can you show a minimal example that demonstrates the problem? – BradHards May 13 '15 at 7:39
  • AFAIK, OGR is based on GDAL. Both software packages are writing out EPSG:3857 incorrectly. "Mercator_1SP" should have both sphere- and ellipsoid-based math, so if that projection method is used, the GEOGCS portion would have to use a sphere to trigger the correct equations. Unless there's some funky workaround within the code, the results will be wrong. – mkennedy May 13 '15 at 16:49
1

I am not sure if GDAL is recognizing that the projection is just EPSG:3857 by the code but I suppose that the projection info it finds is correct. Make the same test with ogrinfo. If you can't get the same info with C# then there may be something wrong in the bindings or in your code.

ogr2ogr -f "ESRI Shapefile" -s_srs epsg:4326 -t_srs epsg:3857 test_3857.shp test.shp

>ogrinfo test_3857.shp -al -so
INFO: Open of `test_3857.shp'
      using driver `ESRI Shapefile' successful.

Layer name: test_3857
Geometry: Polygon
Feature Count: 21
Extent: (-13557934.236980, 4655107.343957) - (-13557684.314289, 4655312.908599)
Layer SRS WKT:
PROJCS["WGS_84_Pseudo_Mercator",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_84",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["Meter",1],
    PARAMETER["latitude_of_origin",0.0]]
OBJECTID_1: Integer (9.0)
OBJECTID: Integer (9.0)
Building_U: String (50.0)
NAME_LC: String (20.0)

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.