Learn R Programming

dodgr (version 0.1.1)

weight_streetnet: weight_streetnet

Description

Weight (or re-weight) an sf-formatted OSM street network according to a named routino profile, selected from (foot, horse, wheelchair, bicycle, moped, motorcycle, motorcar, goods, hgv, psv).

Usage

weight_streetnet(sf_lines, wt_profile = "bicycle",
  type_col = "highway", id_col = "osm_id", keep_cols = NULL)

Arguments

sf_lines

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

wt_profile

Name of weighting profile, or vector of values with names corresponding to names in type_col

type_col

Specify column of the sf data.frame object which designates different types of highways 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 highway (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.

Value

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

Examples

Run this code
# NOT RUN {
# hampi is included with package as an 'osmdata' sf-formatted street network
net <- weight_streetnet (hampi)
class(net) # data.frame
dim(net) # 6096  11; 6096 streets
# os_roads_bristol is also included as an sf data.frame, but in a different
# format requiring identification of columns and specification of custom
# weighting scheme.
colnm <- "formOfWay"
wts <- c (0.1, 0.2, 0.8, 1)
names (wts) <- unique (os_roads_bristol [[colnm]])
net <- weight_streetnet (os_roads_bristol, wt_profile = wts,
                         type_col = colnm, id_col = "identifier")
dim (net) # 406 11; 406 streets
# }

Run the code above in your browser using DataLab