<div dir="ltr">Hello, I have this process to convert a URL to a MEM dataset. <br><br>It's not the target data but it's representative, a netcdf with band-level and dataset-level metadata. We can clear the dataset level with COPY_SRC_MDD, but I can't see how to do that for the band level. We're hoping to keep this  without generating files, the final step uses VSI to read into a byte array. <br><br>Can I clear the band metadata without an intermediate dataset? Opening in update mode breaks the COG layout (or is that ok to do this with IGNORE_COG_LAYOUT_BREAK=YES ?). <br><br><br>from osgeo import gdal<br>gdal.UseExceptions()<br><br>dsn = "vrt:///vsicurl/<a href="https://www.ncei.noaa.gov/data/sea-surface-temperature-optimum-interpolation/v2.1/access/avhrr/202405/oisst-avhrr-v02r01.20240511.nc?sd_name=sst">https://www.ncei.noaa.gov/data/sea-surface-temperature-optimum-interpolation/v2.1/access/avhrr/202405/oisst-avhrr-v02r01.20240511.nc?sd_name=sst</a>"<br><br>opts = gdal.TranslateOptions(format = "COG",<br>     creationOptions = [ "COMPRESS=ZSTD", "PREDICTOR=STANDARD", "RESAMPLING=AVERAGE",<br>     "SPARSE_OK=YES", "COPY_SRC_MDD=NO"])<br><br>ds = gdal.Open(dsn)<br>tmp = "/vsimem/tmp1.tif"<br>## here we lose the dataset-level metadata as desired with COPY_SRC_MDD<br>gdal.Translate(tmp, ds, options = opts)<br><br>## but the band metadata is still there<br>lds = gdal.Open(tmp)<br>#{'add_offset': '0', 'long_name': 'Daily sea surface temperature', 'NETCDF_DIM_time': '16932', 'NETCDF_DIM_zlev': '0', 'NETCDF_VARNAME': 'sst', 'scale_factor': '0.0099999998', 'units': 'Celsius', 'valid_max': '4500', 'valid_min': '-300', '_FillValue': '-999'}<br>lds.Close()<br>ds.Close()<br><br><br><br>I guess I need to open and translate to another COG dataset after breaking the COG layout? <br><br><br><br>## now open in rw, to zap band level md (but breaks COG layout)<br>#lds = gdal.OpenEx(tmp, gdal.GA_Update, open_options =  ["IGNORE_COG_LAYOUT_BREAK=YES"])<br>#lds.GetRasterBand(1).SetMetadata({})<br>#lds.Close()<br>#Warning 1: tmp1.tif: The IFD has been rewritten at the end of the file, which breaks COG layout.<br><br>ds = gdal.Open(tmp)<br>#Warning 1: tmp1.tif: This file used to have optimizations in its layout, but those have been, at least partly, invalidated by later changes<br><br>Cheers, Mike<br><br><br><br><br>--<br>Michael Sumner<br>Research Software Engineer<br>Australian Antarctic Division<br>Hobart, Australia<br>e-mail: <a href="mailto:mdsumner@gmail.com">mdsumner@gmail.com</a><br></div>