Get borders between polygons.

mf_get_borders(x, id)

Arguments

x

an sf object of POLYGONS, using a projected CRS.

id

name of the identifier variable in x, default to the first column. (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 neighbor a border; id is the concatenation of id1 and id2 (with "_" as separator).

Examples

mtq <- mf_get_mtq()
# Extract 3 polygons
m <- mtq[c(5, 29, 9), ]
# Get borders
m_borders <- mf_get_borders(x = m)
# Plot polygons
mf_map(m)
# Plot borders
mf_map(m_borders,
  col = 1:4, lwd = c(8, 6, 4, 2),
  add = TRUE
)
# Plot labels
mf_label(m_borders, "id",
  overlap = FALSE,
  lines = FALSE, halo = TRUE,
  col = 1:4
)