I would like to adjust the basic colour of a raster plotted with tmap, when there is only one value in the raster.
Here is a very simple reproducible example:
library(raster)
library(tmap)
a <- raster(matrix(sample(c(1, NA), 10000, replace = TRUE, prob = c(0.01, 0.99)), nr = 100, nc = 100, ))
tm_shape(a) +
tm_raster()
You can see that the default yellow colour is barely visible by a human eye. Hence, when drawing a map where you only have a few pixels, it is extremely difficult to locate where are the pixels with values.
Unfortunately, I was not able to change this colour after multiple attempts. I think this issue may be encountered by other users, thus if a simple answer arises here it might be very helpful.
Unsuccessful attempts:
tm_shape(a) +
tm_raster(col = "black")
tm_shape(a) +
tm_raster(palette = "RdBu")
Note: for this one, I expected either a Red or a Blue colour to show up. Not grey... I tried to adjust midpoints as well but nothing changed.
tm_shape(a) +
tm_raster() +
tm_layout(aes.color= c(fill = "black"))