# NOT RUN {
library(sf)
grid <- gisco_get_grid(resolution = 20)
grid$popdens <- grid$TOT_P_2011 / 20
breaks <-
c(
0,
500,
1000,
2500,
5000,
10000,
25000,
50000,
max(grid$popdens) + 1
)
pal <- hcl.colors(length(breaks) - 2, palette = "inferno", alpha = 0.7)
pal <- c("black", pal)
opar <- par(no.readonly = TRUE)
par(mar = c(0, 0, 0, 0), bg = "grey2")
plot(
grid[, "popdens"],
pal = pal,
key.pos = NULL,
breaks = breaks,
main = NA,
xlim = c(2500000, 7000000),
ylim = c(1500000, 5200000),
border = NA
)
par(opar)
# }
Run the code above in your browser using DataLab