qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.59k stars 3k forks source link

GDAL: "Compression" and "Description" values are not displayed in Layer Properties->Information for some GeoTIFF layers #58489

Closed agiudiceandrea closed 1 month ago

agiudiceandrea commented 2 months ago

What is the bug or the crash?

For some GeoTIFF raster layers, the "Compression" and "Description" values are not displayed in Layer Properties -> Information -> Information from provider

image

Steps to reproduce the issue

  1. Import in QGIS the test_compression.tif GeoTIFF raster layer contained in the attached zip file test_compression.zip
  2. Open the Layer Properties -> Information dialog window

Versions

QGIS version 3.38.2-Grenoble QGIS code revision 130c432394 Qt version 5.15.13 Python version 3.12.5 GDAL/OGR version 3.9.2 PROJ version 9.4.0 EPSG Registry database version v11.004 (2024-02-24) GEOS version 3.12.2-CAPI-1.18.2 SQLite version 3.45.1 PDAL version 2.6.3 PostgreSQL client version 16.2 SpatiaLite version 5.1.0 QWT version 6.2.0 QScintilla2 version 2.14.1 OS version Windows 10 Version 1903

Active Python plugins db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99

Supported QGIS version

New profile

Additional context

The test_compression.tif GeoTIFF raster layer file compression is DEFLATE.

The compression type is correctly reported by gdalinfo in the same system:

gdalinfo "test_compression.tif"
Driver: GTiff/GeoTIFF
Files: test_compression.tif
Size is 5120, 1987
GCP Projection =
GEOGCRS["WGS 84",
    ENSEMBLE["World Geodetic System 1984 ensemble",
        MEMBER["World Geodetic System 1984 (Transit)"],
        MEMBER["World Geodetic System 1984 (G730)"],
        MEMBER["World Geodetic System 1984 (G873)"],
        MEMBER["World Geodetic System 1984 (G1150)"],
        MEMBER["World Geodetic System 1984 (G1674)"],
        MEMBER["World Geodetic System 1984 (G1762)"],
        MEMBER["World Geodetic System 1984 (G2139)"],
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]],
        ENSEMBLEACCURACY[2.0]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["Horizontal component of 3D system."],
        AREA["World."],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
GCP[  0]: Id=1, Info=
          (0,0) -> (16.0114548706679,39.4883800190811,0)
GCP[  1]: Id=2, Info=
          (5120,0) -> (16.0117837339636,39.4883800190811,0)
GCP[  2]: Id=3, Info=
          (5120,1987) -> (16.0117837339636,39.4882836224255,0)
GCP[  3]: Id=4, Info=
          (0,1987) -> (16.0114548706679,39.4882836224255,0)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=DEFLATE
  INTERLEAVE=PIXEL
  PREDICTOR=2
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 1987.0)
Upper Right ( 5120.0,    0.0)
Lower Right ( 5120.0, 1987.0)
Center      ( 2560.0,  993.5)
Band 1 Block=5120x1 Type=Byte, ColorInterp=Red
  NoData Value=0
Band 2 Block=5120x1 Type=Byte, ColorInterp=Green
  NoData Value=0
Band 3 Block=5120x1 Type=Byte, ColorInterp=Blue
  NoData Value=0
Band 4 Block=5120x1 Type=Byte, ColorInterp=Alpha
  NoData Value=0

The compression type is also correctly reported by GetMetadataInfo:

from osgeo import gdal
ds = gdal.Open('test_compression.tif')
print(ds.GetMetadataItem('COMPRESSION', 'IMAGE_STRUCTURE')) # -> DEFLATE
print(ds.GetDescription()) # -> test_compression.tif
agiudiceandrea commented 2 months ago

@rouault, do you have any clue?

rouault commented 2 months ago

do you have any clue?

yes, this is because the dataset is referenced by GCPs, and thus QGIS creates a on-the-fly warped VRT, and uses it to get metadata, but it lacks them. I believe https://github.com/qgis/QGIS/pull/58638 should fix it, but haven't tested

agiudiceandrea commented 1 month ago

I believe #58638 should fix it, but haven't tested

I can confirm #58638 fixes this issue.