Re: Use of GCPS in Rasterio

Sean Gillies
 

Hi Vincent,

Doesn't GDAL get georeferencing for GeoTIFFs from GCPs already? https://gdal.org/drivers/raster/gtiff.html#georeferencing leads me to believe that it does. GDAL doesn't get georeferencing for a VRT from its GCPs, I have just checked this. Maybe the place to address this is in GDAL?

On Thu, Aug 22, 2019 at 8:16 AM <vincent.sarago@...> wrote:
Right now Rasterio has partial support of GCPS (meaning it can just list them). 

I've started a PR to add support of GCPS to retrieve the geotransform and crs from it when it's not present in the file (mostly to support Sentinel-1 data COG): https://github.com/mapbox/rasterio/pull/1749
While this works, the implementation and logic might not be the one expected from users. Because it's unlikely that a file will have a georeferenced coordinates system + gcps, I'd love if we could have something at least semi-automatic/seamless for users when opening the file (e.g with an environment variable ?) to handle gcps information.

GDAL docs says "The GDAL data model does not imply a transformation mechanism that must be generated from the GCPs … this is left to the application"
Ref: https://gdal.org/user/raster_data_model.html?highlight=gcps#gcps

GDAL behaviour:
- gdalinfo: list gcps, does not get transform, bounds and crs from GCPS
- gdal_translate: create a pure copy, does not get transform, bounds and crs from GCPS
- gdalwarp: get transform, bounds and crs from GCPS and copy those to the output file

Rasterio behaviour:
- rio info: list gcps, does not get transform, bounds and crs from GCPS
- rio convert: copy the file, loose GCPS info, does not get transform, bounds and crs from GCPS
- rio warp: copy the file, loose GCPS info, does not get transform, bounds and crs from GCPS

Note: 
when using `WarpedVRT`rasterio seems to be able to get the geotransform from the gcps 

```
with rasterio.open(src_path) as src_dst: 
    with WarpedVRT(src_dst, src_crs=src_dst.gcps[1], scrs=src_dst.gcps[1]) as vrt_dst: 
        print(vrt_dst.bounds)
        print(vrt_dst.meta)
        print(vrt_dst.transform)
```
,_._,_

--
Sean Gillies

Join dev@rasterio.groups.io to automatically receive all group messages.