Lines can be created from point aggregates (using summarise) or from -- to to create a 2-vertex line.

st_makeline(.geom, .to, ...)

Arguments

.geom

A geometry or a set of geometries of class sfc to be converted to line. The geometries are often aggregated using a dplyr::group_by() followed by adplyr::summarise().

.to

A point geometry to create pairwise lines.

...

Unused.

Value

A line (LINESTRING) of class sfc.

See also

Examples

library(dplyr)
#> #> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
library(tibble) x <- tibble(g = c("a", "a"), point = c(st_point(12, 21), st_point(21, 12))) x %>% summarise(line = st_makeline(point))
#> # A tibble: 1 x 1 #> line #> <LINESTRING> #> 1 (12 21, 21 12)