si_to_od: Prepare OD data frame

View source: R/si_to_od.R

si_to_odR Documentation

Prepare OD data frame

Description

Prepares an OD data frame that next could be used to estimate movement between origins and destinations with a spatial interaction model.

Usage

si_to_od(origins, destinations, max_dist = Inf, intrazonal = TRUE)

Arguments

origins

sf object representing origin locations/zones

destinations

sf object representing destination locations/zones

max_dist

Euclidean distance in meters (numeric). Only OD pairs that are this distance apart or less will be returned and therefore included in the SIM.

intrazonal

Include intrazonal OD pairs? Intrazonal OD pairs represent movement from one place in a zone to another place in the same zone. TRUE by default.

Details

In most origin-destination datasets the spatial entities that constitute origins (typically administrative zones) also represent destinations. In this 'unipartite' case origins and destinations should be passed the same object, an sf data frame representing administrative zones.

'Bipartite' datasets, by contrast, represent "spatial interaction systems where origins cannot act as destinations and vice versa" (Hasova et al. 2022).

a different sf object can be passed to the destinations argument.

Value

An sf data frame

Examples

library(sf)
origins = si_centroids[c(1, 2, 99), ]
destinations = origins
plot(origins$geometry)
odsf = si_to_od(origins, destinations, max_dist = 1200)
plot(odsf)
# note: result contains intrazonal flows represented by linestrings
# with a length of 0, e.g.:
sf::st_coordinates(odsf$geometry[1])
# With different destinations compared with origins
library(sf)
origins = si_centroids[c(2, 99), c(1, 6, 7)]
destinations = si_centroids[1, c(1, 6, 8)]
odsf = si_to_od(origins, destinations)
nrow(odsf) # no intrazonal flows
plot(odsf)

simodels documentation built on Sept. 1, 2022, 1:05 a.m.