Create a links layer from a data frame of links.
getLinkLayer( x, xid = NULL, df, dfid = NULL, spdf, spdf2 = NULL, spdfid = NULL, spdf2id = NULL, dfids = NULL, dfide = NULL )
| x | an sf object, a simple feature collection (or a Spatial*DataFrame). |
|---|---|
| xid | name of the identifier variable in x, default to the first column (optional) |
| df | a data frame that contains identifiers of starting and ending points. |
| dfid | names of the identifier variables 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. |
An sf LINESTRING is returned, it contains two variables (origins and destinations).
#> Reading layer `mtq' from data source `/tmp/RtmpfMP0Eo/temp_libpath527a79870990/cartography/gpkg/mtq.gpkg' using driver `GPKG' #> Simple feature collection with 34 features and 7 fields #> geometry type: MULTIPOLYGON #> dimension: XY #> bbox: xmin: 690574 ymin: 1592536 xmax: 735940.2 ymax: 1645660 #> projected CRS: WGS 84 / UTM zone 20Nmob <- read.csv(system.file("csv/mob.csv", package="cartography")) # Select links from Fort-de-France (97209)) mob_97209 <- mob[mob$i == 97209, ] # Create a link layer mob.sf <- getLinkLayer(x = mtq, df = mob_97209, dfid = c("i", "j")) # Plot the links1 plot(st_geometry(mtq), col = "grey")