Learn R Programming

stplanr (version 0.5.0)

od_dist: Quickly calculate Euclidean distances of od pairs

Description

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.

Usage

od_dist(flow, zones)

Arguments

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 cents(), the first column is geo_code. This corresponds to the first two columns of flow().

zones

A spatial object representing origins (and destinations if no separate destinations object is provided) of travel.

Details

Note: this function assumes that the zones or centroids in cents have a geographic (lat/lon) CRS.

See Also

Other od: dist_google(), od2line(), od2odf(), od_aggregate_from(), od_aggregate_to(), od_aggregate(), od_coords2line(), od_coords(), od_id, od_oneway(), od_radiation(), od_to_odmatrix(), odmatrix_to_od(), points2flow(), points2odf(), sp_aggregate()

Examples

Run this code
# NOT RUN {
data(flow)
data(cents)
od_dist(flow, cents)
# }

Run the code above in your browser using DataLab