if (FALSE) {
if(require(cartography)){
nuts3.spdf@data <- nuts3.df
t1 <- system.time(
s1 <- stewart(knownpts = nuts3.spdf,resolution = 40000,
varname = "pop2008",
typefct = "exponential", span = 100000,
beta = 3, mask = nuts3.spdf, returnclass = "sf")
)
t2 <- system.time(
s2 <- mcStewart(knownpts = nuts3.spdf, resolution = 40000,
varname = "pop2008",
typefct = "exponential", span = 100000,
beta = 3, mask = nuts3.spdf, cl = 3, size = 500,
returnclass = "sf")
)
identical(s1, s2)
cat("Elapsed time\n", "stewart:", t1[3], "\n mcStewart:",t2[3])
iso <- isopoly(x = s2,
breaks = c(0,1000000,2000000, 5000000, 10000000, 20000000,
200004342),
mask = nuts3.spdf, returnclass = "sf")
# cartography
opar <- par(mar = c(0,0,1.2,0))
bks <- sort(unique(c(iso$min, iso$max)))
choroLayer(x = iso, var = "center", breaks = bks, border = NA,
legend.title.txt = "pop")
layoutLayer("potential population", "","", scale = NULL)
par(opar)
}
}
Run the code above in your browser using DataLab