# \donttest{
library(sf)
library(ggplot2)
library(dplyr)
if (require(giscoR)) {
useBorder = TRUE
} else {
useBorder = FALSE
print("You need to install giscoR for plotting borders and clipping the gridded maps")
}
# These are SYNTHETIC agricultural FSS data
data(ifs_dk) # Census data
# Create spatial data
ifg = fssgeo(ifs_dk, locAdj = "LL")
if (useBorder) {
# Read country borders, only used for plotting, remove oversea regions
borders = gisco_get_nuts(nuts_level = 0)
}
ress = c(1,5,10,20,40, 80, 160)*1000
# Gridding Utilized agricultural area (UAA)
ifl = gridData(ifg, "UAA",res = ress)
# Create a multi-resolution grid of UAA
himg1 = multiResGrid(ifl, vars = "UAA", ifg = ifg)
if (useBorder) {
p1 = MRGplot(himg1, UAA, transform = "log10", borders = borders, clip = TRUE)
} else {
p1 = MRGplot(himg1, UAA, transform = "log10")
}
p1
# Plot can be customized further (reverting to ggplot default color scale in this case)
p1 + scale_color_continuous() + scale_fill_continuous()
# }
Run the code above in your browser using DataLab