xarray_leaflet icon indicating copy to clipboard operation
xarray_leaflet copied to clipboard

mask nan in single band raster

Open 12rambau opened this issue 2 years ago • 0 comments

Fix #62 Capture d’écran 2022-04-21 à 23 11 22

I computed the alpha channel as it is done for rgb images. My assomption is that single band dataset will always use np.nan as a nodata value.

At first I wanted to use:

alpha = np.where(das[0]==self._da.rio.nodata, 0, 1)

but if nodata is np.nan it always returns 1. If you know a trick that could work for any value + np.nan that would be great. if not, the assumption I made seems to be commonly accepted. e.g @giswqs use the same in the add_raster method of geemap: https://github.com/giswqs/geemap/blob/13c83f59ebc6790b531277c5908859d4cb5ec190/geemap/geemap.py#L3526

12rambau avatar Apr 21 '22 21:04 12rambau