yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
141 stars 27 forks source link

maximum not always maximum #258

Open visr opened 2 years ago

visr commented 2 years ago

In this post: https://discourse.julialang.org/t/get-true-maximum-value-of-a-raster/70622/2

I found out that ArchGDAL.maximum, does not do any computation, and just returns the typemax if it is not in the metadata.

https://github.com/yeesian/ArchGDAL.jl/blob/8f4ace3d927e7f634927a5cb59c605bcbbdffda0/src/raster/rasterband.jl#L225-L231 https://github.com/JuliaGeo/GDAL.jl/blob/3838e938642712cf8a98c52df5937dcfdb19221e/src/GDAL.jl#L8631-L8647

The C API docs only say "Fetch the maximum value for this band.", but the C++ docs actually explains this: https://gdal.org/api/gdalrasterband_cpp.html#classGDALRasterBand_1a6021d86aca5668bd10e4e4f3f1967ce5

Right now we don't use pbSuccess, but perhaps we should. Don't know how though. We could optionally return it, such that users can check it if they want. In any case we should document this behavior.

yeesian commented 2 years ago

Thanks for reporting this!