| Title: | Model of pedestrian flows throughout New York City |
|---|---|
| Description: | Model of pedestrian flows throughout New York City. |
| Authors: | Mark Padgham [aut, cre] (ORCID: <https://orcid.org/0000-0003-2172-5265>) |
| Maintainer: | Mark Padgham <[email protected]> |
| License: | GPL-3 |
| Version: | 0.0.0.017 |
| Built: | 2026-06-02 18:59:26 UTC |
| Source: | https://github.com/ATFutures/nyped |
Build final pedestrian model
add_layer_to_model(data_dir, dat = NULL, sig = 0.01, pos_only = TRUE)add_layer_to_model(data_dir, dat = NULL, sig = 0.01, pos_only = TRUE)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
dat |
Output of previous run of 'add_layer_to_model' |
sig |
Desired level of statistical significance |
pos_only |
Only include layers that make a positive contribution to final model (and so exclude any layers that are negatively correlated)? |
Batch-convert all flow layers to equivalent values matched to pedestrian counting stations via the fit_flows_to_ped function.
all_flows_to_ped(data_dir)all_flows_to_ped(data_dir)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
build_ped_model
build_ped_model(data_dir, sig_build = 0.05, sig_model = 0.01, pos_only = FALSE)build_ped_model(data_dir, sig_build = 0.05, sig_model = 0.01, pos_only = FALSE)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
sig_build |
Significance threshold for initial constructing of model through adding successive layers |
sig_model |
Desired significance of final model |
pos_only |
Only include layers that make a positive contribution to final model (and so exclude any layers that are negatively correlated)? |
The final model reduced to only layers with significance below 'sig_model'.
This function can take several minutes to run, and saves the final model in two forms, both stored in 'data_dir': the initial, full model with all layers, called 'ped-model-full.Rds', and the final model with only layers with significance below 'sig_model', called 'ped-model-final.Rds'.
Calculate relative scales of contributions of each flow layer to final model of pedestrian flows generated by successive calls to build_ped_model.
calc_layer_scales(data_dir, model = "final")calc_layer_scales(data_dir, model = "final")
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
model |
Default "final" uses the final model of layers reduced only to those with significance less than 'sig_model' in build_ped_model, otherwise the full model with potentially less significant layers is used. |
A ‘data.frame' with six columns of (1) ’model' with the layer names; (2) 'estimates' holding the estimates for each layer from the multiple linear regression model; (3) 'full_rel' with the relative scaling coefficient for the contribution of each layer weighted by the full flow layers; (4) 'ped_rel' with equivalent values weighted by values at pedestrian count stations only; (5) 'full_abs' with the absolute scaling coefficient for each layer weighted by full flow layers; and (6) 'ped_abs' with equivalent values weighted by values at pedestrian count stations only.
Convert edge-based centrality measures to equivalent point-based.
centrality_edge_to_point(data_dir, save = FALSE)centrality_edge_to_point(data_dir, save = FALSE)
data_dir |
The data directory |
save |
If 'TRUE', save resultant vertex-based centrality measures in 'data_dir'. |
Equivalent point- or vertex-based measures of centrality
Get OpenStreetMap calibration data.
clb_osm_data(city, prefix, data_dir = NULL)clb_osm_data(city, prefix, data_dir = NULL)
city |
City or bounding box for which data are to be extracted |
prefix |
Prefix to prepend to file names to identify city |
data_dir |
Directory in which data are to be stored |
List of OSM data for highways, green spaces, and activity attractors.
Cut the New York City street network into portions surrounding each pedestrian counting point.
cut_network_to_pts(net, k = 1000, p = NULL, data_dir)cut_network_to_pts(net, k = 1000, p = NULL, data_dir)
net |
Weighted street network; loaded from 'data_dir' if not provided |
k |
Exponential decay parameter to be used in spatial interaction models. This deterines the radius at which to cut the network. |
p |
Pedestrian counts including OSM IDs of nearest points, as returned from ped_osm_id. |
data_dir |
The directory in which data are to be, or have previously been, downloaded - only needed if 'p' is not provided. |
Fit network centrality to pedestrian counts, by aggregating across a variable number of edges ('n') nearest to each pedestrian count station.
fit_cen_to_ped(data_dir)fit_cen_to_ped(data_dir)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
A list containing vectors of 'k' and 'n' values, and a matrix of 30x20 = 600 columns, one for each combination of 30 'k'- and 20 'n'-values.
Fit one network with multiple flow columns (from multiple k-values) to pedestrian counts, by aggregating each flow column across a variable number of edges ('n') nearest to each pedestrian count station.
fit_flows_to_ped(net_f, data_dir)fit_flows_to_ped(net_f, data_dir)
net_f |
A network with flow columns, obtained from 'get_layer' |
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
A list containing vectors of 'k' and 'n' values, and a matrix of 30x20 = 600 columns, one for each combination of 30 'k'- and 20 'n'-values.
Get points of trip attraction
get_attractors(bbox, quiet = FALSE)get_attractors(bbox, quiet = FALSE)
bbox |
Bounding box for which green space polygons are to be extracted. |
quiet |
If 'TRUE', dump progress information to screen. |
Get polygons of all green areas for a given location
get_green_space(bbox, quiet = FALSE)get_green_space(bbox, quiet = FALSE)
bbox |
Bounding box for which green space polygons are to be extracted. |
quiet |
If 'TRUE', dump progress information to screen. |
An sf-format 'data.frame' of polygons representing all green areas.
Append network with flow columns between nominated places
get_layer(net, from = "subway", to = "disperse", data_dir)get_layer(net, from = "subway", to = "disperse", data_dir)
net |
Weighted street network; loaded from 'data_dir' if not provided |
from |
Category of origins for pedestrian flows; one of "subway" or "residential" |
to |
Category of destinations for pedestrian flows; one of "residential", "education", "entertainment", "healthcare", "sustenance", "transportation", or "disperse" for a general dispersal model. |
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
Get OpenStreetMap data for New York City
nyosm_data(data_dir)nyosm_data(data_dir)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
A list of three items: (1) the street network; (2) building polygons; and (3) green space polygons
Download, clean, and return New York City pedestrian count data
nyped_data(data_dir = tempdir(), quiet = FALSE)nyped_data(data_dir = tempdir(), quiet = FALSE)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
quiet |
If 'FALSE', display progress information on screen |
A 'data.frame' of pedestrian counts, and geographical coordinates, with counts for weekdays, weekends, and "week" derived as a weighted combintaion of both.
dat <- nyped_data () # library (mapview) # mapview (dat, cex = "week", zcol = "week")dat <- nyped_data () # library (mapview) # mapview (dat, cex = "week", zcol = "week")
Get population density data for New York City
nypopdens(data_dir = tempdir())nypopdens(data_dir = tempdir())
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
Population density data
Download, clean, and join New York City subway station counts and coordinates
nysubway_data(quiet = FALSE, sub_exits = TRUE)nysubway_data(quiet = FALSE, sub_exits = TRUE)
quiet |
If 'FALSE', display progress information on screen |
sub_exits |
Calculate layer from subway exits ('TRUE'), or just from single points denoting subway stations ('FALSE')? |
A 'data.frame' of subway names, annual counts, and geographical coordinates.
dat <- nysubway_data () # library (mapview) # mapview (dat, cex = "count2018", zcol = "count2018")dat <- nysubway_data () # library (mapview) # mapview (dat, cex = "count2018", zcol = "count2018")
Convert a final model of pedestrian flows at the pedestrian count stations back into a model of full flows along each edge of the entire network
ped_model_to_full_flow(mod, data_dir)ped_model_to_full_flow(mod, data_dir)
mod |
A final pedestrian model produced by successive calls to build_ped_model |
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
Get OSM IDs nearest to pedestrian count points
ped_osm_id(data_dir, net = NULL, quiet = FALSE)ped_osm_id(data_dir, net = NULL, quiet = FALSE)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
net |
Weighted street network; loaded from 'data_dir' if not provided |
quiet |
If 'FALSE', display progress information on screen |
A 'data.frame' of pedestrian counts, associated spatial coordinates, and OSM IDs of nearest points on network
Plot the population density of New York City via 'mapdeck'
plot_ny_popdens(data_dir)plot_ny_popdens(data_dir)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
This function presumes that a mapdeck token exists as an environmental variable with a name that includes "mapbox"
Plot pedestrian count data for New York City
plot_ped_counts(type = "week")plot_ped_counts(type = "week")
type |
One of "weekday", "weekend", or "week" (aggregate of both) |
Plot subway entrace/exit count data for New York City
plot_subway_counts(year = 2018L)plot_subway_counts(year = 2018L)
year |
Year in [2013:2018] |
Get OSM IDs nearest to subway count points
subway_osm_id(data_dir, net = NULL, sub_exits = TRUE, quiet = FALSE)subway_osm_id(data_dir, net = NULL, sub_exits = TRUE, quiet = FALSE)
data_dir |
The directory in which data are to be, or have previously been, downloaded. |
net |
Weighted street network; loaded from 'data_dir' if not provided |
sub_exits |
Calculate layer from subway exits ('TRUE'), or just from single points denoting subway stations ('FALSE')? |
quiet |
If 'FALSE', display progress information on screen |
A 'data.frame' of pedestrian counts, associated spatial coordinates, and OSM IDs of nearest points on network