What's error of using SetGCPs of my code?

by Baikal   Last Updated October 13, 2018 08:22 AM

I have two images, one is Sentinel-1 HH-pol tiff file and it contains projections and 400 GCPs information and the other is SigmaNought tiff file, it doesn't have GCPs and projections information. I want to add projections and 400 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)

How to modify my code?

Tags : python gdal

Related Questions

python GDAL translate to convert and coloring

Updated March 03, 2018 02:22 AM

Module has no attribute Warp?

Updated July 28, 2017 20:22 PM

gdal.Warp workingType option default

Updated August 24, 2018 15:22 PM

What resampling method is used in gdal_merge?

Updated June 22, 2015 22:09 PM