# 7. Guide to individual tools¶

## 7.1. Options common to multiple tools¶

Several tools share the following parameters:

*Input*,*Output*Shape layers for input and output

*Start grade separation*,*End grade separation*- Select fields for grade separation. If given, links will only be deemed connected if
- they share the same endpoints (x,y,z)
- they share the same grade separation value at those endpoints

Grade separation can also be used to emulate multilayer/multimode networks. For example, use values of 0,1,2... for grade separation on roads, 10,11,12... for railways, etc.

*Analysis Metric*Select metric for analysis: Euclidean, angular, custom, hybrid, other (see Distance Metric for details).

Custom metrics require selection of a custom metric data field.

If using hybrid metrics, the formula must be provided in advanced_config using the

*lineformula*and*juncformula*keywords.The remaining metrics provided are preset forms of hybrid metric designed for specific network types (pedestrian, vehicle, cycle, public transport). You can inspect the message output of sDNA to discover exactly what formula they use - this is, in fact, a good way to learn how to use hybrid metrics. Some presets include user variables, which have a default value but can be changed in advanced config; see preset metric variables.

Hybrid and preset metrics require sDNA+.

*Radii*Enter one or more radii to use as radius of analysis (see Radius for details). By default these are Euclidean and expressed in the spatial units of the data, which should usually be metres if your data is projected correctly. If entering several, separate them by commas. Radius ‘n’ can be used to specify global analysis, limited only by the size of the network (but computationally intensive). Example:

`100, 200, 400, 800, 1600, n`

*Radial metric*As well as using Euclidean radii, in sDNA+ it is possible to use radii expressed using any other metric. If using hybrid metrics, the formula must be provided in advanced_config using the

*radlineformula*and*radjuncformula*keywords. If using a custom metric, provide the custom data field to advanced_config in*radcustommetric*.If the radial metric is set to

*match_analytical*sDNA+ will use the analysis metric for the radius, which saves you from having to input the same metric twice.*Continuous space*Select whether continuous space analysis is used.

*Banded radius*If this mode is chosen, measures for each radius exclude links contained in the next smallest radius. This allows multivariate analysis across radii while keeping cross-correlation of measures to a minimum.

*Disable lines*Allows discarding of certain polylines from the analysis. This is useful for testing multiple design options, or for switching on and off parts of the network such as cycle paths.

This parameter takes an expression which, if it evaluates to a nonzero result for a given polyline, will disable that polyline. In the simplest case, this can be a field name such as

`walk_net`

(which would disable all lines for which the walk_net field is nonzero) or a combination such as`walk_net||cycle_net`

(which would disable both the walking and cycling network - useful for a vehicle analysis).

*Origin Destination Matrix file*Optionally allows weights to be determined by an Origin-Destination (OD) matrix. The file must be formatted correctly, see Creating a zone table or matrix file. All geodesic and destination weights are replaced by values read from the matrix. The matrix is defined between sets of

*zones*; polylines must contain fields to indicate their zone.In the case of sDNA Integral, Two phase betweenness is disabled, because use of a two phase model for determining geodesic and destination weights conflicts with use of an OD matrix to determine these.

*Intermediate link filter*Optionally restricts the analysis to include only geodesics that pass through a given line or set of lines specified by the filter. Affects output of Betweenness, Two Phase Betweenness, Two Phase Destination, Mean Crow Flight, Mean Geodesic Length, Diversion Ratio measures; also Geodesic and Destination geometries.

This parameter takes an expression which, if it evaluates to a nonzero result for a given line, will include geodesics which pass through that line. In the simplest case, this can be a field name such as

`my_link_filter`

(which would disable all lines for which the field*my_link_filter*is nonzero).It is not sufficient for a geodesic’s origin or destination to pass the filter; an intermediate line must pass in order for the geodesic to be included.

*Advanced config*Allows setting of parameters not shown in the interface. These are described in advanced_config.

## 7.2. Individual tool details¶

### Preparation¶

#### Prepare network¶

Prepares spatial networks for analysis by checking and optionally repairing various kinds of error.

**Note that the functions offered by sDNA prepare are only a small subset of those needed for preparing networks.** A good understanding of Network Preparation is needed, and other (free) tools can complement sDNA Prepare.

The errors fixed by sDNA Prepare are:

*endpoint near misses*(XY and Z tolerance specify how close a near miss)*duplicate lines**traffic islands*(requires traffic island field set to 0 for no island and 1 for island). Traffic island lines are straightened; if doing so creates duplicate lines then these are removed.*split links*. Note that fixing split links is no longer necessary as of sDNA 3.0 so this is not done by default*isolated systems*

See Options common to multiple tools.

Optionally, numeric data can be preserved through a prepare operation by providing the desired field names, separated by commas, to the parameters *Absolute data to preserve* and *Unit length data to preserve*. (Requires sDNA+).

#### Individual Line Measures¶

Outputs connectivity, bearing, euclidean, angular and hybrid metrics for individual polylines.

This tool can be useful for checking and debugging spatial networks. In particular, connectivity output can reveal geometry errors.

### Analysis¶

#### Integral Analysis¶

sDNA Integral is the core analysis tool of sDNA. It computes several flow, accessibility, severance and efficiency measures on networks. Full details of the analysis are given in Analysis: what the results mean and Analysis: full specification.

Integral allows output of various groups of measures to be switched on and off.

#### Specific Origin Accessibility Maps¶

Outputs accessibility maps for specific origins. (Requires sDNA+).

See Options common to multiple tools.

The accessibility map tool also allows a list of origin polyline IDs to be supplied (separated by commas). Leave this parameter blank to output maps for all origins.

If outputting “maps” for multiple origins, these will be output in the same feature class as overlapping polylines. It may be necessary to split the result by origin link ID in order to display results correctly.

#### Integral from OD Matrix (assignment model)¶

A simplified version of sDNA Integral geared towards use of an external Origin Destination matrix. Note that several other tools (including Integral) allow Origin Destination matrix input as well.

The file must be formatted correctly, see Creating a zone table or matrix file. All geodesic and destination weights are replaced by values read from the matrix. The matrix is defined between sets of *zones*; polylines must contain text fields to indicate their zone.

#### Skim Matrix¶

Skim Matrix outputs a table of inter-zonal mean distance (as defined by whichever sDNA Metric is chosen), allowing high spatial resolution sDNA models of accessibility to be fed into existing zone-base transport models.

### Geometries¶

The geometry tools output individual geometries used in an integral analysis. These may be useful either for visualization, or for exporting to external analysis tools. For example, you could join geodesics to a pollution dataset to estimate exposure to pollution along everyday travel routes.

#### Convex Hulls¶

Outputs the convex hulls of network radii used in Integral Analysis. (Requires sDNA+).

See Options common to multiple tools.

The convex hulls tool also allows a list of origin polyline IDs to be supplied (separated by commas). Leave this parameter blank to output hulls for all origins.

#### Geodesics¶

Outputs the geodesics (shortest paths) used by Integral Analysis. (Requires sDNA+).

See Options common to multiple tools.

The geodesics tool also allows a list of origin and destination polyline IDs to be supplied (separated by commas). Leave the origin or destination parameter blank to output geodesics for all origins or destinations. (Caution: this can produce a very large amount of data).

#### Network Radii¶

Outputs the network radii used in Integral Analysis. (Requires sDNA+).

See Options common to multiple tools.

The network radii tool also allows a list of origin polyline IDs to be supplied (separated by commas). Leave this parameter blank to output radii for all origins.

### Calibration¶

sDNA Learn and Predict provide a way to calibrate sDNA outputs against measured variables (flows, house prices, etc). Currently they offer bivariate regression with Box-Cox transformation. Multiple predictor variables (the outputs of sDNA) can be tested to see which gives the best cross-validated correlation with the target variable.

#### Learn¶

sDNA Learn selects the best model for predicting a target variable, then computes GEH and cross-validated \(R^2\). If an output model file is set, the best model is saved and can be applied to fresh data using sDNA Predict.

Available methods for finding models are:

*Single best variable*- performs bivariate regression of target against all variables and picks single predictor with best cross-validated fit*Multiple variables*- regularized multivariate lasso regression*All variables*- regularized multivariate ridge regression (may not use all variables, but will usually use more than lasso regression)

Candidate predictor variables can either be entered as field names separated by commas, or alternatively as a *regular expression*. The latter follows Python regex syntax. A wildcard is expressed as `.*`

, thus, `Bt.*`

would test all Betweenness variables (which in abbreviated form begin with *Bt*) for correlation with the target.

Box-Cox transformations can be disabled, and the parameters for cross-validation can be changed.

*Weighting lambda* weights data points by \(\frac{y^\lambda}{y}\), where \(y\) is the target variable. Setting to 1 gives unweighted regression. Setting to around 0.7 can encourage selection of a model with better GEH statistic, when used with traffic count data. Setting to 0 is somewhat analagous to using a log link function to handle Poisson distributed residuals, while preserving the model structure as a linear sum of predictors. Depending on what you read, the literature can treat traffic count data as either normally or Poisson distributed, so something in between the two is probably safest.

Ridge and Lasso regression can cope with multicollinear predictor variables, as is common in spatial network models. The techniques can be interpreted as frequentist (adding a penalty term to prevent overfit); Bayesian (imposing a hyperprior on coefficient values); or a mild form of entropy maximization (that limits itself in the case of overspecified models). More generally it’s a machine learning technique that is tuned using cross-validation. The \(r^2\) values reported by learn are always cross-validated, giving a built-in test of effectiveness in making predictions.

#### Predict¶

Predict takes an output model file from sDNA Learn, and applies it to fresh data. For example, suppose we wish to calibrate a traffic model, using measured traffic flows at a small number of points on the network.

- First run a Betweenness analysis at a number of radii using Integral Analysis.
- Use a GIS spatial join to join Betweenness variables (the output of Integral) to the measured traffic flows.
- Run Learn on the joined data to select the best variable for predicting flows (where measured).
- Run Predict on the output of Integral to estimate traffic flow for all unmeasured polylines.

## 7.3. Advanced configuration and command line options¶

sDNA supports a wide variety of options for customizing the analysis beyond what is shown in the user interface. All of these are accessed through the advanced config system.

Advanced config options are specified in a long string with options separated by semicolons (;) like this:

```
nohull;probroutethreshold=1.2;skipzeroweightorigins
```

This is an example of an advanced config for sDNA Integral, which means

- Don’t compute convex hull
- Problem route threshold = 1.2
- Skip zero weight origins

When calling sDNA Integral Analysis and Prepare Network from the command line (Using sDNA from the command line), the entire configuration is specified as an advanced config. Therefore, the advanced config options include some which are usually set via the graphical interface. If these options are given as advanced config in the sDNA graphical interface, an error (“Keyword specified multiple times”) will result.

### Advanced config options for sDNA Prepare¶

Option | Description | sDNA | sDNA+ |
---|---|---|---|

startelev= | Name of field to read start elevation from | Yes | Yes |

endelev= | Name of field to read end elevation from | Yes | Yes |

island= | Name of field to read traffic island information from. Anything other than zero will be treated as traffic island | Yes | Yes |

islandfieldstozero= | Specifies additional data fields to set to zero when fixing traffic islands (used for e.g. origin or destination weights) | No | Yes |

data_unitlength= | Specifies numeric data to be preserved by sDNA prepare (preserves values per unit length, averages when merging links) | No | Yes |

data_absolute= | Specifies numeric data to be preserved by sDNA prepare (preserves absolute values, sums when merging links) | No | Yes |

data_text | Specifies text data to be preserved (merges if identical, deletes otherwise) | No | Yes |

xytol= | Manual override xy tolerance for fixing endpoint connectivity | Yes | Yes |

ztol= | Manual override z tolerance for fixing endpoint connectivity | No | Yes |

*xytol and ztol are manual overrides for tolerance. sDNA, running
on geodatabases from command line or ArcGIS, will read tolerance values from each feature class as
appropriate. sDNA running in QGIS or on shapefiles will use a default tolerance of
0, as shapefiles do not store tolerance information:- manual override is
necessary to fix tolerance on shapefiles.*

### Advanced config options for sDNA Integral and geometry tools¶

*sDNA Convex Hulls, Network Radii, Geodesics and Accessibility Map are all different interfaces applied to sDNA Integral, so will in some cases accept these options as well.*

Option | Default | Description | sDNA | sDNA+ |
---|---|---|---|---|

startelev= | Name of field to read start elevation from | Yes | Yes | |

endelev= | Name of field to read end elevation from | Yes | Yes | |

metric= | angular | Metric – angular, euclidean, custom or hybrid (see next section) | Yes | Yes |

radius= | n | List of radii separated by commas | Yes | Yes |

startelev= | Name of field to read start elevation from | Yes | Yes | |

endelev= | Name of field to read end elevation from | Yes | Yes | |

weight= | Name of field to read weight from. Applies weight field to both origins and destinations. | Yes | Yes | |

lenwt | Specifies that weight field is per unit length | Yes | Yes | |

custommetric= | Specified field name to read custom metric from | Yes | Yes | |

xytol= | Manual override xy tolerance for fixing endpoint connectivity. | Yes | Yes | |

ztol= | Manual override z tolerance for fixing endpoint connectivity. | No | Yes | |

outputgeodesics | Output geometry of all pairwise geodesics in analysis (careful – this can create a lot of data) | No | Yes | |

outputdestinations | Output geometry of all pairwise destinations in analysis (careful – this can create a lot of data). Useful in combination with origins for creating a map of distance/metric from a given origin. | No | Yes | |

outputhulls | Output geometry of all convex hulls in analysis | No | Yes | |

outputnetradii | Output geometry of all network radii in analysis | No | Yes | |

origins= | Only compute selected origins (provide feature IDs as comma separated list). Useful in conjunction with outputgeodesicsm, outputdestinations, outputhulls, outputnetradii. | No | Yes | |

destinations= | Only compute selected destinations (ditto) | No | Yes | |

nonetdata | Don’t output any network data (used in conjunction with geometry outputs) | No | Yes | |

pre= | Prefix text of your choice to output column names | Yes | Yes | |

post= | Postfix text of your choice to output column names | Yes | Yes | |

nobetweenness | Don’t calculate betweenness (saves a lot of time) | Yes | Yes | |

nojunctions | Don’t calculate junction measures (saves time) | Yes | Yes | |

nohull | Don’t calculate convex hull measures (saves time) | Yes | Yes | |

linkonly | Only calculate individual link measures. | Yes | Yes | |

outputsums | Output sum measures SAD, SCF etc as well as means MAD, MCF etc. | Yes | Yes | |

probroutes | Output measures of problem routes – routes which exceed the length of the radius | No | Yes | |

forcecontorigin | Force origin link to be handled in continuous space, even in a discrete analysis. Prevents odd results on very long links. | Yes | Yes | |

nqpdn= | 1 | Custom numerator power for NQPD equation | No | Yes |

nqpdd= | 1 | Custom denominator power for NQPD equation | No | Yes |

skipzeroweightorigins | Skips calculation of any output measures for origins with zero weight. Saves a lot of time if many such origins exist. | No | Yes | |

skipzeroweightdestinations | 1 | Zero weight destinations are skipped by default. Note this will exclude them from geometry outputs; if this is not desired behaviour then set skipzeroweightdestinations=0 | No | Yes |

skiporiginifzero= | Specified field name. If this field is zero, the origin will be skipped. Allows full customization of skipping origins. | No | Yes | |

skipfraction= | 1 | Set to value n, skips calculation for (n-1)/n origins. Effectively the increment value when looping over origins. | No | Yes |

skipmod= | 0 | Chooses which origins are calculated if skipfraction?1. Effectively the initial value when looping over origins: every skipfractionth origin is computed starting with the skipmodth one. | No | Yes |

nostrictnetworkcut | Don’t constrain geodesics to stay within radius. This will create a lot more ‘problem routes’. Only alters behaviour of betweenness measures (not closeness). | No | Yes | |

probrouteaction= | ignore | Take special action for problem routes that exceed the radius by a factor greater than probroutethreshold. Can be set to ignore, discard or reroute. Reroute changes geodesic to shortest Euclidean path. Only alters betweenness output, not closeness. | No | Yes |

probroutethreshold= | 1.2 | Threshold over which probrouteaction is taken. Note this does not affect computation of probroutes measures, which report on all routes which exceed the radius length regardless of this setting. | No | Yes |

outputdecomposableonly | output only measures which are decomposable i.e. can be summed over different origins (useful for parallelization) | No | Yes | |

linkcentretype= | Angular for angular analysis, Euclidean otherwise | Override link centre types – angular or Euclidean | No | Yes |

lineformula= | Formula for line metric in hybrid analysis (see below) | No | Yes | |

juncformula= | 0 | Formula for junction turn metric in hybrid analysis (see below) | No | Yes |

ignorenonlinear | Force sDNA to proceed even if linkformula is nonlinear (see below) | No | Yes | |

bidir | Output betweenness for each direction separately | No | Yes | |

oneway= | Specified field name to read one way data from (see note 1 below) | No | Yes | |

vertoneway= | Specified field name to read vertical one way data from (see note 1 below) | No | Yes | |

oversample= | 1 | Number of times to run the analysis; results given are the mean of all runs. Useful for sampling hybrid metrics with random components. | No | Yes |

odmatrix | Read OD matrix from input tables (a 2d table must be present) | No | Yes | |

zonedist= | euc | Set expression to determine how zone weights are distributed over links in each zone, or 0 to skip distribution (all lines receive entire zone weight) | No | Yes |

intermediates= | Set expression for intermediate link filter. Geodesics are discarded unless they pass through link where expression is nonzero. | No | Yes | |

disable= | Set expression to switch off links (links switched off when expression evaluates nonzero) | No | Yes | |

radlineformula | Formula for radial line metric in when using hybrid radial metric (see below) | No | Yes | |

radjuncformula | 0 | Formula for junction turn metric when using hybrid radial metric (see below) | No | Yes |

radcustommetric | Data field for custom metric when using custom radial metric | No | Yes | |

radmetric | euclidean | Type of radial metric to use | No | Yes |

outputskim | Output skim matrix file | No | Yes | |

skimorigzone | Origin zone field (must be text) for skim matrix | No | Yes | |

skimdestzone | Destination zone field (must be text) for skim matrix | No | Yes | |

skimzone | Skim matrix zone field for both origin and destination (sets both skimorigzone and skimdestzone) | No | Yes | |

bandedradii | Divide radius into bands: for each radius only include links outside the previous radius | No | Yes |

### Preset metric variables¶

A number of preset metrics are provided for different urban forms of transport (currently *cycle*, *pedestrian* and *vehicle*). These are special cases of hybrid metrics, sometimes with a fairly complex formula. To inspect the formula for a given metric, run Individual Line Measures with the metric selected, and inspect the message output where the full formula will be shown.

The CYCLE_ROUNDTRIP metric, as the name implies, measures a round trip to take account of hills in both directions.

Certain variables within the preset metric formulae can be changed by assigning to them in advanced config. To date, the list is:

Metric | Variable | Default | Meaning |
---|---|---|---|

Vehicle | jp | 0 | Tendency of drivers to avoid junctions |

Vehicle | a | 1 | Tendency of drivers to avoid angular change |

Pedestrian | a | 0.5 | Blend of angular and Euclidean metric: 0 for full Euclidean, 1 for full Angular |

Cycle | aadtfield | aadt | Name of data field containing annual average daily vehicle traffic estimate |

Cycle | t | 0.04 | Tendency of cyclists to avoid vehicle traffic |

Cycle | a | 0.3 | Tendency of cyclists to avoid angular change |

Cycle | s | 0.5 | Tendency of cyclists to avoid slope |

Public Transport | linefield | line | Name of data field containing ID for each public transport “line” |

Public Transport | c | 3 | Penalty for changing line (applied whenever “line” field changes) |

Public Transport | s | 1 | Penalty per stop (applied per polyline) |

Public Transport | e | 0.001 | Penalty multiplier for Euclidean distance |

### Interpretation of one way data¶

One way data is interpreted as follows:

- 0 – traversal allowed in both directions (so long as
*vertoneway*allows this too) - positive number – forward traversal only
- negative number – backward traversal only

Forwards/backwards are taken with respect to the direction in which the link is drawn in the network (ordering of points in the data).

Vertical one way data is interpreted as follows:

- 0 – traversal allowed in both directions (so long as
*oneway*allows this too) - positive number – upward traversal only
- negative number – downward traversal only

Upward/downward are deduced by measuring the endpoints of the link only. In the event that these have the same elevation/height and this leads to ambiguity, sDNA will print an error message and exit.

If conflicting *oneway* and *vertoneway* data are provided, sDNA
will print an error message and exit. Note that if either field is zero,
the other is permitted to override it without conflict.

### Hybrid analysis¶

In hybrid analysis, custom expressions can be given in advanced config for the evaluation metric of (partial) links and junctions. Here are some examples of advanced configs that specify hybrid analysis.

To simulate Euclidean analysis, assign links a metric equal to their Euclidean length. Junctions receive metric of 0 by default:

```
lineformula=euc
```

To simulate angular analysis, both links and junctions have a metric equal to their angular change:

```
lineformula=ang; juncformula=ang
```

A mixture of the two. Links have a metric of their Euclidean distance plus twice their angular change; junctions get 3 times the angular change:

```
lineformula=euc+2*ang; juncformula=3*ang
```

Topological analysis – counting only the number of junctions and ignoring length and angularity:

```
lineformula=0; juncformula=1
```

The formulae used by lineformula and junctionformula are much like those in any spreadsheet or programming language (see expressions). Crucially you have access to the following variables:

Variable | Meaning | Available for links | Available for junctions |
---|---|---|---|

ang | Angular change | Yes | Yes |

euc | Euclidean distance | Yes | No |

hg | Height gain | Yes | No |

hl | Height loss | Yes | No |

FULLang | Angular change for entire line | Yes | No |

FULLeuc | Euclidean distance for entire line | Yes | No |

FULLhg | Height gain for entire line | Yes | No |

FULLhl | Height loss for entire line | Yes | No |

fwd | True if you are traversing this line forwards, false if backwards | Yes | No |

(Forwards/Backwards have no physical meaning but are defined by the orientation of the polyline in your network data.)

You also have access to any custom numeric data attached to your input
network. So for example if you had a field on your input data called
*travel_time*, then you might write:

```
lineformula=travel_time (WRONG!)
```

But while possible, this is not a good formula to use: sDNA would return an error saying the formula is not linear!

The reason for this is that sDNA’s continuous space algorithm does not necessarily evaluate the formula for a whole polyline at once, so at any time, the
formula might be applied to a partial line. So, let’s say the *travel_time*
for a given line is 1 minute. If the above formula were to be evaluated
once, the metric for that line would be 1 minute, which is correct. But
if sDNA breaks the link into two parts and evaluates each part
separately, the metric will be 2 minutes – which is clearly wrong. So
here is one solution to the problem:

```
lineformula=euc/FULLeuc*travel_time
```

The above formula assumes travel time is distributed evenly along the link length, calculates the proportion the link we are currently
processing `(euc/FULLeuc)`

and multiplies that by `travel_time`

so that
no matter how the link is divided inside sDNA, the metric for the full
link will always be the same.

Formally, the requirement for *lineformula* as a function is that it is
linear with respect to breaking down any given link *L* into arbitrary
parts of links *x* and *y*

Inspired by this, you might like to try distributing your custom travel time along the angular changes in a link instead of its length:

```
lineformula=ang/FULLang*travel_time (WRONG!)
```

This time sDNA fails during computation. The reason would be that some links are totally straight lines, and these have no angular
cost. Thus *ang* and *FULLang* are both zero, and zero divided by zero is
not a number. We need another way to handle
the case of straight links. How about distributing travel time down the
link’s angular change normally, but if there is no angular change, then
distributing down its length?:

```
lineformula=(FULLang!=0)?ang/FULLang*travel_time:euc/FULLeuc*travel_time
```

Notice that last formula introduced () brackets, != inequality, and :? the if-then-else ternary operator.

The same formula can be simplified a little by using a temporary variable:

```
lineformula= _p=(FULLang!=0)?ang/FULLang:euc/FULLeuc , _p*travel_time
```

Any variable beginning with an underscore `_`

, is assumed to be
temporary (not present on the input data). So in the above example we
first set `_p`

to represent the proportion of the link we were
processing, then we output a value of `_p`

times `travel_time`

. These
two operations were separated by a comma `,`

. This may seem like a minor
improvement, but as formulae get more complicated, it helps.

### Expression reference¶

Operator (in reverse order of precedence) | Name | Example | Meaning |
---|---|---|---|

, | Statement separator | a,b,c | Do a, then b, then output c |

= | Assignment | _a=b | Set _a equal to b |

?: | If-then-else | p?x:y | If p then x else y |

&& | Logical and | a&&b | a and b |

|| | Logical or | a||b | a or b |

<= | Less than or equal | a<=b | a is less than or equal to b |

>= | Greater than or equal | a>=b | a is greater than or equal to b |

!= | Not equal | a!=b | a is not equal to b |

== | Equal | a==b | a is equal to b |

> | Greater than | a>b | a is greater than b |

< | Less than | a<b | a is less than b |

+ | Addition | a+b | a plus b |

- | Subtraction | a-b | a minus b |

* | Multiplication | a*b | a times b |

/ | Division | a/b | a divided by b |

^ | Exponentiation | a^b | a to the power of b |

() | Parentheses | 2*(x+1) | add one to x then multiply by 2 |

Builtin functions | |
---|---|

sin(x), cos(x), tan(x) asin(x), acos(x), atan(x) sinh(x), cosh(x), tanh(x) asinh(x), acosh(x), atanh(x) |
Trigonometric functions of x (in radians). |

log2(x) | Logarithm of x base 2 |

log10(x), log(x) | Logarithm of x base 10 |

ln(x) | Logarithm of x base e |

exp(x) | e to the power of x |

sqrt(x) | Square root of x |

sign(x) | -1 if x is negative, else 1 |

rint(x) | x rounded to nearest integer |

abs(x) | Absolute value of x |

min(a,b,c,…) max(a,b,c,…) sum(a,b,c,…) avg(a,b,c,…) |
Minimum, maximum, sum and average of all arguments |

trunc(x,l,u) | Truncate x to the range [l,u] (including endpoints) |

randnorm(m,s) | Random number drawn from normal distribution with mean m and standard deviation s |

randuni(l,u) | Random number drawn from uniform distribution on range [l,u] |

Random numbers are generated from Mersenne Twister mt19937 algorithm.
*“Mersenne Twister: A 623-dimensionally equidistributed uniform
pseudo-random number generator”, Makoto Matsumoto and Takuji Nishimura,
ACM Transactions on Modeling and Computer Simulation: Special Issue on
Uniform Random Number Generation, Vol. 8, No. 1, January 1998, pp.
3-30.*

Constants | |
---|---|

inf | infinity |

pi | pi |

Variables | |
---|---|

ang | Angular change |

euc | Euclidean distance |

hg | Height gain |

hl | Height loss |

FULLang | Angular change for entire link |

FULLeuc | Euclidean distance for entire link |

FULLhg | Height gain for entire link |

FULLhl | Height loss for entire link |

fwd | True if you are traversing this link forwards, false if backwards |

_x |
(where x is any name): Temporary variable (initialized to 0) |

x |
(where x is any name not used as function or other value): field data on network link |

PREV*x* | (junction metrics only): field data on previous network link |

NEXT*x* | (junction metrics only): field data on next network link |

*Any variable can be assigned to with =, but the new value will only
affect the current formula being evaluated (assigning to ``ang`` will
not change the shape of the network, for example!). It is recommended to
use only temporary variables of the form ``_x`` as targets for
assignment.*

### Creating a zone table or matrix file¶

sDNA can read custom zone data, that is, data attached to *zones* rather than individual lines in the network. Currently, this feature only extends to reading a custom origin-destination (OD) matrix, though further features are planned. An OD matrix must be provided as a two dimensional zone table.

One dimensional tables can be provided in *list* format, and two dimensional tables can be provided in *list* or *matrix* format. The *list* format allows for sparse data, that is, data need not be given for all zones, and is assumed to be zero where not given.

All tables must be saved in CSV (comma separated) format.

#### 1d table in list format¶

list | 1 | ||

zone | houses | jobs | schools |

westeros | 2000 | 4000 | 4 |

royston vasey | 1800 | 7 | 1 |

mordor | 600 | 10000 | 0 |

narnia | 2100 | 500 | 3 |

A 1d table in list format must have

*list*and*1*in the header row- zone field name and data names in the second row. The network must contain a text field with name matching the zone field name (in this case “zone”)
- zones and data below

#### 2d table in list format¶

list | 2 | |

zone | zone | flow |

shire | rivendell | 4 |

rivendell | mordor | 6 |

mordor | shire | 2 |

gondor | mordor | 10000 |

mordor | gondor | 5000 |

A 2d table in list format must have

*list*and*2*in the header row- origin and destination zone field names followed by data names in the second row. The network must contain a text field with name matching the zone field names. In this case, the origin and destination zones are drawn from the same set so these are both named “zone”. Different sets of zones for origin and destination are supported however (e.g. for use with census residential and workplace zones).
- zones and data below

#### 2d table in matrix format¶

matrix | zone | zone | ||

flow | shire | rivendell | gondor | mordor |

shire | 0 | 4 | 0 | 0 |

rivendell | 0 | 0 | 0 | 6 |

gondor | 0 | 0 | 0 | 10000 |

mordor | 2 | 0 | 5000 | 0 |

*This table shows the same data as the 2d table in list format above*

A 2d table in matrix format must have

*matrix*in the first line followed by the origin zone field name then the destination zone field name. The network must contain a text field with name matching the zone field names. In this case, the origin and destination zones are drawn from the same set so these are both named “zone”. Different sets of zones for origin and destination are supported however (as with 2d list tables above).- the second row starts with the name of the data, then the name of each destination zone
- the left column from row 3 downwards contains the name of each origin zone
- the remainder of the matrix contains the data