#### Example with type = "line"
mystewart <- stewart(knownpts = spatPts, varname = "Capacite",
typefct = "exponential", span = 1000, beta = 3,
resolution = 50, longlat = FALSE,
mask = spatMask)
# Create a raster of potentials values
mystewartraster <- rasterStewart(x = mystewart, mask = spatMask)
# Display the raster and get break values
break.values <- plotStewart(x = mystewartraster)
# Create contour SpatialLinesDataFrame
mystewartcontourpoly <- contourStewart(x = mystewartraster,
breaks = break.values,
type = "line")
# Display the Map
plot(spatMask, add=TRUE)
plot(mystewartcontourpoly, border = "grey40",add = TRUE)
plot(spatPts, cex = 0.8, pch = 20, col = "black", add = TRUE)
#### Example with type = "poly"
mystewart <- stewart(knownpts = spatPts, varname = "Capacite",
typefct = "exponential", span = 1000, beta = 3,
resolution = 50, longlat = FALSE,
mask = spatMask)
# Create a raster of potentials valuesn, no mask
mystewartraster <- rasterStewart(x = mystewart)
# Display the raster and get break values
break.values <- plotStewart(x = mystewartraster)
# Create contour SpatialLinesDataFrame
mystewartcontourpoly <- contourStewart(x = mystewartraster,
breaks = break.values,
mask = spatMask,
type = "poly")
# Display the map
library(cartography)
opar <- par(mar = c(0,0,1.1,0))
choroLayer(spdf = mystewartcontourpoly,
df = mystewartcontourpoly@data,
var = "mean", legend.pos = "topleft",
breaks = break.values, border = "grey90",
lwd = 0.2,
legend.title.txt = "Potential number\nof beds in the\nneighbourhood",
legend.values.rnd = 0)
plot(spatMask, add = TRUE)
propSymbolsLayer(spdf = spatPts, df = spatPts@data, var = "Capacite",
legend.title.txt = "Number of beds",
col = "#ff000020")
layoutLayer(title = "Global Accessibility to Public Hospitals",
south = TRUE, sources = "", author = "")
par(opar)Run the code above in your browser using DataLab