I want to run a cycle roundtrip model in sDNA. My file is a road center line (RCL) map, containing z coordinates (start Z, end Z - image attached).

The RCL vector file is shown by GRASS GIS as 3D, but is flat (elev = 0). Consequently, s=0, s=1, etc. yield identical results applying the cycle model (Hmf and Hmb, and all other output variables).

How could I accomplish running the cycle roundtrip model with such a file, instead of a true 3D vector?

I have converted the vector to 3D based on endpoints, but sDNA network preparation fails - many links seem to be separated vertically.

enter image description here

1 Answer 1


I couldn't say what went wrong with your conversion to 3d. However you could use an sDNA hybrid metric based on CYCLE_ROUNDTRIP and adapt it to estimate link slope from its endpoint elevations.

The default CYCLE_ROUNDTRIP metric is printed to sDNA's output when you run it:

lineformula=_a=0.2,_s=2,_t=0.04,_slope = hg/FULLeuc*100,_slopefac = _slope<2?1:(_slope<4?1.371:(_slope<6?2.203:4.239)),_slopeb = hl/FULLeuc*100,_slopefacb = _slopeb<2?1:(_slopeb<4?1.371:(_slopeb<6?2.203:4.239)),_trafficfac = 0.84*exp(aadt/1000), euc* (_slopefac^_s + _slopefacb^_s) * (_trafficfac^_t) + _a*67.2/90*ang*2;juncformula=0.2*67.2/90*ang*2

The above makes use of sDNA builtin variables hg (height gain) and hl (height loss). Note that hg and hl do not assume the link has even slope - they accumulate total height gain and loss over the link such that gains and losses do not cancel. However the CYCLE_ROUNDTRIP formula does use them in a way that assumes even slope.

In the example below I replace them with user defined temporary variables (which must start with underscore, otherwise sDNA will go looking for them in the input data) _hg and _hl

Note also that the above formula isn't applied to a whole link at once. It is applied at most to half a link (in discrete space mode) or smaller fractions thereof (in continuous space mode). So to compute mean slope for the link we compute elevation change between its endpoints and divide by the full network-Euclidean length of the link FULLeuc:

_slope = _hg/FULLeuc*100

where _hg was computed from your endpoint data TO_Z, FROM_Z as follows


(fwd tells us whether this link is being traversed forwards, hence which way round FROM and TO should be; we then set any negative elevation change to 0 to get height gain _hg).

Later in the final expression, recalling that we may not be computing a whole link at a time, we multiply the various factors by euc the length of the fraction of link under consideration.

The full formula:

lineformula=_a=0.2,_s=2,_t=0.04,_elevchange=fwd?TO_Z-FROM_Z:FROM_Z-TO_Z,_hg=_elevchange>0?_elevchange:0,_hl=_elevchange<0?-_elevchange:0,_slope = _hg/FULLeuc*100,_slopefac = _slope<2?1:(_slope<4?1.371:(_slope<6?2.203:4.239)),_slopeb = _hl/FULLeuc*100,_slopefacb = _slopeb<2?1:(_slopeb<4?1.371:(_slopeb<6?2.203:4.239)),_trafficfac = 0.84*exp(aadt/1000), euc* (_slopefac^_s + _slopefacb^_s) * (_trafficfac^_t) + _a*67.2/90*ang*2;juncformula=0.2*67.2/90*ang*2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.