[gdal-dev] OGR_L_SetSpatialRef

Radim Blazek radim.blazek at gmail.com
Mon Apr 11 11:23:29 EDT 2011


Hi,
thanks for the suggestion.
I have created enhancement ticket for that
http://trac.osgeo.org/gdal/ticket/4032 .

Radim

On Fri, Apr 8, 2011 at 2:02 PM, Even Rouault
<even.rouault at mines-paris.org> wrote:
> Selon Radim Blazek <radim.blazek at gmail.com>:
>
> Radim,
>
> there's no API in OGR to alter the SRS of an existing layer.
>
> However in the particular case of a shapefile, you just need to generate the
> .prj file. You can do that quite easily with the OSR API. See
> http://gdal.org/ogr/ogr__srs__api_8h.html
>
> Basically, something like :
>
> OGRSpatialReferenceH hSRS = OSRNewSpatialReference ( NULL );
> OSRImportFromXXXXX(hSRS, YYYYYY);
> OSRMorphToESRI(hSRS); /* this is the important stuff for shapefile .prj */
> char* pszOutWkt = NULL;
> OSRExportToWkt(hSRS, &pszOutWkt);
> OSRDestroySpatialReference(hSRS);
> fprintf(fp, "%s", pszOutWkt);
> CPLFree(pszOutWkt);
>
>> Hi,
>> is there a way to assign a CRS to an existing OGR layer.
>> I would like to open for example a shapefile without .prj in write
>> mode, set a CRS and save it with .prj without creating a new layer.
>>
>> Radim
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>


More information about the gdal-dev mailing list