Got ERROR 1: Geotransform should define a north-up non rotated area, but area seems not rotated
What is the bug?
In some cases the Geotransformation raises ERROR 1: Geotransform should define a north-up non rotated area, but area seems not rotated. See also the attached example. example.zip
Steps to reproduce the issue
Unzip example.
gdal_create test.pdf -co COMPOSITION_FILE=pdfcomposition_working.xml
gdal_create test.pdf -co COMPOSITION_FILE=pdfcomposition_broken.xml
The last command raises the error mentioned before.
After investigation the error is happening here: https://github.com/OSGeo/gdal/blob/9581c776498d594217ff597685f9fdef3f733e57/frmts/pdf/pdfcreatefromcomposition.cpp#L763
The second condition is not met, because
std::fabs(georeferencing.m_adfGT[4]) is not smaller than
1e-5 * std::fabs(georeferencing.m_adfGT[5]))
georeferencing.m_adfGT[4] has for example the value 4.76e-19 and georeferencing.m_adfGT[5] has for example the value 0. I would assume 4.76e-19 ≈ 0.
But maybe I'm wrong and the issue is somewhere different. Any ideas how to resolve this?
Thanks in advance.
Versions and provenance
3.8.4, Package from Distribution. Ubuntu 24.04.1 LTS
Additional context
No response
But maybe I'm wrong and the issue is somewhere different.
The set of GCPs is inconsistent. It forms a "hour-glass" like shape if I might say. The fact that it "works" (actually it doesn't really) for working is just due to numerical precision luck/unluck
if I print the adfGT[] coefficients, I get:
$ gdal_create test.pdf -co COMPOSITION_FILE=pdfcomposition_working.xml 4.604582 0.002127 0.000000 5.500000 0.000000 0.000000 4.602405 0.002132 0.000000 5.500000 0.000000 0.000000
$ gdal_create test.pdf -co COMPOSITION_FILE=pdfcomposition_broken.xml 4.598406 0.002142 0.000000 5.500000 0.000000 0.000000 4.596238 0.002147 0.000000 5.500000 -0.000000 0.000000 ERROR 1: Geotransform should define a north-up non rotated area.
In both cases the fact that adfGT[5] is zero or close to it is a sign that the GCPs don't make sense. adfGT[5] is supposed to be the resolution in the Y axis. This can't be a zero value for a valid geotransform.
In https://github.com/OSGeo/gdal/pull/11620 I make GDALGCPsToGeoTransform() to fail in both cases
@rouault Thanks for your fast response. You are right. Both cases are invalid.