evaluate_weight_spec | R Documentation |
This function is not meant to be called directly, but used inside other functions that accept the specification of edge weights.
evaluate_weight_spec(data, spec)
data |
An object of class |
spec |
The specification that defines how to compute or extract edge
weights defused into a |
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.
A numeric vector of edge weights.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.