3

I am performing an image processing task on one geotiff that produces another, however the metadata, including the RPCs, aren't propagated from the input to the output. Is there a way to copy the RPCs from the one image to the other, using GDAL or similar?

3

You can use the gdal library in python:

from osgeo import gdal, gdalconst

# Open the files you want to transfer RPCs from and to
tif_with_RPCs = gdal.Open(tif_file_with_RPCs, gdalconst.GA_ReadOnly)
tif_without_RPCs = gdal.Open(tif_file_without_RPCs,gdalconst.GA_Update)

# get the RPCs from the first file ...
rpcs = tif_with_RPCs.GetMetadata('RPC')

# ... write them to the second file
tif_without_RPCs.SetMetadata(rpcs ,'RPC')

# close the files
del(tif_with_RPCs)
del(tif_without_RPCs)

You can check this has worked with the command gdalinfo on the command line - the RPCs will be printed out if they are present

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.