OSGeo / gdal

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

Wrong handling of angular units in GeoTIFF #10154

Closed agisoft-metashape closed 3 months ago

agisoft-metashape commented 3 months ago

What is the bug?

When reading SRS definition from GeoTIFF file with AngularGrad units GDAL seem to incorrectly interpret ProjNatOriginLatGeoKey parameter as if it was written in degrees.

But according to GeoTIFF specification angular projection parameters (including ProjNatOriginLatGeoKey) shall have units specified by the GeogAngularUnitsGeoKey: https://docs.ogc.org/is/19-008r4/19-008r4.html#_map_projection_parameters_coordinate_operation_parameters

Steps to reproduce the issue

A test image in NTF (Paris) / Lambert Sud France (EPSG:27563) projection: test_27563_tif.zip

listgeo utility lists the ProjNatOriginLatGeoKey value in angular units (grads) as required by GeoTIFF specification:

$ listgeo test_27563.tif

...
      GeogAngularUnitsGeoKey (Short,1): Angular_Grad
      GeogAngularUnitSizeGeoKey (Double,1): 0.0157079633     
...
      ProjNatOriginLatGeoKey (Double,1): 49               
...

But gdalinfo (GDAL 3.8.4) prints incorrect value for this parameter:

$ gdalinfo test_27563.tif

...
                PARAMETER["Latitude of natural origin",54.4444444444444,
                    ANGLEUNIT["grad",0.015707963267949],
                    ID["EPSG",8801]],
...

Complete listgeo output: test_27563_listgeo.txt Complete gdalinfo output: test_27563_gdalinfo.txt

Versions and provenance

GDAL 3.8.4, released 2024/02/08 running on Windows 10

Additional context

No response

jratike80 commented 3 months ago

What is the bug? Is it the different number of coordinates in

0.0157079633 (listgeo) and 0.015707963267949 (gdalinfo)

If angle was considered to be in degrees I would expect to see something like

ANGLEUNIT["degree",0.0174532925199433]

agisoft-metashape commented 3 months ago

The bug is in the value of Latitude of natural origin reported by GDAL. It should be 49 grads, not 54.4444444444444 grads.