getBorders {cartography}R Documentation

Extract Polygons Borders

Description

Extract borders between polygons.

Outer borders are non-contiguous polygons borders (e.g. maritime borders).

Usage

getBorders(x, id, spdf, spdfid)

getOuterBorders(x, id, res = NULL, width = NULL, spdf, spdfid)

Arguments

x

an sf object, a simple feature collection or a SpatialPolygonsDataFrame.

id

name of the identifier variable in x, default to the first column. (optional)

spdf

defunct.

spdfid

defunct.

res

resolution of the grid used to compute outer borders (in x units). A high resolution will give more detailed borders. (optional)

width

maximum distance between used to compute outer borders (in x units). A higher width will build borders between units that are farther apart. (optional)

Value

An sf object (MULTILINESTRING) of borders is returned. This object has three id variables: id, id1 and id2. id1 and id2 are ids of units that neighbour a border; id is the concatenation of id1 and id2 (with "_" as separator).

Note

getBorders and getOuterBorders can be combined with rbind.

See Also

discLayer

Examples

library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
# Get borders
mtq.borders <- getBorders(x = mtq)
# Plot polygons
plot(st_geometry(mtq), border = NA, col = "grey60")
# Plot borders
plot(st_geometry(mtq.borders), 
     col = sample(x = rainbow(nrow(mtq.borders))), 
     lwd = 3, add = TRUE)
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
# Get units borders
mtq.outer <- getOuterBorders(x = mtq, res = 1000, width = 2500)
# Plot municipalities
plot(st_geometry(mtq), col = "grey60")
# Plot borders
plot(st_geometry(mtq.outer), col = sample(x = rainbow(nrow(mtq.outer))),
     lwd = 3, add = TRUE)

[Package cartography version 3.0.0 Index]