Opened 13 years ago

Closed 5 years ago

#4032 closed enhancement (wontfix)

OGRLayer::SetSpatialRef

Reported by: rblazek Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: OGR_SRS Version: unspecified
Severity: normal Keywords:
Cc: rblazek

Description

It would be useful to have a method which can set a CRS on an existing layer:

OGRErr 	OGRLayer::SetProjection (const char *);

OGRErr OGR_L_SetSpatialRef ( OGRLayerH hLayer, const char *);

Currently there is no such function and no simple way to do it.

Change History (6)

comment:1 by rblazek, 13 years ago

Cc: rblazek added

comment:2 by Even Rouault, 13 years ago

Linking to the initial need, which was related to shapefile .prj : http://lists.osgeo.org/pipermail/gdal-dev/2011-April/028351.html

Before going into implementation, OGR_L_SetSpatialRef() would require a bit of thinking, in particular (not exhaustive) :

  • how would that work with on-disk/on-databases already existing features ? Should it reproject them to the new SRS if there was a previous one ? or just assign/override the SRS ?
  • how would that work with features that have been gotten by GetNextFeature() / GetFeature() ?
  • which drivers are good candidate for this new API : shapefile driver, database drivers, ... ? To be excluded for sure : append-only drivers such as GML, GeoRSS, CSV, ... For a few drivers like KML or GFT, the SRS cannot be changed at all (EPSG:4326)
  • So a new capability, OLCSetSpatialRef ?, would be likely needed.

As far as the API itself is concerned, a choice should be made. Your proposal looks more to what is done at the GDAL side (SRS exchanged as their WKT representation), but currently OGR works directly with OGRSpatialReferenceH in OGR_DS_CreateLayer() and OGR_G_GetSpatialReference(). And the name of the C++ method and the C function should ideally be as close as possible.

comment:3 by rblazek, 13 years ago

The feature was also requested here: http://lists.osgeo.org/pipermail/gdal-dev/2010-August/025793.html

Another problem: some formats may probably define SRS for the whole dataset instead of for individual layers, then OGRLayer::SetProjection() could be problematic. Are there such formats? At least GRASS defines SRS for location.

comment:4 by warmerdam, 13 years ago

I do not thing resetting the SRS should reproject the images. It should just reassign the SRS.

I believe this feature should be introduced via an RFC so the various issues can be clarified and agreed upon.

comment:5 by Jukka Rahkonen, 9 years ago

Is the status that this ticket is waiting for the RFC?

comment:6 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.