[GIS] Terrain correction / Orthorectification with gdal

gdalorthorectificationradarterrain

Since MODIS Imagery Orthorectification (Open Source) had no answer, I will try to get one here with a similar problem:

I got some raster datasets with GCPs in lat/lon, but without height information. When I use gdal to project/re-project the data, I get an offset of approx. 2km, which I think comes from terrain distortion.
Using ESA's SNAP Toolbox, I get the results I want, but they are using the actual SRTM DEM in the background.

Is there a way to provide gdal with the raster, the GCPs and a DEM to get everything done "at once" (or in several steps)?

So far, my approach (which gives the offset) looks like this:

gdal_translate -gcp pix1 line1 x1 y1 -gcp pix2 line2 x2 y2 (...) input.tif output.tif

The data are SAR raster from ERS-1, which might have something to do with the offset due to the viewing angle of the sensor

Best Answer

Here is the command I use to do it all at once, plus some other helpful settings to help it run a bit quicker. If needed, you can also specify coordinates to chip the image using the -te flag. This command will chip the image, change the output format, and orthorectify using a DEM in a single step. You can download SRTM here: http://srtm.csi.cgiar.org/srtmdata/

gdalwarp -multi -wo NUM_THREADS=ALL_CPUS -co NUM_THREADS=ALL_CPUS --config GDAL_CACHEMAX 1536 -wm 1536 -rpc -to RPC_DEM=${DEM_FILE} -of GTiff -te ${aoi_coords} ${inFile} ${outFile}