How to add a nodata mask or alpha channel to a source image that is read-only or should be treated as such?
For example I have this satellite image that uses jpeg compression in a geotiff. Since the source already uses a lossy compression we don't want to run it through any process that will resample the valid pixels again, thus losing more information. We also don't want to pay the storage penalty of converting to another file using lossless compression because a) we're duplicating the source, and b) the lossless-file will be several times larger than the source.
Yellow is current nodata (actually 0,0,0
). Black jagged perimeter is what we want to turn into nodata.
The gdal nearblack utility is a very convenient method of removing this unwanted collar in one step but we could also use a polygon mask or some other method. Unfortunately all of the methods I'm aware of create redundant copies of the data and/or resample our value pixels which we want to leave unchanged.