Rasterize displaying nodata missing_value _FillValue for integer (uint16) data

I’m struggling to display my integer image 0 values as transparent using rasterize. Looking at the release notes for holoviews=1.14.0 it says this should be possible and refers to Working with Large Data but I still can’t figure it out.

What do I need to modify here?

Full notebook displaying the issue here: https://nbviewer.jupyter.org/gist/rsignell-usgs/a0cce73ae5d8b9b5fa77b836ef2adc08

@philippjfr responded on gitter that we need to do redim.nodata(value=0) here. And yep, that works!

Here’s the full Notebook example

Does anyone know how to use the .redim.nodata(value=0) solution can be applied to a plot with widget selection, e.g. if in the example above da was a stack if some bands and I wanted to call something like

da.hvplot.image(x='x',y='y',groupby='band',widgets={'band':pn.widgets.Select},rasterize=True,data_aspect=1)

How can the redim be applied to the individual images?

I think it’s similar to this:

image, select = ds.hvplot('lon', 'lat', widgets={'time':pn.widgets.Select})

Once widgets is passed, the image is no longer an image type, but a row, so you need to split it out. Once you split it out, you can call redim on image.

Thanks, @ahuang11. I tried to split it out and then can call redim on image.object. But redim doesn’t get applied and interestingly, image has the selection widget embedded. See Screenshot. I also tried a call to da.hvplot() instead of da.hvplot.image() to no avail. Any other thoughts?

That redim does look like it’s working (its at the bottom of the colorbar)

I tried to replicate the data array @rsignell was showing above. Still no luck masking out the nodata values in my plot.

xr.__version__

'0.20.2'

hvplot.__version__

'0.7.3'

I figured out that the issue comes from having named the data array. Then (values=0) needs to be adjusted with (<Name>=0). However, programatically that is hard if the name of a data array changes dynamically as (da.name=0) does not work. Working example with da0.name='Dummy' and hence (Dummy=0) for the redim.

2 Likes