Terraflux Terraflux
Download

Grid distances

17 operators. Inputs marked required must be connected or given; the others have defaults.

cost.acc_cost#

The accumulated cost from the nearest origin over a transition of conductances (gdistance's accCost through landschaft's C++): inf where no origin can be reached.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
originsrequiredanypoints (vector features) or a mask (its cells not 0)
OutputTypeWhat it is
mapmapthe accumulated cost

cost.areas#

Area transitions of a map of categories (gdistance's transition(x, "areas")): one per category k (1, 2, ... n: the value k), 1 between two cells of it, 0.5 between one of it and another cell, as weights of cost.path_inc.

InputTypeWhat it is
maprequiredmapcategories 1..n
OutputTypeWhat it is
transitionsstacka set of transitions
SettingTypeWhat it is
directionsinteger4, 8 (default) or 16

cost.barriers#

Barrier transitions of a map (gdistance's transition(x, "barriers")): each marks with 1 (as resistances) the connections that cross a boundary, as weights of cost.path_inc. With breaks: one per break, between a cell below it and one above; else the values are categories: one per pair of categories in gdistance's order ((2, 1), (3, 1), ..., (3, 2), ...), two (one per way) when not symmetric.

InputTypeWhat it is
maprequiredmapthe values
OutputTypeWhat it is
transitionsstacka set of transitions
SettingTypeWhat it is
directionsinteger4, 8 (default) or 16
breaksanybreaks of continuous values: [b1, b2, ...]
symmetricboolcategories: both ways in one (default true)

cost.combine#

Two transitions on the same grid added, subtracted or multiplied connection by connection (gdistance's Arith on TransitionLayers), in their common layout: the most directions, symmetric when both are.

InputTypeWhat it is
arequiredstacka transition
brequiredstackanother, on the same grid
OutputTypeWhat it is
transitionstackthe result
SettingTypeWhat it is
operationtextsum (default), difference or product

cost.commute_distance#

The expected commute distances of a random walk between points (gdistance's commuteDistance through landschaft's C++): how long a walk that moves to a neighbour with a probability proportional to the conductance takes, on average, to reach the other point and come back; the effective resistance times the graph's volume. inf between separate parts of the graph, no value for points outside it.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
pointsrequiredvectorthe points
OutputTypeWhat it is
tabletablea row per point: its number, then the distance to each point

cost.distance#

The least costs between points over a transition of conductances (gdistance's costDistance through landschaft's C++): from every point to every other (a symmetric matrix when the transition is), or to every point of another set; no value for points outside the grid.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
fromrequiredvectorthe points
tovectorother points (default: the same)
OutputTypeWhat it is
tabletablea row per point from: its number, then the cost to each point

cost.geo_correction#

A transition corrected for the distances between cells' centres (gdistance's geoCorrection through landschaft's C++): divided by them (type c, least-cost distances), or also by the cells' widths across the connection (type r, random walks); great-circle distances on longitude/latitude grids.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
OutputTypeWhat it is
transitionstackthe corrected transition
SettingTypeWhat it is
typetextc (default) or r
scaleboolscaled by the distance between the grid's first cells

cost.mahal#

The Mahalanobis transition of a stack of maps (gdistance's transition(brick, "mahal")): for every pair of neighbouring cells with values in all maps, the Mahalanobis distance d between their values (with the inverse of the maps' covariance); the connection is mean(d) / (d + mean(d)). R's cov, solve, %*% and mean, to the bit.

InputTypeWhat it is
mapsrequiredstacktwo or more maps
OutputTypeWhat it is
transitionstacka symmetric transition
SettingTypeWhat it is
directionsinteger4, 8 (default) or 16

cost.math#

A function of a transition's values on its connections (landschaft's Transition.map, R's maths to the bit): sqrt, exp, log, pow (to a value), multiply (by a value) or divide (a value by each, the reciprocal for 1); NaN results leave the connection out.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
OutputTypeWhat it is
transitionstackthe result
SettingTypeWhat it is
functionrequiredtextsqrt, exp, log, pow, multiply or divide
valuenumberthe power, the factor or the dividend (default 1)

cost.normalize#

A transition normalised (gdistance's normalize): each row divided by its sum (the probabilities of a random walk; asymmetric), each column, or by the square roots of the row and column sums (stays symmetric).

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
OutputTypeWhat it is
transitionstackthe normalised transition
SettingTypeWhat it is
methodtextrow (default), col or symm

cost.passage#

The passages of a random walk from origins to goals through every cell (gdistance's passage through landschaft's C++). Without theta: the net number of times a random walk passes through each cell, the current of a unit current from the origins to the goals (a symmetric transition; 1 at the origins and goals, 0 off the graph). With theta (0 to 20): randomised shortest paths (Saerens et al. 2009), that prefer cheap routes more as theta grows; no value off the graph.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
originsrequiredanypoints (vector features) or a mask (its cells not 0)
goalsrequiredanypoints (vector features) or a mask (its cells not 0)
OutputTypeWhat it is
mapmapthe passages
SettingTypeWhat it is
thetanumberrandomised shortest paths, 0 to 20 (default: none)
total_nettextwith theta: net (default) or total passages
gdistance_compatboolwithout theta: gdistance's potential of the grounded cell (default true); false: the exact currents

cost.path_inc#

The overlap and non-overlap of the routes from a common origin to each location (gdistance's pathInc through landschaft's C++, van Etten & Hijmans 2010): the flow of a random walk (or, with theta, of randomised shortest paths) from the origin to each location on every connection, then for each pair of locations the sum over the connections of min(f1, f2) (overlap) or max(f1, f2)(1 - min) - min (non-overlap), weighted by the cost of each connection or by weights (a transition, or a set: cost.barriers, cost.areas; a result per transition).

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
originrequiredvectorthe common origin (one point)
fromrequiredvectorthe locations
tovectorother locations (default: the pairs among from)
weightsstacka transition or a set (default: the costs)
OutputTypeWhat it is
overlaptablea row per weight and location: its numbers, then each pair's
nonoverlaptablethe same, of the non-overlap
SettingTypeWhat it is
thetanumberrandomised shortest paths, 0 to 20 (default: random walks)
gdistance_compatboolrandom walks: gdistance's grounded cell (default true)

cost.rsp_distance#

Randomised-shortest-path distances between points (gdistance's rSPDistance through landschaft's C++): the expected cost of the walk from each point to each other, near a random walk's with theta near 0, near the least cost with large theta. No value for points off the grid.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
fromrequiredvectorthe points
tovectorother points (default: the same)
OutputTypeWhat it is
tabletablea row per point from: its number, then the cost to each point
SettingTypeWhat it is
thetarequirednumber0 to 20
total_nettextthe cost of the net (default) or total passages
methodinteger1 (default): exp(-theta cost) P; 2: P^theta

cost.shortest_path#

The least-cost paths from an origin to goals over a transition of conductances (gdistance's shortestPath through landschaft's C++, igraph's ties): lines through the cells' centres, and a map of the share of the paths that cross each cell.

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
originrequiredvectorthe origin (the first point)
goalsrequiredvectorthe goals
OutputTypeWhat it is
linesvectora line per goal (id 1..)
mapmapthe share of the paths through each cell

cost.sum_reciprocal#

Two transitions of conductances as resistances in series (gdistance's sumReciprocal): 1 / (1/a + 1/b) on the connections.

InputTypeWhat it is
arequiredstacka transition
brequiredstackanother, on the same grid
OutputTypeWhat it is
transitionstackthe result

cost.to_map#

A map of each cell's connections (gdistance's raster() of a TransitionLayer): sums or means of the matrix's columns (connections into the cell) or rows (out of it); NZ: the mean over the connections only (no value without any).

InputTypeWhat it is
transitionrequiredstacka transition (cost.transition)
OutputTypeWhat it is
mapmapa value per cell
SettingTypeWhat it is
reducetextNZcolMeans (default)...

cost.transition#

A transition between neighbouring cells (gdistance's transition through landschaft's C++): the connection of every cell with its 4, 8 or 16 neighbours, a function of the two cells' values (mean, min, max, sum, prod, from, to, diff, harmonic, geometric), none where either has no value. Usually of a conductance (1 / resistance), then corrected for the cells' distances (cost.geo_correction).

InputTypeWhat it is
maprequiredmapthe values (a conductance, usually)
OutputTypeWhat it is
transitionstacka layer per direction
SettingTypeWhat it is
functiontextof the two cells' values: mean (default)...
directionsinteger4, 8 (default) or 16
symmetricboolone value per pair of cells (default true)
reciprocalbool1 / the function's value (a conductance of a resistance; gdistance's 1 / transition(r, mean))