Opened 11 months ago

Closed 11 months ago

Last modified 11 months 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
Cc:

Description

I'm trying to automatically add GCPs to a geotiff using python APIs. I followed as example the gdal_edit.py 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.

Thanks

Change History (4)

comment:1 Changed 11 months ago by Even Rouault

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

Ex:

$ cp ../autotest/gcore/data/byte.tif test_gcp.tif
$ python swig/python/scripts/gdal_edit.py -unsetgt  test_gcp.tif
$ python swig/python/scripts/gdal_edit.py -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:
  INTERLEAVE=BAND
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 Changed 11 months ago by dandev

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

comment:3 Changed 11 months ago by Even Rouault

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 Changed 11 months ago by Even Rouault

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.