Chapter 7 Geometry manipulation

To manipulate geometries, there are few options. For spatial objects defined with sp, there is a specific package to manipulate vector objects: rgeos. The equivalent of most common functions in sp are found in sf. Finally, there are a set of interesting functions in raster to handle the manipulation of rasters with vector objects.

Let’s first load the packages required and download a simple shapefile of Belgium.

library(sp)
library(sf)
library(rgeos)
library(raster)
bel2 <- getData(name = "GADM", country = "BEL", path =  "data", level = 2)
#R>  Warning in getData(name = "GADM", country = "BEL", path = "data", level = 2): getData will be removed in a future version of raster
#R>  . Please use the geodata package instead
plot(bel2)
text(bel2, 1:11)