<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p><br>
</p>
<p>I haven't done myself that exercice but I know that computing RPC
values that are stable enough might be challenging, so perhaps the
issue is related to that<br>
</p>
<p><br>
</p>
<p>A few other remarks:</p>
<p>- your gdalwarp command line refers to RPC_DEM_SRS and
RPC_DEM_MISSING_VALUE but doesn't include a RPC_DEM itself, hence
those are likely to be non effective</p>
<p>- you generally don't want to use both RPC_HEIGHT and RPC_DEM.
RPC_HEIGHT is essentially useful when you don't have a DEM
available, and thus fallback taking an average elevation</p>
<p>- there's a subtlety regarding DEM. RPC reference for altitudes
is WGS84 ellipsoidal height, not orthometric/MSL altitude. But DEM
values use orthometric/MSL altitude, hence a geoid correction must
be applied. So you'd rather want to use RPC_DEM_SRS=EPSG:4326+5773
for example to use the EGM96 geoid (cf
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/issues/3298">https://github.com/OSGeo/gdal/issues/3298</a>). That said, misusing
orthometric altitude vs ellipsoidal height generally accounts for
small shifts, not big ones</p>
<p>- you could use gdaltransform with all your -to parameter and
input_with_RPCs.tiff to check at least that the forward RPC
transformation path works correctly (the one from longitude,
latitude -> column, line). And with -i to check the inverse RPC
transformer. The inverse RPC transformer can have a hard time
converging in montainous areas or for images off-nadir</p>
<p><br>
</p>
<p>Even<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 17/04/2024 à 23:30, Joseph McGlinchy
via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:AM9PR07MB7106CB04CA1DA76705A6BC59A10F2@AM9PR07MB7106.eurprd07.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello,</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am attempting to implement georegistration through RPC. I have
the following information I've used to calibrate the RPC
coefficients, using all terms for numerator and denominator for
both sample and line equations.</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<ul
data-editing-info="{"orderedStyleType":1,"unorderedStyleType":1}"
style="margin-top: 0px; margin-bottom: 0px; list-style-type: disc;">
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
image grid, stored in tiff format with no geo-information
associated with it, so it reflects the imaging orientation</div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
a 'ground' grid, which corresponds to the longitude/latitude
coordinates for each pixel determined from a line-of-sight
vector and imaging system coordinates where the pseudo-rays
intersect the WGS84 geoid</div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
a random sample of up to 4000 image coordinate / object
space coordinate pairs (I arrived at this number through
trial and error; using all pixels explodes RAM)</div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
elevation extracted at the longitude/latitude coordinates
from a DEM, in this case, SRTM, but have also tried using
NASADEM</div>
</li>
</ul>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am able to write out an image to EPSG:4326 by populating the
RPC metadata and using the non-georeferenced image data.
However, I am struggling to use
<code>gdalwarp</code> in a reliable way to orthorectify that
data, let alone writing it out in a way that 'bakes in' the
georegistration with the RPCs whether that is in EPSG:4326 or
the local UTM zone. I see strips of the image "ripped out" with
odd curves in various places throughout the image. </div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The only way I've been able to use <code>gdalwarp</code> to
write the image at all is with the following parameters (any DEM
reference is to the SRTM DEM):<br>
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
gdalwarp --config CPL_DEBUG ON -t_srs EPSG:32610 -rpc -to
"RPC_DEM_SRS=+proj=longlat +datum=WGS84 +no_def" -to
"RPC_HEIGHT=350" -to "RPC_DEM_MISSING_VALUE=0.001" -to
"RPC_FOOTPRINT='POLYGON ((list of polygon coordinates comprising
the long/lat grid))'" -to "RPC_MAX_ITERATIONS=101"
input_with_RPCs.tiff output.tiff</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This is the only configuration i can use to run <code>gdalwarp</code>
successfully. removing any single RPC_X tranformer option gives
me bogus output. The RPC_HEIGHT value i specify above is not
close to the mean or median elevation of the extent of my data;
mean is ~195m and median is ~150m.</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
With the debug turned on, any other set of parameters gives me
failed RPC convergence on several points. I am able to reproduce
this regularly by specifying RPC_DEM=dem.tif, where dem.tif is
the same data I used to extract elevation values when
calibrating the RPCs. I am seeing normalized latitude and
longitude values with magnitude > 1 (I checked every location
in the image, based on the metadata, the range is not outside of
[-1,1]), as well as normalized altitude values with magnitude
> 1 (there are some, not many, that have magnitude of 1.75). </div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
My workflow can be summarized as:<br>
<br>
</div>
<ol
data-editing-info="{"orderedStyleType":1,"unorderedStyleType":1}"
data-listchain="__List_Chain_425"
style="margin-top: 0px; margin-bottom: 0px; list-style-type: decimal;"
start="1">
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
load grids (image data, longitude, latitude)</div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">randomly
sample up to 4000 points in image coordinates, object
coordinates</span></div>
</li>
<ol
style="margin-top: 0px; margin-bottom: 0px; list-style-type: lower-alpha;"
start="1">
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">assign
z-value from SRTM DEM</span></div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">evaluate
if any of the points are in NODATA areas of SRTM (image
is coastal, so there are NODATA areas for SRTM here), if
so, remove those and generate more points</span></div>
</li>
</ol>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
normalize coordinates of grids to be in [-1,1], recording
offsets and scale</div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
calibrate RPC coefficients using all terms</div>
</li>
<li
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
write out GeoTIFF with image grid for pixels, along with RPC
required metadata fields and CRS EPSG:4326</div>
</li>
</ol>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
System information (please let me know if more is needed)</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
OS: Ubuntu 20.04 LTS (GNU/Linux
5.10.16.3-microsoft-standard-WSL2 x86_64) (Windows Subsystem for
Linux)</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
GDAL 3.6.0 (python)</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you in advance for any insight into this process! I am
happy to package up any of the data I am using, as well. I have
placed the initial data from the end of Step 5 described above,
along with some additional files, a sample gdalwarp call, and a
file-list.txt, at <a
href="https://drive.google.com/drive/folders/1BfevhKQa4ZHi_OQfiX_rUk2sqeoNVhyM?usp=sharing"
id="LPlnkOWAef49c06e-b1a7-175b-d89e-e930398f4b9a"
class="OWAAutoLink moz-txt-link-freetext"
data-loopstyle="linkonly" moz-do-not-send="true">
https://drive.google.com/drive/folders/1BfevhKQa4ZHi_OQfiX_rUk2sqeoNVhyM?usp=sharing</a></div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
If more is needed for anyone interested in having a look, please
let me know and I'll upload.</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Joe</div>
<div class="elementToProof"
style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>