Closed alexjohnson-kobold closed 7 months ago
Actually looks as though the band descriptions I'm seeing aren't coming directly from write_cog
but from some custom code we have on top of it - regardless, that code won't (directly at least) work with save_cog_with_dask
so the request remains.
I would approach this by implementing an optional gdal_metadata_extra: str|List[str]|None = None
, for example
save_cog_with_dask(
xx, ...,
gdal_metadata_extra=[
'<Item name="DESCRIPTION" sample="1" role="description">green</Item>',
'<Item name="DESCRIPTION" sample="2" role="description">red</Item>',
])
This would require updating these two internal methods with an extra argument:
then passing on extra args in save_cog_with_dask
:
https://github.com/opendatacube/odc-geo/blob/1f8885490d8836f6dd6ad09640c639ee02c003f7/odc/geo/cog/_tifffile.py#L697-L698 https://github.com/opendatacube/odc-geo/blob/1f8885490d8836f6dd6ad09640c639ee02c003f7/odc/geo/cog/_tifffile.py#L712-L713
Then we can use that machinery to automatically add band names, overview resampling settings and whatever other relevant metadata other than stats to COG.
@Kirill888 thanks for the guidance on this. I modified save_cog_with_dask
to write band names by default using the dataset attribute long_name
by default. That way the user doesn't need to figure out how to deal with either XML escaping or -- even more fun -- GDAL's XML double escaping.
Sensible way to do it Matthew, build it in.
Using
write_cog
we get band descriptions, but these don't currently show up if we usesave_cog_with_dask
. Could this be added? For example if I open a COG created withwrite_cog
in a text editor I see a block like:Which means in QGIS I see band labels like "Band 04: swir1" whereas for a COG made by
save_cog_with_dask
I just see "Band 04"cc @mplough-kobold @Kirill888