xarray-contrib / xarray_leaflet

An xarray extension for tiled map plotting.
https://xarray-leaflet.readthedocs.io
MIT License
163 stars 21 forks source link

mask nan in single band raster #63

Open 12rambau opened 2 years ago

12rambau commented 2 years ago

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