I have a geotiff file that is single band but contains multiple subdatasets. I use gdal with numpy to open a specific subdataset and mask some of its values.
$ gdalinfo sample.tif
sds = gdal.Open('GTIFF_DIR:2:sample.tif')
sds_mask = apply mask to sds
I want to put sds_mask back into the original geotiff or a copy of it. Is this possible with gdal?
I tried writing out all the subdatasets, modifying one of the subdatasets, and then merging them back together with gdal_translate and gdal_merge.py with the -separate option but it does not create a geotiff with subdatasets.