5.1 Plot methods for sp
objects
Let’s first get some data:
library(sp)
library(sf)
library(raster)
bel1 <- getData("GADM", country = "BEL", level = 1, path = "data")
#R> Warning in getData("GADM", country = "BEL", level = 1, path = "data"): getData will be removed in a future version of raster
#R> . Please use the geodata package instead
#R> Warning in getData("GADM", country = "BEL", level = 2, path = "data"): getData will be removed in a future version of raster
#R> . Please use the geodata package instead
Quick plot:
Two quick plots:
Slightly customized plots:
plot(bel1, col = "grey85", main = "Belgium")
plot(bel2, lwd = .5, add = TRUE)
points(coordinates(bel2), pch = 19, cex = .4)
city <- coordinates(bel2)[1, ]
text(city[1], city[2], labels = "Bruxelles", pos = 3, col = "#9728eb")