I have two images, one is Sentinel-1 HH-pol TIFF file and it contains projections and 399 GCPs information and the other is SigmaNought TIFF file, it doesn't have GCPs and projections information.
I want to add projections and 399 GCPs information from Sentinel-1 image to SigmaNought image by using GCPs() functions in GDAL. Code is:
import gdal,gdalconst
dir = r'G:\201606Sen\scihub.copernicus.eu\201511\S1A_EW_GRDM_1SDH_20151121T143754_20151121T143848_008704_00C632_33C6.SAFE\measurement/'
filename = 's1a-ew-grd-hh-20151121t143754-20151121t143848-008704-00c632-001.tiff'
source_tiff = dir + filename
source_ds = gdal.Open( source_tiff, gdalconst.GA_ReadOnly )
gcpcount = source_ds.GetGCPCount( )
gcp = source_ds.GetGCPs()
gcpproj = source_ds.GetGCPProjection()
calibration_image_tiff = dir + 'sigmaNought.tif'
ds = gdal.Open( calibration_image_tiff, gdalconst.GA_Update )
ds.SetGCPs( gcp, gcpcount, gcpproj )
However, I ecnountered error when using SetGCPs() function. The error is:
Traceback (most recent call last):
File "<ipython-input-40-7e6a9954b5d1>", line 1, in <module>
runfile('C:/Users/Baikal/Desktop/delete/untitled0.py', wdir='C:/Users/Baikal/Desktop/delete')
File "D:\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "D:\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/Baikal/Desktop/delete/untitled0.py", line 23, in <module>
ds.SetGCPs( gcp, gcpcount, gcpproj )
File "D:\Anaconda2\lib\site-packages\osgeo\gdal.py", line 1886, in SetGCPs
return _gdal.Dataset_SetGCPs(self, *args)
TypeError: Dataset_SetGCPs() takes exactly 3 arguments (4 given)
After I looked at this website In python gdal how to add Ground Control point to GeoTiff image by using gdal_translate I removed variable of gcpcount in SetGCPs() function then there is no error of code, but sigmaNought file cannot get GCPs information and projection.Why?