You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, trollimage has two behaviours when it comes to nodata: either a fill_value is provided and is used to fill the data (resulting in an image without alpha) or fill_value is None (default) in which case an alpha channel is used, and nodata value as set to full transparency.
It works very well in most cases.
However, the geotiff format supports the usage of dataset masks to flag out nodata pixels in a raster. They differ from alpha channels since they are purely binary. Benefits include lower disk space usage for storing the mask than an alpha channel (iiuc the mask is encoded on 1 bit per pixel), and allows more compression options, for example JPEG YCbCr (resulting in halving the size of the file saved to disk compared to JPEG alone, and YCbCr doesn't support alpha).
At the moment, the alpha channel generation is tightly coupled to the masking of the data, so we will have to refactor the code to be able to add support for a dataset mask.
Have you looked at how rioxarray makes this available? Given that we probably want to adopt rioxarray as a replacement for trollimage's custom geotiff handling, we should probably adopt/transition to a similar interface.
Currently, trollimage has two behaviours when it comes to nodata: either a fill_value is provided and is used to fill the data (resulting in an image without alpha) or fill_value is None (default) in which case an alpha channel is used, and nodata value as set to full transparency.
It works very well in most cases.
However, the geotiff format supports the usage of dataset masks to flag out nodata pixels in a raster. They differ from alpha channels since they are purely binary. Benefits include lower disk space usage for storing the mask than an alpha channel (iiuc the mask is encoded on 1 bit per pixel), and allows more compression options, for example JPEG YCbCr (resulting in halving the size of the file saved to disk compared to JPEG alone, and YCbCr doesn't support alpha).
At the moment, the alpha channel generation is tightly coupled to the masking of the data, so we will have to refactor the code to be able to add support for a dataset mask.
A link to the relevant rasterio documentation:
https://rasterio.readthedocs.io/en/latest/topics/masks.html#dataset-masks
https://rasterio.readthedocs.io/en/latest/api/rasterio.io.html?highlight=write_mask#rasterio.io.DatasetWriter.write_mask
An example of writing such a mask with rasterio:
The text was updated successfully, but these errors were encountered: