weight_railway: Weight a network for routing along railways.

weight_railwayR Documentation

Weight a network for routing along railways.

Description

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

Usage

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

Arguments

x

A street network represented either 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

Other extraction: dodgr_streetnet_sc(), dodgr_streetnet(), weight_streetnet()

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 documentation built on June 7, 2023, 5:44 p.m.