[gdal-dev] Assigning SpatialReference to OGRLayer
Even Rouault
even.rouault at mines-paris.org
Mon Aug 23 15:00:38 EDT 2010
You cannot do that. The layer can set the spatial reference when building its
definition, but the user cannot change that.
You could achieve this by wrapping your layer into a OGR VRT though. See
http://gdal.org/ogr/drv_vrt.html
But for shapefiles, the easier will be to write a .prj file. You can use the
OGRSpatialReference for that (see
http://gdal.org/ogr/classOGRSpatialReference.html ) . Namely the
morphToESRI() and exportToWkt() should be of great help to get the ESRI WKT
string to write into the .prj
Le lundi 23 août 2010 20:41:55, Anders Moe a écrit :
> Hi everyone
>
> I was wondering how I should assign a spatial reference to my OGRLayer.
>
> virtual
> OGRSpatialReference<http://www.gdal.org/ogr/classOGRSpatialReference.html>
> *
> OGRLayer::GetSpatialRef<http://www.gdal.org/ogr/classOGRLayer.html#75c06b4
> 993f8eb76b569f37365cd19ab> ()
>
>
> There seems to be no SetSpatialRef method. The current spatial reference
> is null, since it was imported from a shapefile without spatial ref, so I
> can not simply fill in the values of the existing sref object. I tried
> assigning to each geometry, but this seems less than elegant, and the
> layer still returns 0.
>
> Thanks in advance,
> Anders
More information about the gdal-dev
mailing list