Learn R Programming

cartography (version 2.1.2)

getLinkLayer: Create a Links Layer from a Data Frame of Links.

Description

Create a links layer from a data frame of links.

Usage

getLinkLayer(x, xid = NULL, df, dfid = NULL, spdf, spdf2 = NULL,
  spdfid = NULL, spdf2id = NULL, dfids = NULL, dfide = NULL)

Arguments

x

an sf object, a simple feature collection (or a Spatial*DataFrame).

xid

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

df

a data frame that contains identifiers of starting and ending points.

dfid

identifier fields in df, character vector of length 2, default to the two first columns. (optional)

spdf

defunct.

spdf2

defunct.

spdfid

defunct.

spdf2id

defunct.

dfids

defunct.

dfide

defunct.

Value

An sf LINESTRING is returned, it contains two fields (origins and destinations).

See Also

gradLinkLayer, propLinkLayer

Examples

Run this code
# NOT RUN {
library(sp)
library(sf)
data("nuts2006")
# Create a link layer
head(twincities.df)
# Select links from Ireland (IE)
twincitiesIE <- twincities.df[substr(twincities.df$i,1,2)=="IE", ]
twincities.sf <- getLinkLayer(x = nuts2.spdf, df = twincitiesIE, dfid = c("i", "j"))
# Plot the links
plot(nuts2.spdf, col = "#6C6870")
plot(st_geometry(twincities.sf), col = "#F78194", add = TRUE)
# }

Run the code above in your browser using DataLab