
Convert geographic line objects to a data.frame with from and to coords
Source:R/od-funs.R
line2df.Rd
This function returns a data frame with fx and fy and tx and ty variables representing the beginning and end points of spatial line features respectively.
See also
Other lines:
angle_diff()
,
geo_toptail()
,
is_linepoint()
,
line2points()
,
line_bearing()
,
line_breakup()
,
line_midpoint()
,
line_sample()
,
line_segment_sf()
,
line_segment()
,
line_via()
,
mats2line()
,
n_sample_length()
,
n_vertices()
,
onewaygeo()
,
points2line()
,
toptail_buff()
,
toptailgs()
,
update_line_geometry()
Examples
data(flowlines)
line2df(flowlines[5, ]) # beginning and end of a single straight line
#> # A tibble: 1 × 5
#> object fx fy tx ty
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 -1.52 53.8 -1.52 53.8
line2df(flowlines) # on multiple lines
#> # A tibble: 49 × 5
#> object fx fy tx ty
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 -1.52 53.8 -1.52 53.8
#> 2 2 -1.52 53.8 -1.54 53.8
#> 3 3 -1.52 53.8 -1.55 53.8
#> 4 4 -1.52 53.8 -1.53 53.8
#> 5 5 -1.52 53.8 -1.52 53.8
#> 6 6 -1.52 53.8 -1.51 53.8
#> 7 7 -1.52 53.8 -1.52 53.8
#> 8 8 -1.54 53.8 -1.52 53.8
#> 9 9 -1.54 53.8 -1.54 53.8
#> 10 10 -1.54 53.8 -1.55 53.8
#> # … with 39 more rows
line2df(routes_fast[5:6, ]) # beginning and end of routes
#> # A tibble: 2 × 5
#> object fx fy tx ty
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 -1.52 53.8 -1.52 53.8
#> 2 2 -1.52 53.8 -1.51 53.8
line2df(routes_fast_sf[5:6, ]) # beginning and end of routes
#> # A tibble: 2 × 5
#> L1 fx fy tx ty
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 -1.52 53.8 -1.52 53.8
#> 2 2 -1.52 53.8 -1.51 53.8