cd gdal/autotest
python3
from osgeo import gdal
ds = gdal.OpenEx('gdrivers/data/netcdf/byte_no_cf.nc', gdal.OF_MULTIDIM_RASTER)
ds.GetRootGroup().OpenMDArray("Band1").GetShape()
# (20, 20)
## create a new dataset with view spec
nds = gdal.MultiDimTranslate("/vsimem/array_view.zarr", ds, format="Zarr", arraySpecs=['name=Band1,view=[::2,::4]'])
## no change from source
nds.GetRootGroup().OpenMDArray("Band1").GetShape()
# (20, 20)
## I expect that to work at command line with
## gdalmdimtranslate gdrivers/data/netcdf/byte_no_cf.nc out.zarr -of Zarr -array 'name=Band1,view=[::2,::4]'
## calling GetView directly works
ds.GetRootGroup().OpenMDArray("Band1").GetView("[::2,::4]").GetShape()
# (10, 5)
demonstrate successful use of sf utils vs gdal_read_mdim to get a subset with the GDAL mdim arraySpec (this only works the same in both in GDAL >= 3.8.0 and some backport patch of 3.7)
OSGeo/gdal#8297
reported on gdal-dev: https://lists.osgeo.org/pipermail/gdal-dev/2023-August/057591.html
Created on 2023-08-31 with reprex v2.0.2
prior to this fix we see
Created on 2023-09-01 with reprex v2.0.2