evaluate_weight_spec: Specify edge weights in a spatial network

View source: R/weights.R

evaluate_weight_specR Documentation

Specify edge weights in a spatial network

Description

This function is not meant to be called directly, but used inside other functions that accept the specification of edge weights.

Usage

evaluate_weight_spec(data, spec)

Arguments

data

An object of class sfnetwork.

spec

The specification that defines how to compute or extract edge weights defused into a quosure. See Details for the different ways in which edge weights can be specified.

Details

There are multiple ways in which edge weights can be specified in sfnetworks. The specification can be formatted as follows:

  • As edge measure function: A spatial edge measure function computes a given measure for each edge, which will then be used as edge weights.

  • As column name: A column in the edges table of the network that contains the edge weights. Note that tidy evaluation is used and hence the column name should be unquoted.

  • As a numeric vector: This vector should be of the same length as the number of edges in the network, specifying for each edge what its weight is.

  • As dual weights: Dual weights can be specified by the dual_weights function. This allows to use a different set of weights for shortest paths computation and for reporting the total cost of those paths. Note that not every routing backend support dual-weighted routing.

If the weight specification is NULL or NA, this means that no edge weights are used. For shortest path computation, this means that the shortest path is simply the path with the fewest number of edges.

Value

A numeric vector of edge weights.

Note

For backward compatibility it is currently also still possible to format the specification as a quoted column name, but this may be removed in future versions.

Also note that many shortest path algorithms require edge weights to be positive.


luukvdmeer/sfnetworks documentation built on Nov. 21, 2024, 4:54 a.m.