Skip to contents

This function prepares the base network for generating a cohesive cycling network using NPT data. It integrates two different road network data sources within a specified target zone to produce a cohesive cycling network that considers specific road attributes.

Usage

cohesive_network_prep(
  base_network,
  influence_network,
  target_zone,
  crs = "EPSG:27700",
  key_attribute = "road_function",
  attribute_values = c("A Road", "B Road", "Minor Road"),
  use_stplanr = TRUE
)

Arguments

base_network

Base road network object from Open Road, class 'sf'.

influence_network

NPT road network object, which contains influence factors like all_fastest_bicycle_go_dutch, class 'sf'.

target_zone

Target zone, a polygon of a study area, such as a 3km radius around Edinburgh city centre, class 'sf'.

crs

Coordinate reference system to use, default is "EPSG:27700".

key_attribute

The attribute in the network data to filter by and influence the outcome.

attribute_values

Values of the key_attribute to retain in the network.

use_stplanr

Logical value indicating whether to use the stplanr package for merging

Value

A list containing two elements: a cohesive network and zone data, both class 'sf'.

Examples

library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
library(zonebuilder)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
library(tmaptools)

# Load demo data 
os_edinburgh_demo_3km = sf::st_set_crs(os_edinburgh_demo_3km, 27700)
NPT_demo_3km = sf::st_set_crs(NPT_demo_3km, 27700)
base_network = sf::st_transform(os_edinburgh_demo_3km, crs = 27700)
influence_network = sf::st_transform(NPT_demo_3km, crs = 27700)
target_zone = zonebuilder::zb_zone("Edinburgh", n_circles = 2) |>
               sf::st_transform(crs = "EPSG:27700")

# Prepare the cohesive network
OS_NPT_demo = cohesive_network_prep( base_network = base_network, 
                                influence_network = influence_network, 
                                target_zone = target_zone, 
                                key_attribute = "road_function", 
                                crs = "EPSG:27700", 
                                attribute_values = c("A Road", "B Road", "Minor Road"))
#> Requested number of segments (45185) does not match the number of segments returned by rsgeo (44530).
#> Warning: st_centroid assumes attributes are constant over geometries
#> Joining with `by = join_by(road_function)`
#> [1] "Finished preparing the network data"