-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ogr2ogr and gdalwarp -gcp -tps produce different results #8572
Comments
I wonder if the y coordinates in the raster case are counted from the top-left corner but in the vector case from the lower-left corner. |
The core of the issue is that the TPS (and probably GCP) transformers are not invertible, and for gdalwarp we use the inverse direction to go from a georeferenced location to the source pixel (column, line) coordinate $ echo 7453 1955 | gdaltransform -tps tif_with_cross_gdal_translate_gcp.tif $ echo 7453 1955 | gdaltransform -tps tif_with_cross_gdal_translate_gcp.tif | gdaltransform -i -tps tif_with_cross_gdal_translate_gcp.tif |
Thanks for your quick reply 👍 I am not sure I quite follow though; both the I am not trying to reverse the transformation, simply expecting, the same transformation done by the 2 utilities to produce the same results for the same input. To put it another way, if I gave |
That's what you believe ;-) But the way gdalwarp works is that it goes from each target pixel and computes the source pixel coordinate, and that involves the inverse direction of the TPS transformer, which doesn't perfectly roundtrip with the forward way |
But but, surely one of these results must be inherently “wrong”?! Given the GCP points and the TPS algorithm, is it not the case that one of these results must be the actual solution and the other is 330m incorrect at that location? Accepting the inevitable however, what can I do project pixel points in the same way as |
Working on implementing an exact inverse transformer |
With the fix in #8573, we now get much better reversibility
|
Perfect, that sounds much more accurate; many thanks for your quick fix. 😃 I will close this issue off now and await the release of 3.8.0. |
TPS transformer: use an iterative method to refine the inverse transformation (fixes #8572)
Expected behavior and actual behavior.
The results of a GCP reprojection seems to be different between the output of
gdal_translate & gdalwarp
andogr2ogr
Steps to reproduce the problem.
Given the un-georeferenced TIFF tif_with_cross.zip:
Embed GCP points:
gdapwarp the image:
Opening the output of gdalwarp
tif_with_cross_gdal_translate_gcp_gdalwarp.tif
gives the following result:The cross on the image is located at pixel
7453,1955
, putting this coordinate throughogr2ogr
using the same GCP and TPS option:Produces:
Opening this GeoJSON shows the point is significantly different (~330m) to the location of the cross on the GeoTIFF:
The cross on the GeoTIFF occurs around
-3.91015603
,53.20182776
Operating system
Rocky Linux 8.6
GDAL version and provenance
GDAL 3.7.2, released 2023/09/05
The text was updated successfully, but these errors were encountered: