Skip to content

FillValue/nodata not in metadata for JPEG 2000 files #4

@Alexander-Barth

Description

@Alexander-Barth

JPEG 2000 files seem to not expose fill values (no data) with the ArchGDAL.getnodatavalue as it is the case for GeoTIFF files.

See also
https://gis.stackexchange.com/questions/280107/writing-no-data-value-within-jpeg2000kdu-with-gdal-translate

julia> ds
Dataset: ./GRANULE/L1C_T32TPQ_A007471_20260209T102157/IMG_DATA/T32TPQ_20260209T102201_B10.jp2
Group: /

Dimensions
   cols = 1830
   rows = 1830

Variables
  lon   (1830 × 1830)
    Datatype:    Float64 (Float64)
    Dimensions:  cols × rows
    Attributes:
     standard_name        = longitude
     units                = degrees_east

  lat   (1830 × 1830)
    Datatype:    Float64 (Float64)
    Dimensions:  cols × rows
    Attributes:
     standard_name        = latitude
     units                = degrees_north

  x   (1830)
    Datatype:    Float64 (Float64)
    Dimensions:  cols
    Attributes:
     standard_name        = projection_x_coordinate

  y   (1830)
    Datatype:    Float64 (Float64)
    Dimensions:  rows
    Attributes:
     standard_name        = projection_y_coordinate

  crs  
    Attributes:
     grid_mapping_name    = transverse_mercator
     longitude_of_central_meridian = 9.0
     false_easting        = 500000.0
     false_northing       = 0.0
     latitude_of_projection_origin = 0.0
     scale_factor_at_central_meridian = 0.9996
     longitude_of_prime_meridian = 0.0
     semi_major_axis      = 6.378137e6
     inverse_flattening   = 298.257223563
     crs_wkt              = PROJCS["WGS 84 / UTM zone 32N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32632"]]
     GeoTransform         = 600000.0 60.0 0.0 5.00004e6 0.0 -60.0

  band1   (1830 × 1830)
    Datatype:    UInt16 (UInt16)
    Dimensions:  cols × rows
    Attributes:
     grid_mapping         = crs

Global attributes
  Conventions          = CF-1.8

Also osgeo.gdal does not report the fill value encoded in MTD_MSIL1C.xml

</Product_Info>
        <Product_Image_Characteristics>
            <Special_Values>
                <SPECIAL_VALUE_TEXT>NODATA</SPECIAL_VALUE_TEXT>
                <SPECIAL_VALUE_INDEX>0</SPECIAL_VALUE_INDEX>
            </Special_Values>
....
% cd /mnt/data1/abarth/.julia/dev/STAC/examples/tmp/S2C_MSIL1C_20260209T102201_N0512_R065_T32TPQ_20260209T123710.SAFE

from osgeo import gdal
ds = gdal.Open("MTD_MSIL1C.xml")
subdatasets = ds.GetSubDatasets()
s2_10m = gdal.Open(subdatasets[0][0])
band = s2_10m.GetRasterBand(1)
a = band.GetNoDataValue()
type(a)
# NoneType

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions