You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wondering if the following approach was possible in tidyterra.
I have a spatraster with a layer for prediction value and another layer for standard error, and I want to plot using one layer to scale fill and the other to scale alpha. The current approach uses geom_tile after converting spatraster to a dataframe.
library(tidyterra)
library(ggplot2)
x <- rast(array(data = rnorm(120, 0, 1), dim = c(5, 5, 2)))
names(x) = c("prediction", "se")
xdf <- as.data.frame(x, xy = T)
ggplot() +
geom_tile(data = xdf, aes(x = x, y = y, fill = se, alpha = prediction)) +
scale_alpha_continuous(range = c(0, 1)) +
scale_fill_gradient(low = "white", high = "deeppink3") +
theme_minimal()
The text was updated successfully, but these errors were encountered:
Currently there is no way to achieve this with tidyterra, however your solution is completely fine IMHO. I would only add a coord_sf(crs = pull_crs(x)) to create a spatial-aware plot.
Just wondering if the following approach was possible in tidyterra.
I have a spatraster with a layer for prediction value and another layer for standard error, and I want to plot using one layer to scale fill and the other to scale alpha. The current approach uses geom_tile after converting spatraster to a dataframe.
The text was updated successfully, but these errors were encountered: