si_calculate | R Documentation |
Executes a spatial interaction model based on an OD data frame and user-specified function
si_calculate( od, fun, constraint_production, constraint_attraction, constraint_total, output_col = "interaction", ... )
od |
A data frame representing origin-destination data, e.g. as created by
|
fun |
A function that calculates the interaction (e.g. the number of trips) between each OD pair |
constraint_production |
Character representing column in |
constraint_attraction |
Character representing column in |
constraint_total |
Single number representing the total interaction. This argument, when set, ensures that the sum of the interaction calculated will equal the value given. |
output_col |
Character string containing the name of the new output
column. |
... |
Arguments passed to |
An sf data frame
od = si_to_od(si_zones, si_zones, max_dist = 4000) fun_dd = function(d = "distance_euclidean", beta = 0.3) exp(-beta * d / 1000) fun_dd(d = (1:5)*1000) od_dd = si_calculate(od, fun = fun_dd, d = distance_euclidean) plot(od$distance_euclidean, od_dd$interaction) fun = function(O, n, d, beta) O * n * exp(-beta * d / 1000) od_output = si_calculate(od, fun = fun, beta = 0.3, O = origin_all, n = destination_all, d = distance_euclidean) head(od_output) plot(od$distance_euclidean, od_output$interaction) od_pconst = si_calculate(od, fun = fun, beta = 0.3, O = origin_all, n = destination_all, d = distance_euclidean, constraint_production = origin_all) plot(od_pconst$distance_euclidean, od_pconst$interaction) plot(od_pconst["interaction"], logz = TRUE) od_dd = si_calculate(od, fun = fun_dd, d = distance_euclidean, output_col = "res") head(od_dd$res) od_dd = si_calculate(od, fun = fun_dd, d = distance_euclidean, constraint_total = 10) sum(od_dd$interaction)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.