Zarr: fix BuildOverviews() on a new multiband dataset - #14977
Conversation
|
Thank you @rouault However, it does expose a couple of new problems. The first involves directly writing the overviews myself (which we use in some circumstances to avoid an extra pass through the data). This is demonstrated by the following Python fragment. import os
import numpy
from osgeo import gdal, osr
gdal.DontUseExceptions()
zarrFile = "testOverviews.zarr"
drvr = gdal.GetDriverByName('Zarr')
if os.path.exists(zarrFile):
drvr.Delete(zarrFile)
options = ["COMPRESS=BLOSC", "FORMAT=ZARR_V3"]
(nrows, ncols) = (1000, 1000)
bands = 1
ds = drvr.Create(zarrFile, ncols, nrows, bands, gdal.GDT_Byte, options=options)
ds.BuildOverviews(overviewlist=[4])
b = ds.GetRasterBand(1)
b.SetNoDataValue(0)
a = numpy.full((nrows, ncols), 25, dtype=numpy.uint8)
b.WriteArray(a)
closeReopen = False
if closeReopen:
ds = None
ds = gdal.Open(zarrFile, gdal.GA_Update)
b = ds.GetRasterBand(1)
b_ov = b.GetOverview(0)
ov = a[::4, ::4]
b_ov.WriteArray(ov)If If That does expose a second problem, which is that the no-data value is not being propagated into the overviews, which I think it should. This shows up as the following messages The main Many thanks, as always Ping @gillins |
Fixes #14963