Selon Radim Blazek <[email protected]>: 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 > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev > _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
