[gdal-dev] Source SRS not honoured if shapefile .prj file exists

Rahkonen Jukka jukka.rahkonen at mmmtike.fi
Fri Jun 7 04:21:26 PDT 2013


Even Rouault wrote:

> Selon Jukka Rahkonen <jukka.rahkonen at mmmtike.fi>:
> 
> > Hi,
> >
> > I received a shapefile with a non-perfect .prj file which does not
> > advertise that the coordinate system is Finnish KKJ (EPSG:2393) which
> > needs +towgs84 parameters. I knew that GDAL 1.10 finally comes with
> > correct parameters and thought that problem could be solved easily by
> > adding parameter "-s_srs epsg:2393" into ogr2ogr command. However,
> > GDAL does not honour the parameter if the .prj still exists in the
> > shapefile directory. Only after deleting the .prj file I got the
> > correct result. I think that the correct behaviour would be the opposite and
> take -s_srs instead of .prj if both are available.
> >
> > Tested with GDAL 1.10.0, released 2013/04/13 and my command was
> > ogr2ogr -f KML -s_srs epsg:2393 -t_srs epsg:4326 test4.kml
> > test_region.shp
> 
> This one is weird. Looking at ogr2ogr code doesn't lead to an obvious
> explanation. -s_srs should override the SRS of the shapefile. Perhaps you could
> open a ticket with the data to reproduce ?

Sad, but I can't. It was only a typo in -t_srs when the prj file was present. Now I know that GDAL discarded quietly also -s_srs because  of missing -t_srs and utilized prj  instead.

Perhaps ogr2ogr could print a message if it is discards -s_srs.  I also think that the KML driver page is  a little bit too optimistic when it is advertising "As such OGR will create layers in the correct coordinate system and transform any geometries."  At least there could be sentence  in the Caveats section emphasizing that if the automatic recognition of source srs fails then user must give both source srs and target srs manually.

-Jukka Rahkonen-


More information about the gdal-dev mailing list