Calculates the number of opportunities accessible under a given specified travel cost cutoff.
This function is generic over any kind of numeric travel cost, such as distance, time and money.
Usage
cumulative_cutoff(
travel_matrix,
land_use_data,
opportunity,
travel_cost,
cutoff,
group_by = character(0),
active = TRUE,
fill_missing_ids = TRUE
)
Arguments
- travel_matrix
A data frame. The travel matrix describing the costs (i.e. travel time, distance, monetary cost, etc.) between the origins and destinations in the study area. Must contain the columns
from_id
,to_id
and any others specified intravel_cost
.- land_use_data
A data frame. The distribution of opportunities within the study area cells. Must contain the columns
id
and any others specified inopportunity
.- opportunity
A string. The name of the column in
land_use_data
with the number of opportunities/resources/services to be considered when calculating accessibility levels.- travel_cost
A
character
vector. The name of the columns intravel_matrix
with the travel costs between origins and destinations to be considered in the calculation.- cutoff
Either a
numeric
vector or a list ofnumeric
vectors, one for each cost specified intravel_cost
. The travel cost cutoffs to consider when calculating accessibility levels. If a list, the function finds every single possible cutoff combination and use them to calculate accessibility (e.g. if one specifies that travel time cutoffs should be 30 and 60 minutes and that monetary cost cutoffs should be 5 and 10 dollars, the output includes accessibility estimates limited at 30 min & 5 dollars, 30 min & 10 dollars, 60 min & 5 dollars and 60 min & 10 dollars). In these cases, cost constraints are considered simultaneously - i.e. only trips that take 30 minutes or less AND 5 dollars or less to be completed, for example, are included in the accessibility output. The cutoff parameter is not included in the final output if the input includes only a single cutoff for a single travel cost.- group_by
A
character
vector. When notcharacter(0)
(the default), indicates thetravel_matrix
columns that should be used to group the accessibility estimates by. For example, iftravel_matrix
includes a departure time column, that specifies the departure time of each entry in the data frame, passing"departure_time"
to this parameter results in accessibility estimates grouped by origin and by departure time.- active
A logical. Whether to calculate active accessibility (the of opportunities that can be reached from a given origin, the default) or passive accessibility (by how many people each destination can be reached).
- fill_missing_ids
A
logical
. Calculating cumulative accessibility may result in missing ids if the they cannot reach any of the destinations within the specified travel cost cutoff. For example, using a travel time cutoff of 20 minutes, when estimating the accessibility of originA
that can only reach destinations with more than 40 minutes results in idA
not being included in the output. WhenTRUE
(the default), the function identifies which origins would be left out and fills their respective accessibility values with 0, which incurs in a performance penalty.
Value
A data frame containing the accessibility estimates for each
origin/destination (depending if active
is TRUE
or FALSE
) in the
travel matrix.
See also
Other cumulative access:
cumulative_interval()
Examples
if (FALSE) { # identical(tolower(Sys.getenv("NOT_CRAN")), "true")
data_dir <- system.file("extdata", package = "accessibility")
travel_matrix <- readRDS(file.path(data_dir, "travel_matrix.rds"))
land_use_data <- readRDS(file.path(data_dir, "land_use_data.rds"))
# active accessibility: number of schools accessible from each origin
df <- cumulative_cutoff(
travel_matrix = travel_matrix,
land_use_data = land_use_data,
cutoff = 30,
opportunity = "schools",
travel_cost = "travel_time"
)
head(df)
df <- cumulative_cutoff(
travel_matrix = travel_matrix,
land_use_data = land_use_data,
cutoff = c(30, 60),
opportunity = "schools",
travel_cost = "travel_time"
)
head(df)
# passive accessibility: number of people that can reach each destination
df <- cumulative_cutoff(
travel_matrix = travel_matrix,
land_use_data = land_use_data,
cutoff = 30,
opportunity = "population",
travel_cost = "travel_time",
active = FALSE
)
head(df)
# using multiple travel costs
pareto_frontier <- readRDS(file.path(data_dir, "pareto_frontier.rds"))
df <- cumulative_cutoff(
pareto_frontier,
land_use_data = land_use_data,
opportunity = "jobs",
travel_cost = c("travel_time", "monetary_cost"),
cutoff = list(c(20, 30), c(0, 5, 10))
)
head(df)
}