Learn R Programming

od (version 0.5.1)

coords_to_od: Convert coordinates into a data frame of origins and destinations

Description

Takes geographic coordinates and converts them into a data frame representing the potential flows, or 'spatial interaction', between every combination of points.

Usage

coords_to_od(p, interzone_only = FALSE, ids_only = FALSE)

Value

A data frame object with O and D codes and origin and destination coordinates.

Arguments

p

A spatial points object or a matrix of coordinates representing points

interzone_only

Should the result only include interzonal OD pairs, in which the ID of the origin is different from the ID of the destination zone? FALSE by default

ids_only

Should a data frame with only 2 columns (origin and destination IDs) be returned? The default is FALSE, meaning the result should also contain the coordinates of the start and end points of each OD pair.

Examples

Run this code
p = sf::st_coordinates(od_data_centroids[1:3, ])
od = points_to_od(p)
(od = coords_to_od(p, interzone_only = TRUE))
l = odc_to_sf(od[3:6], d = od[1:2])
l$v = 1
(l_oneway = od_oneway(l))
plot(l_oneway)

Run the code above in your browser using DataLab