Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

weight_railway

weight_railway


Description

Weight (or re-weight) an sf-formatted OSM street network for routing along railways.

Usage

weight_railway(
  sf_lines,
  type_col = "railway",
  id_col = "osm_id",
  keep_cols = c("maxspeed"),
  excluded = c("abandoned", "disused", "proposed", "razed")
)

Arguments

sf_lines

A street network represented as sf LINESTRING objects, typically extracted with dodgr_streetnet

type_col

Specify column of the sf data.frame object which designates different types of railways to be used for weighting (default works with osmdata objects).

id_col

Specify column of the codesf data.frame object which provides unique identifiers for each railway (default works with osmdata objects).

keep_cols

Vectors of columns from sf_lines to be kept in the resultant dodgr network; vector can be either names or indices of desired columns.

excluded

Types of railways to exclude from routing.

Value

A data.frame of edges representing the rail network, along with a column of graph component numbers.

Note

Default railway weighting is by distance. Other weighting schemes, such as by maximum speed, can be implemented simply by modifying the d_weighted column returned by this function accordingly.

See Also

Examples

## Not run: 
# sample railway extraction with the 'osmdata' package
library (osmdata)
dat <- opq ("shinjuku") %>%
    add_osm_feature (key = "railway") %>%
    osmdata_sf (quiet = FALSE)
graph <- weight_railway (dat$osm_lines)

## End(Not run)

dodgr

Distances on Directed Graphs

v0.2.11
GPL-3
Authors
Mark Padgham [aut, cre], Andreas Petutschnig [aut], Robin Lovelace [ctb], Andrew Smith [ctb], Malcolm Morgan [ctb], Shane Saunders [cph] (Original author of included code for priority heaps)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.