r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
856 stars 119 forks source link

Is there a way to add transparency to a raster based on a variable? #671

Open bienflorencia opened 2 years ago

bienflorencia commented 2 years ago

How do I use a raster layer's value as the measure for the aplha/transparency of the layer?

For example:

tm_shape(raster1) +
    tm_raster(palette = 'PiYG', midpoint = NA, style= "cont") +
    tm_shape(raster2) +
    tm_raster(fill='white', aplha=<the_variable_value>) 

Or even better:

tm_shape(c(raster1, raster2)) +
    tm_raster(palette = 'PiYG', midpoint = NA, style= "cont", alpha=raster2) 

Thanks!

Nowosad commented 2 years ago

Hi @bienflorencia -- I do not think it is possible (yet?).