Rasters.jl
Rasters.jl copied to clipboard
Feature request: `mask_and_scale`
Hey there,
rioxarray exposes an argument mask_and_scale when opening a raster, which lazily scales the raster using the scales and offsets in metadata. Could we have this option in Rasters.jl, possibly in the Raster function?
Here is a quick proposition:
function scale(raster::Raster)
T = typeof(raster.metadata["scale"])
(raster .|> T) .* raster.metadata["scale"] .+ raster.metadata["offset"]
end
It's on the way!
See: https://github.com/rafaqz/Rasters.jl/pull/695
It's a bit trickier than that because it has to work lazily on larger than memory data, on RasterStack etc.
But it's pretty much there in the PR, just a few bugs to iron out.
Also this will be applied as the default when scale and offset are set. Keywords can turn it off.
Excellent!