This function takes a wide range of input data types (spatial lines, points or text strings) and returns a matrix of coordinates representing origin (fx, fy) and destination (tx, ty) points.
See also
Other od:
od2line()
,
od2odf()
,
od_aggregate_from()
,
od_aggregate_to()
,
od_coords2line()
,
od_id
,
od_id_order()
,
od_oneway()
,
od_to_odmatrix()
,
odmatrix_to_od()
,
points2flow()
,
points2odf()
Examples
od_coords(from = c(0, 52), to = c(1, 53)) # lon/lat coordinates
#> fx fy tx ty
#> [1,] 0 52 1 53
od_coords(cents_sf[1:3, ], cents_sf[2:4, ]) # sf points
#> fx fy tx ty
#> [1,] -1.546463 53.80952 -1.511861 53.81161
#> [2,] -1.511861 53.81161 -1.524205 53.80410
#> [3,] -1.524205 53.80410 -1.550806 53.82442
# od_coords("Hereford", "Leeds") # geocode locations
od_coords(flowlines_sf[1:3, ])
#> fx fy tx ty
#> [1,] -1.516734 53.82887 -1.535617 53.82847
#> [2,] -1.516734 53.82887 -1.550807 53.82442
#> [3,] -1.516734 53.82887 -1.530712 53.81756