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 ... Subdatasets: SUBDATASET_1_NAME=GTIFF_DIR:1:sample.tif SUBDATASET_1_DESC=... SUBDATASET_2_NAME=GTIFF_DIR:2:sample.tif SUBDATASET_2_DESC=... # pseudocode 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.