It is common to want to know the Euclidean distance between origins and destinations
in OD data. You can calculate this by first converting OD data to SpatialLines data,
e.g. with od2line(). However this can be slow and overkill if you just
want to know the distance. This function is a few orders of magnitude faster.
od_dist(flow, zones)
| flow | A data frame representing origin-destination data.
The first two columns of this data frame should correspond
to the first column of the data in the zones. Thus in |
|---|---|
| zones | A spatial object representing origins (and destinations if no separate destinations object is provided) of travel. |
Note: this function assumes that the zones or centroids in cents have a geographic
(lat/lon) CRS.
Other od:
dist_google(),
od2line(),
od2odf(),
od_aggregate_from(),
od_aggregate_to(),
od_coords2line(),
od_coords(),
od_id,
od_oneway(),
od_to_odmatrix(),
odmatrix_to_od(),
points2flow(),
points2odf()
#> [1] 0.0000 1241.4409 2292.9691 1559.1826 1465.7100 1948.2115 2801.3756 #> [8] 1241.4409 0.0000 1095.2609 1257.2449 1771.5987 2441.3717 2815.0957 #> [15] 2292.9691 1095.2609 0.0000 1525.5896 2281.1352 2929.7882 2859.0798 #> [22] 1559.1826 1257.2449 1525.5896 0.0000 774.0731 1404.6273 1557.9761 #> [29] 1465.7100 1771.5987 2281.1352 774.0731 0.0000 676.1596 1341.2071 #> [36] 1948.2115 2441.3717 2929.7882 1404.6273 676.1596 0.0000 1165.2059 #> [43] 2801.3756 2815.0957 2859.0798 1557.9761 1341.2071 1165.2059 0.0000