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).

weight_streetnet(x, wt_profile = "bicycle", type_col = "highway",
  id_col = "osm_id", keep_cols = NULL, times = FALSE,
  left_side = FALSE)

# S3 method for default
weight_streetnet(x, wt_profile = "bicycle",
  type_col = "highway", id_col = "osm_id", keep_cols = NULL,
  times = FALSE, left_side = FALSE)

# S3 method for sf
weight_streetnet(x, wt_profile = "bicycle",
  type_col = "highway", id_col = "osm_id", keep_cols = NULL,
  times = FALSE, left_side = FALSE)

# S3 method for sc
weight_streetnet(x, wt_profile = "bicycle",
  type_col = "highway", id_col = "osm_id", keep_cols = NULL,
  times = FALSE, left_side = FALSE)

Arguments

x

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 (see Details)

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.

times

Weight network for routing according to times rather than distances (see Note).

left_side

Does traffic travel on the left side of the road (TRUE) or the right side (FALSE)?

Value

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

Note

Names for the wt_profile parameter are taken from weighting_profiles, which is a data.frame of weights for different modes of transport. Current modes included there are "bicycle", "foot", "goods", "hgv", "horse", "moped", "motorcar", "motorcycle", "psv", and "wheelchair". Railway routing can be implemented with the separate function weight_railway.

Graphs weighted for time-based routing (that is, with times = TRUE) are fundementally different from the default for distance-based routing. Distances in the latter case are shortest distances weighted for the particular mode of transport specified in wt_profile. Time-based routing requires additional calcualtion of turn angles (along with differential speeds along different kinds of ways), represented by additional edges describing turns of different angles through each intersetion. The result of weight_streetnet(..., times = TRUE) should thus only be used to submit to the dodgr_times function, and not for any other dodgr functions nor forms of network analysis.

Examples

# hampi is included with package as an 'osmdata' sf-formatted street network net <- weight_streetnet (hampi) class(net) # data.frame
#> [1] "data.frame" "dodgr_streetnet"
dim(net) # 6096 11; 6096 streets
#> [1] 5845 13
# 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
#> [1] 812 12
# An example for a generic (non-OSM) highway, represented as the # `routes_fast` object of the \pkg{stplanr} package, which is a # SpatialLinesDataFrame.
# NOT RUN { library (stplanr) # merge all of the 'routes_fast' lines into a single network r <- overline (routes_fast, attrib = "length", buff_dist = 1) r <- sf::st_as_sf (r) # We need to specify both a `type` and `id` column for the # \link{weight_streetnet} function. r$type <- 1 r$id <- seq (nrow (r)) graph <- weight_streetnet (r, type_col = "type", id_col = "id", wt_profile = 1) # }