Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6751 closed defect (fixed)

Bug in GDAL SetGCPs

Reported by: dandev Owned by: hobu
Priority: normal Milestone: 2.2.0
Component: GDAL_Raster Version: 2.1.2
Severity: normal Keywords: gtiff gcp geotransform


I'm trying to automatically add GCPs to a geotiff using python APIs. I followed as example the file but I have discovered that both my implementation and the gdal_edit one are not adding GCPs in the tiff header. The gdal_translate implementation works well instead (checked with gdalinfo). Unfortunately, I cannot rely on gdal_translate because of the char limitation of the command line in Windows.


Change History (4)

comment:1 by Even Rouault, 6 years ago

That works for me. If your raster has initially a geotransform you need to unset it with -unsetgt, then -gcp will work.


$ cp ../autotest/gcore/data/byte.tif test_gcp.tif
$ python swig/python/scripts/ -unsetgt  test_gcp.tif
$ python swig/python/scripts/ -gcp 0 1 2 3 test_gcp.tif
$ gdalinfo test_gcp.tif 
Driver: GTiff/GeoTIFF
Files: test_gcp.tif
Size is 20, 20
Coordinate System is `'
GCP Projection = 
GCP[  0]: Id=1, Info=
          (0,1) -> (2,3,0)
Image Structure Metadata:
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,   20.0)
Upper Right (   20.0,    0.0)
Lower Right (   20.0,   20.0)
Center      (   10.0,   10.0)
Band 1 Block=20x20 Type=Byte, ColorInterp=Gray

comment:2 by dandev, 6 years ago

Thanks for your quick reply. I did not know that I had to clear the geotransform.

comment:3 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

In 36908:

GTiff: make setting GCPs when geotransform is already set work (with warning about unsetting the geotransform), and vice-versa) (fixes #6751)

comment:4 by Even Rouault, 6 years ago

Component: PythonBindingsGDAL_Raster
Keywords: gtiff gcp geotransform added
Milestone: 2.2.0

I've pushed an improvement so that this works out of the box (with a warning)

Note: See TracTickets for help on using tickets.