getBorders: Extract Polygons Borders

Description Usage Arguments Value Note See Also Examples

View source: R/getBorders.R

Description

Extract borders between polygons.

Usage

1
getBorders(x, id, spdf, spdfid = NULL)

Arguments

x

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

id

identifier field in x or spdf, default to the first column. (optional)

spdf

deprecated, a SpatialPolygonsDataFrame. This SpatialPolygonsDataFrame has to be projected (planar coordinates).

spdfid

deprecated, identifier field in spdf, default to the first column of the spdf data frame. (optional)

Value

An sf object (MULTILINESTRING) of borders is returned. This object has three id fields: 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, getOuterBorders

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(nuts2006)
# Get borders
nuts0.contig <- getBorders(x = nuts0.spdf)
# Plot Countries
plot(nuts0.spdf, border = NA, col = "grey60")
# Plot borders
plot(st_geometry(nuts0.contig), 
     col = sample(x = rainbow(nrow(nuts0.contig))), 
     lwd = 3, add = TRUE)

mtq <- st_read(system.file("shape/martinique.shp", 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(nuts0.contig))), 
     lwd = 3, add = TRUE)

cartography documentation built on Sept. 25, 2017, 5:03 p.m.