[gdal-dev] myshape.prj versus -s_srs
Frank Warmerdam
warmerdam at pobox.com
Wed Jan 16 22:09:39 EST 2008
Stefan Keller wrote:
> I'm trying to a shapefile to KML. The Shapefile driver indicates that
> "If a .prj files (...) is present, it will be read and used to associate
> a projection with features.". In addition, the OGR KML driver
> documentation says "All OGR KML output will be presented in EPSG:4326.".
>
> Let's say the input files are myshape.shp, myshape.shx, myshape.dbf and
> myshape.prj and I try "ogr2ogr -f kml out.kml myshape.shp".
> then the resulting coordinates are still in the source coordinate
> system: Why? I espected that theya re transformed to WGS84 according to
> the documentation mentioned.
>
> This is what finally worked: "ogr2ogr -f kml del_prairie.kml
> del_prairie.shp -s_srs EPSG:21781 -t_srs EPSG:4326". But indicating
> "-s_srs EPSG:21781" seems to me redundant to the existing file
> myshape.prj . Any explanations?
Stefan,
ogr2ogr does not reproject coordinates by default, even when writing
to formats like KML that only really support one output coordinate system
properly. The -t_srs is the correct way to request reprojection.
The -s_srs EPSG:21781 option should be unnecessary if the source shapefile
already has a readable .prj file.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the gdal-dev
mailing list