OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.94k stars 2.57k forks source link

Order 2 GCP warping inversion not consistant with forward path ==> inaccurate guessed extent when wrapping #3626

Open hbarrett opened 3 years ago

hbarrett commented 3 years ago

If the gcps stretch the image beyond the dimensions of the original raster it appears to clip the data that sits outside of the original raster dimensions rather than increase the raster dimensions to fit the stretched data .

From Even:

Jukka' suggestion is a good one. Using -tps solver or affine approximation -order 1 fixes the issue. The default behaviour with GCPs when there are 6 or more of them is to use the second order polynomial adjustment. The issue here is when computing output bounds. We actually compute two 2nd order polynomial adjustments: one from source image coordinates to georeferenced ones, and one from georeferenced ones to source image. The former one is used to compute the output bounds, but the second one is used to do warping. The issue with 2nd order polynomial is that those two transformers are generally not the inverse of each other... We should likely compute the source image coordinates -> georeferenced coordinates as an iterative inversion of the other one, so they are invertible. The first order polynomial / affine transformation hasn't that issue due to how affine transformation works. The TPS one isn't likely perfectly invertible but TPS transformation is guaranteed to be exact at GCPs, so that diminishes the effect. But 2nd order polynomial has overshoots particularities that can cause the issue observed.

Steps to reproduce the problem.

https://haysbarrett.com/gdal_translate/

jatin142002 commented 3 years ago

I want to contribute . Could you please help me and guide me how to fix this issue ?? Since I am a beginner I need someone for guidance so that I do not make any mistake .

rouault commented 7 months ago

Cf 01eefefeb9ef5024d6b84644d366a1fe8e695b0f that can serve as inspiration