od_coordinates: Create matrices representing origin-destination coordinates

View source: R/od-funs.R

od_coordinatesR Documentation

Create matrices representing origin-destination coordinates

Description

This function takes an 'od data frame' with the first two columns matching IDs of spatial objects, and matches them with objects representing origins and destinations in wide range of input data types (spatial lines, points or text strings). It returns a data frame of coordinates representing movement between all origin (ox, oy) and destination (dx, dy) points.

Usage

od_coordinates(x, p = NULL, pd = NULL, silent = TRUE, sfnames = FALSE)

Arguments

x

A data frame in which the first two columns are codes representing points/zones of origin and destination

p

Points representing origins and destinations

pd

Points representing destinations, if different from origin points

silent

Hide messages? FALSE by default.

sfnames

Should output column names be compatible with the sf package?

Details

See points_to_od() for a function that creates an 'od data frame' from a set (or two sets) of points.

Value

A data frame with origin and destination coordinates

Examples

x = od_data_df
p = od_data_centroids
res = od_coordinates(x, p)[1:2, ]
class(res)
res
od_coordinates(x, p, sfnames = TRUE)[1:2, ]
od_coordinates(x, p, silent = FALSE)[1:2, ]
od_coordinates(x, p)
x = od_data_df2[1:3, ]
p = od_data_centroids2
pd = od_data_destinations
od_coordinates(x, p, pd)

ITSLeeds/od documentation built on Oct. 11, 2024, 9:21 a.m.