[gdal-dev] RPCs in GeoTIFF
Matt.Wilkie at yukon.ca
Matt.Wilkie at yukon.ca
Mon Jan 10 08:01:11 PST 2022
Thanks for the nudge. I implemented that code as a simple command line script a couple of months ago but neglected to put it anywhere someone else could use it. Fixed that today ;-)
https://gist.github.com/maphew/29a73ee7a4517663cef5081c15799fc3
```
'''Copy RPC metdata from IN raster to OUT raster
Adapted from @user7821537
https://gis.stackexchange.com/questions/264644/transfer-rpc-metadata-from-one-geotiff-to-another
'''
import os
import sys
from osgeo import gdal
gdal.UseExceptions()
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} [in_file] [out_file]")
sys.exit(1)
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
```
-Matt
From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> On Behalf Of ni hao
Sent: January 4, 2022 3:00 PM
To: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] RPCs in GeoTIFF
*** External email: Do not click on links or attachments except from trusted senders. ***
******************************************************************************************
Hi list,
https://gis.stackexchange.com/questions/264644/transfer-rpc-metadata-from-one-geotiff-to-another
The above link showed me how to do it.
thanks.
________________________________
From: gdal-dev <gdal-dev-bounces at lists.osgeo.org<mailto:gdal-dev-bounces at lists.osgeo.org>> on behalf of ni hao <ni_hao88 at hotmail.com<mailto:ni_hao88 at hotmail.com>>
Sent: January 3, 2022 2:03 PM
To: gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org> <gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>>
Subject: [gdal-dev] RPCs in GeoTIFF
Hi list,
I use gdal-2.4.4.
I use gdalwarp to orthorectify RADARSAT-2 images with RPCs (in product.xml).
Now I have done some manipulation and save the result in GTiff (e.g., apply Sigma0 LUT).
How can I copy the RPC Metadata from product.xml into GTiff, so I can use gdalwarp RPC orthorectification?
What are the Python commands to call ?
Do I have to use VRT?
Thank you!
ds=gdal.Open(r"C:\RADARSAT-2\2008Feb10\product.xml")
ds.GetMetadata(domain='RPC')
{'HEIGHT_OFF': '1.400000000000000e+02', 'LINE_NUM_COEFF': '1.045003883698053e-03 -3.909147136274753e-05 9.670521993287788e-09 -1.540774061983927e-08 -1.230034082454030e-01 2.994775580755049e-08 3.800851793724760e-08 -7.321141763443381e-04 -3.070513868102579e-08 -3.263789159357597e-08 -1.074590548649705e+00 -1.422870424040082e-07 2.625729922759320e-07 3.515681824455183e-04 1.737795244565543e-08 -1.191967212586014e-06 -6.679635986447045e-04 9.917030647189506e-09 1.183063120029544e-06 9.020179141273994e-07', 'SAMP_SCALE': '1759', 'LONG_OFF': '-5.586200000000000e+00', 'SAMP_DEN_COEFF': '1.000000000000000e+00 -3.873791825160030e-04 -1.654041698986790e-06 1.045768201431545e-08 -7.357169048971613e-04 -5.663646053748347e-06 -2.270764362304154e-08 -7.511863551214131e-07 -3.061984244257416e-07 1.247909289740085e-07 1.555977062556944e-03 2.290649610770613e-06 1.138900631680699e-09 -4.788174308312700e-07 1.913987966778219e-07 -5.724932691905833e-08 5.283021826505342e-06 -2.470297385173699e-08 -5.008669473258436e-08 1.486018900494917e-08', 'ERR_BIAS': '5.000000000000000e-01', 'SAMP_NUM_COEFF': '1.448914459955711e-03 3.107453606755890e-02 -1.362345055216650e-05 -5.545316452513627e-08 1.177884096135199e+00 2.873729811978911e-04 -1.989082475494487e-06 -1.041938833100005e-03 8.430382868139787e-06 -1.570423196668063e-06 -2.556805573684327e-01 -1.724821081109771e-05 4.713416494967566e-07 -9.676787333902578e-04 -2.144746372053350e-06 8.115347578419969e-07 1.767758474109092e-04 2.353735909723349e-07 -6.444353128930045e-06 2.385344654290232e-07', 'LONG_SCALE': '1.859000000000000e-01', 'LINE_DEN_COEFF': '1.000000000000000e+00 -9.804190622020718e-08 -2.386942243966555e-07 1.801605395896790e-08 4.160880031382031e-04 -2.095235371483683e-08 -1.659952797934781e-08 -9.496784414468805e-07 4.758902993568164e-08 5.402628711262573e-08 4.472124981058622e-04 1.370099419045734e-08 -1.785667248922995e-08 7.981478756298640e-07 -7.327071351551446e-09 2.253346171933004e-07 1.637317283006711e-06 -5.178220338393535e-08 1.880261293686099e-06 5.550513900110941e-06', 'SAMP_OFF': '1705', 'LAT_SCALE': '2.073000000000000e-01', 'LAT_OFF': '3.590580000000000e+01', 'LINE_SCALE': '4229', 'LINE_OFF': '4227', 'ERR_RAND': '1.000000000000000e-01', 'HEIGHT_SCALE': '5.010000000000000e+02'}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220110/6a7b1391/attachment-0001.html>
More information about the gdal-dev
mailing list