I want to extract Ground Control Points(GCPs) information from a Sentinel-1 HH geotiff file. Could you give me a method by using Python ?
The picture below shows GCP information of a Sentinel-1 Geotiff image in ENVI software.
I want to extract Ground Control Points(GCPs) information from a Sentinel-1 HH geotiff file. Could you give me a method by using Python ?
The picture below shows GCP information of a Sentinel-1 Geotiff image in ENVI software.
So you have GCPs and you want to access them?
product = snappy.ProductIO.readProduct(product_name)
gcp_group = product.getGcpGroup()
for i in range(gcp_group.getNodeCount()):
gcp = gcp_group.get(i)
Like this?
Yeah, I have those GCPs information in GeoTIFF .I find the word from GeoTIFF File Format explaining website,
Georeferencing from GeoTIFF is supported in the form of one tiepoint and pixel size, a transformation matrix, or a list of GCPs.
My Sentinel-1 tiff belongs to the third case, i.e., there has very GCPs information in TIFF files.
I want to just using Python don’t want snappy.
Could you know how to extract the information in Geotiff files using Python or GDAL?
Thanks your suggestion. Today, I found few functions can also to retrieve GCPs information.
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_ReadOnly )
ds.SetGCPs( gcpcount, gcp, gcpproj )
However, there is still a problem for me, my usage of SetGCPs is wrong and this bug will come as following:
Traceback (most recent call last):
File “”, line 1, in
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 22, in
ds.SetGCPs( gcpcount, gcp, 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)
I don’t know why, if you know , thanks for your kind-hearted . I will try to solve it by myself as my best.
I have solved the problems, because the DetGCPs() function does not need to input GCP numbers , so I made it after modifying code as following:
ds.SetGCPs( gcp, gcpproj ) ds = None
I have solved the problems, because the SetGCPs() function does not need to input GCP numbers , so I made it after modifying code as following:
ds.SetGCPs( gcp, gcpproj ) ds = None