OSGeo / gdal

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

Converting non-LZW-compressed GeoTIFF to PNG produces black image #10307

Closed marklit closed 1 month ago

marklit commented 1 month ago

What is the bug?

This image, along with ~13 others for this dataset, uses LZW compression:

https://umbra-open-data-catalog.s3.amazonaws.com/sar-data/tasks/Suvarnabhumi%20International%20Airport,%20Thailand/feb0f267-9ec4-4e76-a8e3-05f42c755ff8/2024-02-16-02-42-52_UMBRA-05/2024-02-16-02-42-52_UMBRA-05_GEC.tif

$ gdalinfo feb0f267-9ec4-4e76-a8e3-05f42c755ff8/2024-02-16-02-42-52_UMBRA-05/2024-02-16-02-42-52_UMBRA-05_GEC.tif \
    | grep -A4 'Image Structure Metadata'
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
  LAYOUT=COG
RPC Metadata:

I'm able to convert it into a PNG without issue.

$ gdalwarp -overwrite \
    -ts 0 3840 \
    -te 100.728115807637948 13.730234530823225 \
        100.770749699068503 13.64420585877923 \
    feb0f267-9ec4-4e76-a8e3-05f42c755ff8/2024-02-16-02-42-52_UMBRA-05/2024-02-16-02-42-52_UMBRA-05_GEC.tif \
    has_lzw.png

This image, along with ~110 others in this dataset, isn't compressed with LZW. When I try and convert it into a PNG, I get a black image as a result.

https://umbra-open-data-catalog.s3.amazonaws.com/sar-data/tasks/Suvarnabhumi%20International%20Airport,%20Thailand/feae3b18-343f-4c9e-8947-b0889a24174b/2023-10-22-02-48-21_UMBRA-04/2023-10-22-02-48-21_UMBRA-04_GEC.tif

$ gdalinfo feae3b18-343f-4c9e-8947-b0889a24174b/2023-10-22-02-48-21_UMBRA-04/2023-10-22-02-48-21_UMBRA-04_GEC.tif \
    | grep -A4 'Image Structure Metadata'
Image Structure Metadata:
  INTERLEAVE=BAND
  LAYOUT=COG
Corner Coordinates:
Upper Left  (  689839.428, 1516971.354) (100d45'19.94"E, 13d42'56.43"N)

I'm not sure if the lack of LZW compression is the source of the issue but its the only major difference I can see in the makeup of the files.

Other differences I've since noticed:

Steps to reproduce the issue

See above

Versions and provenance

I'm using the following GDAL which was installed from the latest supported package for Ubuntu for Windows.

$ gdalwarp --version
GDAL 3.4.1, released 2021/12/27

Additional context

I suspect this is an issue that might have been resolved in newer versions of GDAL. If there is another format that I could convert between the GeoTIFF -> PNG conversion or another work around that doesn't involve me needing to compile a newer version of GDAL for Ubuntu for Windows I'd appreciate that.

marklit commented 1 month ago

Setting the CRS values fixed this.

$ gdalwarp -overwrite -s_srs 'EPSG:32647' -t_srs 'EPSG:4326' -ts 0 3840 -te 100.728115807637948 13.730234530823225 100.770749699068503 13.64420585877923 feae3b18-343f-4c9e-8947-b0889a24174b/2023-10-22-02-48-21_UMBRA-04/2023-10-22-02-48-21_UMBRA-04_GEC.tif no_lzw.png