Obtain a dodgr_streetnet object from OpenStreetMap data
Source:R/get-network-graph.R
oe_get_dodgrnetwork.RdThis function is a wrapper around oe_get_network() that returns a
dodgr_streetnet object. It performs simplification of the highway values,
filters by highway types and standardises the oneway attribute as well as
applying the implied oneway restriction based on the `junction“ tag values.
Usage
oe_get_dodgrnetwork(
place,
mode = c("cycling", "driving", "walking"),
...,
highway_filter = NULL,
quiet = FALSE
)Arguments
- place
Description of the geographical area that should be matched with a
.osm.pbffile. Can be either a length-1 character vector, ansf/sfc/bboxobject with any CRS, or a numeric vector of coordinates with length 2. In the last case, it is assumed that the EPSG code is 4326 specified as c(LON, LAT), while you can use any CRS withsf/sfc/bboxobjects. See Details and Examples inoe_match().- mode
A character string of length one denoting the desired mode of transport. Can be abbreviated. Currently
cycling(the default),drivingandwalkingare supported.- ...
additional parameters passed to
oe_get_network()anddodgr::weight_streetnet(), excludingxandid_colfor the latter.- highway_filter
Character vector of highway types to keep. Ignored if
NULL. Valid values are: "busway", "cycleway", "footway", "living_street", "motorway", "path", "pedestrian", "primary", "residential", "rest_area", "service", "services", "steps", "tertiary", "track", "trunk" and "unclassified".- quiet
Boolean. If
FALSE, the function prints informative messages. Starting fromsfversion 0.9.6, ifquietis equal toFALSE, then vectortranslate operations will display a progress bar.
Examples
# Copy the ITS file to tempdir() to make sure that the examples do not
# require internet connection. You can skip the next 4 lines (and start
# directly with oe_get_keys) when running the examples locally.
its_pbf = file.path(tempdir(), "test_its-example.osm.pbf")
file.copy(
from = system.file("its-example.osm.pbf", package = "osmextract"),
to = its_pbf,
overwrite = TRUE
)
#> [1] TRUE
if (requireNamespace("dodgr", quietly = TRUE)) {
graph_bike <- oe_get_dodgrnetwork(
place = "ITS Leeds",
mode = "cycling",
wt_profile = "bicycle",
left_side = TRUE,
download_directory = tempdir(),
quiet = TRUE
)
head(graph_bike)
highway_filter = c(
"motorway",
"trunk",
"primary",
"secondary",
"tertiary",
"unclassified",
"residential"
)
graph_car <- oe_get_dodgrnetwork(
place = "ITS Leeds",
mode = "driving",
wt_profile = "motorcar",
left_side = TRUE,
highway_filter = highway_filter,
download_directory = tempdir(),
quiet = TRUE
)
head(graph_car)
class(graph_car)
}
#> [1] "dodgr_streetnet" "data.frame"