# NOT RUN {
library(rasterly)
if(requireNamespace("grid") && requireNamespace("gridExtra")) {
x <- rnorm(1e7)
y <- rnorm(1e7)
category <- sample(1:5, 1e7, replace = TRUE)
data.frame(x = x, y = y, category = category) %>%
rasterly(mapping = aes(x = x, y = y, color = category)) %>%
rasterly_points(layout = "weighted") -> ds1
ds1
# layout with cover
data.frame(x = x, y = y, category = category) %>%
rasterly(mapping = aes(x = x, y = y, color = category)) %>%
rasterly_points(layout = "cover") -> ds2
ds2
# display side by side
grid::grid.newpage()
gridExtra::grid.arrange(
grobs = list(rasterlyGrob(ds1), rasterlyGrob(ds2)),
ncol = 2,
top = "'weighted' layout versus 'cover' layout"
)
}
# }
Run the code above in your browser using DataLab