Skip to contents

This function assigns events to the nearest link in a segmented road network.

Usage

assign_event_to_link(segmented_network, events)

Arguments

segmented_network

A segmented_network object, which contains a list of segmented links and nodes, representing the segmented road network.

events

A sf object representing events, such as traffic accidents, with location information.

Value

A segmented_network object with events assigned to links. Each link will have a count attribute indicating the number of events assigned to it.

Examples

# Create the segmented road network
road_network <- create_road_network(sample_roads)
segmented_network <- create_segmented_network(road_network)

# Assign accidents to the nearest link
segmented_network <- assign_event_to_link(
  segmented_network,
  sample_accidents
)

# Plot the segmented road network with events
plot(segmented_network, mode = "event")