Title: | Many-to-Many Multi-Modal Routing Aggregator |
---|---|
Description: | Many-to-many multi-modal routing aggregator, combining 'dodgr' and 'gtfsrouter' for complete routing through urban networks. |
Authors: | Mark Padgham [aut, cre] |
Maintainer: | Mark Padgham <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1.041 |
Built: | 2024-11-04 11:23:38 UTC |
Source: | https://github.com/UrbanAnalyst/m4ra |
This function runs of a directory which contain a number of silicate or
sc
-formatted street networks, generated with the dodgr_streetnet_sc
function of the dodgr package. The function uses a default cache
location specified by rappdirs::user_cache_dir()
. This location can be
over-ridden by specifying a local environment variable, "M4RA_CACHE_DIR".
m4ra_batch_weight_networks(net_dir, remove_these = NULL)
m4ra_batch_weight_networks(net_dir, remove_these = NULL)
net_dir |
Path of local directory containing 'sc'-format street networks. |
remove_these |
Names of any 'sc'-format files which should not be converted into weighted network form. |
A character vector of local locations of cached versions of the variously weighted network representations used in the various routing functions.
Other cache:
m4ra_cache_network()
,
m4ra_load_cached_network()
,
m4ra_network_hash()
,
m4ra_weight_networks()
Convert bicycle and automobile times into equivalent areas for a specified range of ratios of the two travel times.
m4ra_bike_car_ratio_areas(bike_car_dat, ratio_lims = 1 + 0:10/10)
m4ra_bike_car_ratio_areas(bike_car_dat, ratio_lims = 1 + 0:10/10)
bike_car_dat |
Result of m4ra_times_bike_car function for a
specified vector of |
ratio_lims |
Vector of ratio limits used to calculate areas within which ratio of bicycle to automobile times is less than specified limits. |
A data.frame
with one row for each from
point used to calculate
m4ra_times_bike_car, and columns including the OSM "id" value and
corresponding coordinates ("x" and "y"), followed by a series of columns, one
for each specified value of ratio_lims
, containing the areas in square
kilometres over which bicycle travel times are within the specified ratio of
car travel times.
Other analyses:
m4ra_times_bike_car()
,
m4ra_times_mm_car()
Save a weighted street network in both full and contracted forms to local cache.
m4ra_cache_network(graph, city)
m4ra_cache_network(graph, city)
graph |
The full network to be cached. |
city |
Name of city; used to name cached network files. |
Other cache:
m4ra_batch_weight_networks()
,
m4ra_load_cached_network()
,
m4ra_network_hash()
,
m4ra_weight_networks()
Calculate network distances to nearest 'n' points.
m4ra_dists_n_pts(graph, from = NULL, to = NULL, npts = 3L)
m4ra_dists_n_pts(graph, from = NULL, to = NULL, npts = 3L)
graph |
A |
from |
Vector of OpenStreetMap ID values from which route distances are to be calculated. |
to |
Vector of OpenStreetMap ID values to which nearest 'npts' distances are to be calculated. |
npts |
Number of points to which distances are to be calculated. |
Other main:
m4ra_gtfs_traveltimes()
,
m4ra_times_multi_mode()
,
m4ra_times_single_mode()
Construct a travel time matrix between all pairs of stops in a 'GTFS' feed.
m4ra_gtfs_traveltimes( gtfs, start_time_limits, day, from_stops = NULL, next_interval = TRUE, quiet = FALSE )
m4ra_gtfs_traveltimes( gtfs, start_time_limits, day, from_stops = NULL, next_interval = TRUE, quiet = FALSE )
gtfs |
A 'GTFS' feed extracted with the gtfsrouter function, 'extract_gtfs'. |
start_time_limits |
As for the 'gtfs_traveltimes' function of gtfsrouter, a vector of two values specifying the earliest and latest departure times from each station. |
day |
As for the 'gtfs_traveltimes' function of gtfsrouter, the day for which the matrix is to be calculated. |
from_stops |
If not |
next_interval |
If |
quiet |
If |
A list of two or three integer matrices:
"duration": The fastest travel times between all pairs of stops for the specified 'start_time_limits'; and
"ntransfers": The corresponding numbers of transfers.
(Only if 'next_interval = TRUE') "intervals": a matrix of intervals (in seconds) until the next fastest service after that corresponding to the times in the 'duration' item.
Other main:
m4ra_dists_n_pts()
,
m4ra_times_multi_mode()
,
m4ra_times_single_mode()
A sample street network from the township of Hampi, Karnataka, India. The
same as the dodgr::hampi
dataset, but in sc
rather than sf
format.
A silicate sc
representation of the street
network of Hampi.
Can be re-created with the following commands.
## Not run: hampi <- dodgr_streetnet_sc ("hampi india") ## End(Not run)
## Not run: hampi <- dodgr_streetnet_sc ("hampi india") ## End(Not run)
Load cached file for one city and mode
m4ra_load_cached_network( city = NULL, mode = "foot", contracted = TRUE, filename = NULL )
m4ra_load_cached_network( city = NULL, mode = "foot", contracted = TRUE, filename = NULL )
city |
City for which file is to be loaded. |
mode |
One of "foot", "bicycle", or "motorcar". |
contracted |
If |
filename |
Optional name of specific file to load. |
Previously cached, weighted streetnet for specified city and mode.
Other cache:
m4ra_batch_weight_networks()
,
m4ra_cache_network()
,
m4ra_network_hash()
,
m4ra_weight_networks()
This can be used to identify cached versions of a given network, in particular to determine whether or not weighted versions of a given network have been previously cached.
m4ra_network_hash(graph)
m4ra_network_hash(graph)
graph |
A silicate, "SC", format object containing network data used to generate weighted street networks. |
Single character value with unique hash of given network.
Other cache:
m4ra_batch_weight_networks()
,
m4ra_cache_network()
,
m4ra_load_cached_network()
,
m4ra_weight_networks()
Get data on parking availability and building volumes to estimate time penalties for automobile travel.
m4ra_parking( bb, city_name, mode = "motorcar", planet_file = NULL, dlim = 5000, k = 1000, quiet = FALSE )
m4ra_parking( bb, city_name, mode = "motorcar", planet_file = NULL, dlim = 5000, k = 1000, quiet = FALSE )
bb |
Bounding box of city for query to extract parking data. |
city_name |
Name of city used to name cached files. |
mode |
Mode of transport used to extract OSM node IDs at which to estimate relative parking availability (should generally be "motorcar"). |
planet_file |
Optional file path to local |
dlim |
Distance limit in metres out to which contributions of parking and buildings will be aggregated. |
k |
With of exponential function used to weight contributions with
distance, |
quiet |
If |
A data.frame
of the vertices of the (contracted) network, with
additional columns quantifying number of parking spaces associated with each
vertex, as well as the total volume of all surrounding buildings.
Other prep:
m4ra_prepare_data()
,
m4ra_times_to_gtfs_stops()
This is a meta-function that calls the following functions:
m4ra_weight_networks to generate several versions of the input street network weighted for different kinds of transport.
m4ra_gtfs_traveltimes to generate
It also identifies the closest GTFS stops to every network point. The
function stores several differently-weighted version of the street networks
in a local cache directory defined by the user_cache_dir()
function of the
rappdirs package, or by a local environment parameter,
"M4RA_CACHE_DIR", if set.
m4ra_prepare_data( net_sc = NULL, gtfs = NULL, city_name = NULL, planet_file = NULL, day = NULL, start_time_limits = NULL, final_mode = "foot", fast = FALSE, n_closest = 10L, batch_size = NULL, parking = FALSE, quiet = FALSE )
m4ra_prepare_data( net_sc = NULL, gtfs = NULL, city_name = NULL, planet_file = NULL, day = NULL, start_time_limits = NULL, final_mode = "foot", fast = FALSE, n_closest = 10L, batch_size = NULL, parking = FALSE, quiet = FALSE )
net_sc |
Local file path to a silicate, "SC", format object containing network data used to generate weighted street networks. |
gtfs |
Local file path to a gtfsrouter object saved via |
city_name |
Name of city used to name cached files. |
planet_file |
Optional file path to local |
day |
As for the 'gtfs_traveltimes' function of gtfsrouter, the day for which the matrix is to be calculated. |
start_time_limits |
As for the 'gtfs_traveltimes' function of gtfsrouter, a vector of two values specifying the earliest and latest departure times from each station. |
final_mode |
The mode of transport used for the final stage from GTFS stops to destination points. |
fast |
Values of |
n_closest |
Final travel times to each destination point are calculated by tracing back times to this number of closest GTFS stops. Lower values will result in faster calculation times, yet with potentially inaccurate results. |
batch_size |
Default routine calculates full travel time matrices between all pairs of stops. For very large GTFS feeds, this matrix may not fit into memory, in which case this parameter can be set to a positive integer value to sequentially calculate only portions of the full matrix, before final re-assembly into single result. |
parking |
If |
quiet |
If |
Other prep:
m4ra_parking()
,
m4ra_times_to_gtfs_stops()
This city expects weighted networks to have been generated with the
m4ra_batch_weight_networks function, and for corresponding networks to
exist in the m4ra
cache directory for the specified city.
m4ra_times_bike_car(city = NULL, from = NULL, walk_dists = TRUE)
m4ra_times_bike_car(city = NULL, from = NULL, walk_dists = TRUE)
city |
City for which values are to be calculated |
from |
Vector of OSM ID values of vertices from which ratios are to be
calculated. Typically obtained by loading one weighted network, and
sampling or extracting vertices from the function
|
walk_dists |
If |
A data.frame
of destination vertices, including Open Street Map ID
values, and longitude and latitude values, and four variables:
'car_t' Times in seconds to travel with automobile.
'bike_t' Times in seconds to travel by bicycles.
'walk_d' Equivalent walking distance in kilometres.
'ratio' Ratio of bicycle to automobile travel times.
Other analyses:
m4ra_bike_car_ratio_areas()
,
m4ra_times_mm_car()
## Not run: city <- "<city_name>" net <- m4ra_load_cached_network (city = city, mode = "foot") v <- m4ra_vertices (net, "<city_name>") from <- sample (v$id, size = 10) dat <- m4ra_bike_car_ratios (city = city, from = from) ## End(Not run)
## Not run: city <- "<city_name>" net <- m4ra_load_cached_network (city = city, mode = "foot") v <- m4ra_vertices (net, "<city_name>") from <- sample (v$id, size = 10) dat <- m4ra_bike_car_ratios (city = city, from = from) ## End(Not run)
This city expects weighted networks to have been generated with the
m4ra_batch_weight_networks function, and for corresponding networks to
exist in the m4ra
cache directory for the specified city.
m4ra_times_mm_car( net_sc = NULL, gtfs = NULL, city_name = NULL, day = NULL, start_time_limits = NULL, initial_mode = "foot", final_mode = "foot", from = NULL, duration_max = NULL, fast = FALSE, n_closest = 10L, walk_dists = TRUE, quiet = FALSE )
m4ra_times_mm_car( net_sc = NULL, gtfs = NULL, city_name = NULL, day = NULL, start_time_limits = NULL, initial_mode = "foot", final_mode = "foot", from = NULL, duration_max = NULL, fast = FALSE, n_closest = 10L, walk_dists = TRUE, quiet = FALSE )
net_sc |
Local file path to a silicate, "SC", format object containing network data used to generate weighted street networks. |
gtfs |
Local file path to a gtfsrouter object saved via |
city_name |
Name of city used to name cached files. |
day |
As for the 'gtfs_traveltimes' function of gtfsrouter, the day for which the matrix is to be calculated. |
start_time_limits |
As for the 'gtfs_traveltimes' function of gtfsrouter, a vector of two values specifying the earliest and latest departure times from each station. |
initial_mode |
Initial mode of transport from origin points towards public transport stop. |
final_mode |
The mode of transport used for the final stage from GTFS stops to destination points. |
from |
Vector of OSM ID values of vertices from which ratios are to be
calculated. Typically obtained by loading one weighted network, and
sampling or extracting vertices from the function
|
duration_max |
If specified, only calculate times from each point to the nearest GTFS stops out to specified maximal duration in seconds. Values may be provided if overall travel times are only of interest out to some defined range or maximal value. Specifying values for this parameter can can considerably reduce calculation times. |
fast |
Values of |
n_closest |
Final travel times to each destination point are calculated by tracing back times to this number of closest GTFS stops. Lower values will result in faster calculation times, yet with potentially inaccurate results. |
walk_dists |
If |
quiet |
If |
A data.frame
of destination vertices, including Open Street Map ID
values, and longitude and latitude values, and four variables:
'car_t' Times in seconds to travel with automobile.
'mm_t' Times in seconds for equivalent multi-modal transport.
'walk_d' Equivalent walking distance in kilometres.
'ratio' Ratio of multi-modal to automobile travel times.
Other analyses:
m4ra_bike_car_ratio_areas()
,
m4ra_times_bike_car()
## Not run: city <- "<city_name>" net <- m4ra_load_cached_network (city = city, mode = "foot") v <- m4ra_vertices (net, "<city_name>") from <- sample (v$id, size = 10) dat <- m4ra_mm_car_ratios (city = city, from = from) ## End(Not run)
## Not run: city <- "<city_name>" net <- m4ra_load_cached_network (city = city, mode = "foot") v <- m4ra_vertices (net, "<city_name>") from <- sample (v$id, size = 10) dat <- m4ra_mm_car_ratios (city = city, from = from) ## End(Not run)
Calculate matrix of pair-wise travel times between points using multiple modes of transport.
m4ra_times_multi_mode( net_sc = NULL, gtfs = NULL, city_name = NULL, day = NULL, start_time_limits = NULL, initial_mode = "foot", final_mode = "foot", from = NULL, duration_max = NULL, fast = FALSE, n_closest = 10L, quiet = FALSE )
m4ra_times_multi_mode( net_sc = NULL, gtfs = NULL, city_name = NULL, day = NULL, start_time_limits = NULL, initial_mode = "foot", final_mode = "foot", from = NULL, duration_max = NULL, fast = FALSE, n_closest = 10L, quiet = FALSE )
net_sc |
Local file path to a silicate, "SC", format object containing network data used to generate weighted street networks. |
gtfs |
Local file path to a gtfsrouter object saved via |
city_name |
Name of city used to name cached files. |
day |
As for the 'gtfs_traveltimes' function of gtfsrouter, the day for which the matrix is to be calculated. |
start_time_limits |
As for the 'gtfs_traveltimes' function of gtfsrouter, a vector of two values specifying the earliest and latest departure times from each station. |
initial_mode |
Initial mode of transport from origin points towards public transport stop. |
final_mode |
The mode of transport used for the final stage from GTFS stops to destination points. |
from |
List of OSM vertex IDs from which to calculate total multi-modal travel times. These must be vertices from the largest connected component of the contracted graph. |
duration_max |
If specified, only calculate times from each point to the nearest GTFS stops out to specified maximal duration in seconds. Values may be provided if overall travel times are only of interest out to some defined range or maximal value. Specifying values for this parameter can can considerably reduce calculation times. |
fast |
Values of |
n_closest |
Final travel times to each destination point are calculated by tracing back times to this number of closest GTFS stops. Lower values will result in faster calculation times, yet with potentially inaccurate results. |
quiet |
If |
Other main:
m4ra_dists_n_pts()
,
m4ra_gtfs_traveltimes()
,
m4ra_times_single_mode()
Calculate matrix of pair-wise travel times between points using a single mode of transport.
m4ra_times_single_mode(graph, from = NULL, to = NULL, path = NULL)
m4ra_times_single_mode(graph, from = NULL, to = NULL, path = NULL)
graph |
A |
from |
Vector or matrix of points from which route distances are to be calculated (see Notes) |
to |
Vector or matrix of points to which route distances are to be calculated (see Notes) |
path |
If specified, save individual travel time vectors for each 'from' point at that local directory.
|
Other main:
m4ra_dists_n_pts()
,
m4ra_gtfs_traveltimes()
,
m4ra_times_multi_mode()
net <- dodgr::weight_streetnet (m4ra_hampi, wt_profile = "foot") traveltimes <- m4ra_times_single_mode (net)
net <- dodgr::weight_streetnet (m4ra_hampi, wt_profile = "foot") traveltimes <- m4ra_times_single_mode (net)
Construct a travel time matrix to or from all stops in a 'GTFS' feed from or to to all points in a street network.
m4ra_times_to_gtfs_stops(graph, gtfs, city, from = NULL, graph_to_gtfs = TRUE)
m4ra_times_to_gtfs_stops(graph, gtfs, city, from = NULL, graph_to_gtfs = TRUE)
graph |
A |
gtfs |
A 'GTFS' feed extracted with the gtfsrouter function, 'extract_gtfs'. |
city |
Name of city being analysed; used to name and extract cache files. |
from |
Vector or matrix of points from which route distances are to
be calculated. If not given, times are calculated from all points in the
network. Only has any effect is |
graph_to_gtfs |
If |
An integer matrix of fastest travel times either between all 'gtfs' stops and all network points (for 'graph_to_gtfs = FALSE'), or the other way around (for 'graph_to_gtfs = TRUE').
Other prep:
m4ra_parking()
,
m4ra_prepare_data()
Extract vertices of graph, including spatial coordinates if included. Modified version of equivalent dodgr function that uses different hash comparisons. This version also does none of the checks implemented in the dodgr version, and assumes graphs remain unmodified throughout.
m4ra_vertices(graph, city)
m4ra_vertices(graph, city)
graph |
A flat table of graph edges. Must contain columns labelled
|
city |
Name of city; used to name cached network files. |
A data.frame
of vertices with unique numbers (n
).
Values of n
are 0-indexed
graph <- dodgr::weight_streetnet (dodgr::hampi) v <- m4ra_vertices (graph, "hampi")
graph <- dodgr::weight_streetnet (dodgr::hampi) v <- m4ra_vertices (graph, "hampi")
Uses a default cache location specified by rappdirs::user_cache_dir()
. This
location can be over-ridden by specifying a local environment variable,
"M4RA_CACHE_DIR". The "city" parameter is only used as a prefix for the
cached networks.
m4ra_weight_networks(net, city, quiet = TRUE)
m4ra_weight_networks(net, city, quiet = TRUE)
net |
A silicate, "SC", format object containing network data used to generate weighted street networks. |
city |
Name of city; only used to name cached network files. |
quiet |
If |
A character vector of local locations of cached versions of the variously weighted network representations used in the various routing functions.
Other cache:
m4ra_batch_weight_networks()
,
m4ra_cache_network()
,
m4ra_load_cached_network()
,
m4ra_network_hash()