setDistCosts: Set costs associated to edges based on geographic distances

setDistCostsR Documentation

Set costs associated to edges based on geographic distances

Description

The function setDistCosts sets the costs of a gGraph object using the geographic distance. The cost associated to an edge is defined as the great circle distance between the two nodes of this edge. setDistCosts actually relies on rdist.earth of the fields package.

Usage

setDistCosts(x, ...)

## S4 method for signature 'gGraph'
setDistCosts(x, ...)

Arguments

x

a valid gGraph.

...

other arguments passed to other methods (currently unused).

Details

The notion of 'costs' in the context of gGraph objects is identical to the concept of 'weights' in graph (and thus graphNEL) objects. The larger it is for an edge, the less connectivity there is between the couple of concerned nodes.

Value

For the gGraph method, a gGraph object with appropriate weights. Note that former weights will be removed from the object.

Functions

  • setDistCosts(gGraph): Method for gGraph object

See Also

The getCosts accessor, returning costs of the edges of a gGraph object in different ways.

Examples


if (require(fields)) {
  ## load data
  plot(rawgraph.10k, reset = TRUE)
  geo.zoomin(list(x = c(110, 150), y = c(-10, -40)))
  plotEdges(rawgraph.10k)

  ## compute costs
  x <- rawgraph.10k[isInArea(rawgraph.10k)]
  x <- setDistCosts(x)

  ## replot edges
  plotEdges(x) # no big differences can be seen
  head(getCosts(x))
}


thibautjombart/geograph documentation built on Jan. 27, 2024, 10 p.m.