Skip to content

ValueError: 'PNG' is not a valid Compression when reading MRF file #3256

@oysteinfs

Description

@oysteinfs

Hey!
Im using rasterio to retrieve relevant metadata from rasters in different formats. And one of those formats are MRF:
https://github.com/nasa-gibs/mrf/blob/master/doc/MUG.md

Ive created some test cases for different mrf configurations. Most of them work, but PNG compressed mrf does not work because rasterio doesnt recognize "PNG" as valid compression.

Expected behavior and actual behavior.

mrf file creation:

gdal_translate -of MRF -co COMPRESS=PNG input.tif test_mrf_png.mrf

Then opening with rasterio.open

>>> src = rasterio.open("test_mrf_png.mrf")
>>> src.profile
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rasterio/_base.pyx", line 1039, in rasterio._base.DatasetBase.profile.__get__
  File "rasterio/_base.pyx", line 986, in rasterio._base.DatasetBase.compression.__get__
  File "/opt/conda/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'PNG' is not a valid Compression

I expect that "PNG" is a valid compression

Steps to reproduce the problem.

Unfortunately i cant share the data im working with. But it should be reproproducable with provided gdal_translate command above.

Environment Information

rasterio info:
  rasterio: 1.4.2
      GDAL: 3.9.3
      PROJ: 9.5.0
      GEOS: 3.13.0
 PROJ DATA: /opt/conda/share/proj
 GDAL DATA: /opt/conda/share/gdal

System:
    python: 3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 16:05:46) [GCC 13.3.0]
executable: /opt/conda/bin/python
   machine: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.36

Python deps:
    affine: 2.4.0
     attrs: 24.2.0
   certifi: 2024.08.30
     click: 8.1.7
     cligj: 0.7.2
    cython: None
     numpy: 1.26.4
click-plugins: None
setuptools: 75.6.0

Installation Method

Installed using micromamba dockerfile with rasterio installed from conda-forge

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions