Rasters.jl icon indicating copy to clipboard operation
Rasters.jl copied to clipboard

Arbitrary metadata not read from rasters in GDAL

Open asinghvi17 opened this issue 9 months ago • 2 comments

See the files in this zipfile: https://github.com/user-attachments/files/19419830/sub_leaf_type_2021.zip

using ArchGDAL
dataset = ArchGDAL.read("sub_leaf_type_2021/sub_leaf_type_2021.tif")
ArchGDAL.metadata(dataset)

yields

2-element Vector{String}:
 "AREA_OR_POINT=Area"
 "DataType=Generic"

but if I open it as a Raster

using Rasters
r1 = Raster("sub_leaf_type_2021/sub_leaf_type_2021.tif")
Rasters.metadata(r1)

yields

Metadata{Rasters.GDALsource} of Dict{String, Any} with 1 entry:
  "filepath" => "/Users/anshul/Downloads/sub_leaf_type_2021/sub_leaf_type_2021.tif"

which doesn't contain GDAL's keys...

edit: ah, this specific metadata seems to be read when constructing dims. But the general point stands, since the Rasters method is not actually checking the GDAL metadata at all...

asinghvi17 avatar Mar 24 '25 17:03 asinghvi17

Huh. But what does ArchGDAL.metadata call?

The first one we actually dont want/would always filter out in any case. Its encoded in the dimensions.

rafaqz avatar Mar 24 '25 18:03 rafaqz

https://github.com/rafaqz/Rasters.jl/blob/09a29d3936c591fee00e7a14efffa95a4a8d24f1/ext/RastersArchGDALExt/gdal_source.jl#L206-L230

we don't even read the metadata there, is the main issue...

asinghvi17 avatar Mar 24 '25 22:03 asinghvi17