route_risk: Calculating the risk per route

View source: R/risky_routes.R

route_riskR Documentation

Calculating the risk per route

Description

Calculating the risk per route

Usage

route_risk(routes, crash_data, radius = 5)

Arguments

routes

The routes travelled by the commuter with the associated weight or number of travellers. This is an sf dataframe where the geometry a sfc LINESTRING.

crash_data

An sf dataframe containing the geometry of the crash sites. Geometry requires a projected coordinate system.

radius

The distance between the route and crash point. The default is 10. The unit of measure is dependent on input sf dataframes CRS.

Value

returns an sf dataframe with linestring geometry from routes input and a new column, crash_within_5m, the total number of crash sites encountered by each route.

Examples

## Not run: 

data(jtw_driving_akl)
data(cas_data_akl_2018_proj)

## initialising the router for New Zealand
ghroute::router(osm.file = "osm/new-zealand-latest.osm.pbf")

##getting the routes
jtw_akl_routes <- get_routes(as.matrix(jtw_driving_akl[c("start_lat",
"start_lon", "end_lat", "end_lon")]), crs = 2193)

route_riskiness_d_proj <- route_risk(jtw_akl_routes, cas_data_akl_2018_proj)


## End(Not run)



kathycong/motroadsafety documentation built on June 23, 2022, 8:56 a.m.