<div dir="ltr"><div class="gmail_extra">In my case shapefile are uploaded to the server by users through a web page (polygons represent the boundaries of a new protected natural site). So the only information about the projection that I get is located in the .prj file. I am not sure if there is a way to get the EPSG code automatically in this case (?)  </div><div class="gmail_extra"><br></div><div class="gmail_extra">How can QGIS pick up the name of the EPSG code right (actually I knew that the projection code was<span style="font-size:13px"> </span><span style="font-size:13px">EPSG:28992 by opening the shapefile in QGIS and checking the properties of the layer)   ?</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">In the case there is no way to get the EPSG code automatically: do you know if ogr2ogr could send a warning/error that I would send back to the user asking him to reproject the shapefile in WGS84 himself before uploading the file?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks in advance for your insights</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-22 19:54 GMT+01:00 Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Le jeudi 22 janvier 2015 19:43:50, Pierric de Laborie a écrit :<br>
<span class="">> Hello,<br>
><br>
> I do not understand why there seems to be a drift (about 100 meters) of the<br>
> polygons contained in a shapefile after reprojecting it to 4326 using the<br>
> following command :<br>
><br>
> ogr2ogr -f 'ESRI Shapefile' -wrapdateline -t_srs EPSG:4326<br>
> destinationfile.shp sourcefile.shp<br>
><br>
> The original prj file is the following. It is supposed to describe the<br>
> projection EPSG:28992  ( <a href="http://spatialreference.org/ref/epsg/28992/" target="_blank">http://spatialreference.org/ref/epsg/28992/</a>  )<br>
><br>
> PROJCS["RD_New",GEOGCS["GCS_Amersfoort",DATUM["D_Amersfoort",<br>
> SPHEROID["Bessel_1841",6377397.155,299.1528128]],<br>
> PRIMEM["Greenwich",0.0],<br>
> UNIT["Degree",0.0174532925199433]],<br>
> PROJECTION["Double_Stereographic"],<br>
> PARAMETER["False_Easting",155000.0],<br>
> PARAMETER["False_Northing",463000.0],<br>
> PARAMETER["Central_Meridian",5.38763888888889],<br>
> PARAMETER["Scale_Factor",0.9999079],<br>
> PARAMETER["Latitude_Of_Origin",52.15616055555555],<br>
> UNIT["Meter",1.0]]<br>
<br>
<br>
</span>This definition is outdated and has not the needed datum shift :<br>
<br>
$ gdalsrsinfo EPSG:28992<br>
<br>
PROJ.4 : '+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889<br>
+k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel<br>
+towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m<br>
+no_defs '<br>
<br>
OGC WKT :<br>
PROJCS["Amersfoort / RD New",<br>
    GEOGCS["Amersfoort",<br>
        DATUM["Amersfoort",<br>
            SPHEROID["Bessel 1841",6377397.155,299.1528128,<br>
                AUTHORITY["EPSG","7004"]],<br>
            TOWGS84[565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725],<br>
            AUTHORITY["EPSG","6289"]],<br>
        PRIMEM["Greenwich",0,<br>
            AUTHORITY["EPSG","8901"]],<br>
        UNIT["degree",0.0174532925199433,<br>
            AUTHORITY["EPSG","9122"]],<br>
        AUTHORITY["EPSG","4289"]],<br>
    PROJECTION["Oblique_Stereographic"],<br>
    PARAMETER["latitude_of_origin",52.15616055555555],<br>
    PARAMETER["central_meridian",5.38763888888889],<br>
    PARAMETER["scale_factor",0.9999079],<br>
    PARAMETER["false_easting",155000],<br>
    PARAMETER["false_northing",463000],<br>
    UNIT["metre",1,<br>
        AUTHORITY["EPSG","9001"]],<br>
    AXIS["X",EAST],<br>
    AXIS["Y",NORTH],<br>
    AUTHORITY["EPSG","28992"]]<br>
<span class=""><br>
<br>
><br>
> Apparently QGIS could understand the projection file correctly and<br>
> reproject it to WGS84 with no problem. But it seems that for some specific<br>
> projections, GDAL does not reproject as expected.<br>
<br>
</span>Shapefile .prj files don't include TOWGS84, so that's the likely explanation.<br>
Try adding -s_srs  EPSG:28992 to your ogr2ogr command line<br>
<div class=""><div class="h5"><br>
><br>
>  Is it possible to force it by adding the projection specifications in one<br>
> of the files included in the following folder (linux debian install) :<br>
>  /usr/share/gdal   and how ?<br>
><br>
> For example, I could see a file named gdal_datum.csv  containing the datum<br>
> "D_Amersfoort" specified in the prj file. However I could not find in any<br>
> other files the projection GCS_Amersfoort or RD_New as specified in the prj<br>
> file.<br>
><br>
> Thanks for your help<br>
<br>
</div></div><span class=""><font color="#888888">--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a><br>
</font></span></blockquote></div><br></div></div>