I have some tiffs
that I'd like to plot interactively in python using folium
(or any other package, but I don't know of any). My problem is, that I have many na-values in the raster. At the moment I read in the raster with rasterio
, read the data into a 2d-numpy
-array, and then I write it back out as .png
.
Finally I use folium
with:
rasterlayer = folium.FeatureGroup(name = "raster")
rasterlayer.add_child(folium.raster_layers.ImageOverlay(
image=ndvi,
bounds=[[bottom, left], [top, right]],
interactive=True,
cross_origin=False,
zindex=1,
colormap=matplotlib.pyplt.cm.Greens
))
m.add_child(rasterlayer)
m.add_child(folium.LayerControl())
m
But I get all the NA-Values printed in some colour. And I didn't find any solution to that problem. I had a look here:
https://stackoverflow.com/questions/50689068/display-raster-data-in-folium-handling-no-data-values
but also did not really help.
I also did set all NA-values in the "numpy"-array to 0
, but this also was not the solution. The NA-Values always got plotted. Is there some, relatively easy way, to omit the plotting of na values. And more general: What is a good way of plotting raster with folium? It seems that in R
it's so easy with packages like mapview
or tmap
and in python
it feels way more complicated...