Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Copy RPC metdata from IN raster to OUT raster
'''Copy RPC metdata from IN raster to OUT raster
Adapted from @user7821537
import os
import sys
from osgeo import gdal
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} [in_file] [out_file]")
infile = sys.argv[1] # source filename and path
output = sys.argv[2] # destination file
data_in = gdal.Open(infile, gdal.GA_ReadOnly)
data_out = gdal.Open(output, gdal.GA_Update)
# get the RPCs from the first file ...
rpcs = data_in.GetMetadata('RPC')
# ... write them to the second file
data_out.SetMetadata(rpcs ,'RPC')
# de-reference the datasets, which triggers gdal to save
data_in = None
data_out = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment