USDAForestService / gdalraster

R Bindings to GDAL (Geospatial Data Abstraction Library)
https://usdaforestservice.github.io/gdalraster/
Other
41 stars 7 forks source link

plot orientation with positive-y (note, for discussion) #547

Open mdsumner opened 2 weeks ago

mdsumner commented 2 weeks ago

this had me going for a while, read the raster here when it is created by gdalmdimtranslate:

https://github.com/OSGeo/gdal/issues/11041

#gdalmdimtranslate -of ZARR in.nc out-gdal.zarr 
## gdalinfo ZARR:"out-gdal.zarr":/air_temperature_2m
library(gdalraster)
ds <- new(GDALRaster, "ZARR:"out-gdal.zarr":/air_temperature_2m")
plot_raster(ds)

image

Essentially $bbox() is (xmin, ymax, xmax, ymin) and this controls the plot orientation.

It presents genuinely "upside down", because the R plot axis is inverted. (The contours are me adding a terra version of elevation to the map, which also surprisingly adds to the plot correctly - I guess because rasterImage() and plot() generally allows inversion ...)

I'm not saying this is a problem ... just wanted to share it, because maybe we want different behaviour for positive-y cases.

ctoney commented 2 weeks ago

Thanks for the description of this.

maybe we want different behaviour for positive-y cases

Ideally display should do what QGIS does. However, gdalraster currently implements the GDAL raster data model and does not yet implement the multidimensional raster data model. So I'm unsure if/how this should be handled at the moment. We get the correct plot orientation and bbox on the netCDF "classic raster" as expected (i.e., with ds <- new(GDALRaster, 'NETCDF:"in.nc":air_temperature_2m')).

Support for multidim raster should be added eventually. Please let me know if you have other suggestions for the meantime though.