I am struggling on how to calculate tortuosity in QGIS. My data includes numerous lines (the mapping of animal trails) I have tried calculating tortuosity with the field calculator but had no luck is there a plugin that I need to use or have I just missed something?
Asked
Active
Viewed 306 times
3
-
Sorry for the 'noob" question ... but how do u define tortuosity ? Or ... how do u plan to calculate it ? – Snaileater Feb 14 '19 at 16:41
-
Fractal dimension, might be the common term for what I want...... basically how many turns/ torsions are in a single line? If that helps you any further – Alison Jones Feb 14 '19 at 16:50
-
2To help get better answers, maybe flesh out your question with the calculations to execute, parts of the expressions you wrote, your data structure, etc. – Gabriel Feb 14 '19 at 17:03
2 Answers
3
For the arc-chord ratio, as defined in: https://en.wikipedia.org/wiki/Tortuosity
Use the formula:
length( $geometry) / distance( start_point( $geometry), end_point( $geometry))
Gabriel De Luca
- 14,289
- 3
- 20
- 51
3
Exactly what are you after? The sinuosity index, arc-chord ratio, Mächler's Index or Hausdorff's (fractal) dimension. These are all calculated in very different ways, making your question somewhat vague. Unless somebody has written a Python or R script or one of these indexes exist in a software associated with QGIS, you are likely going to have to write your own function.
In R, for the sinuosity index, you could do something like this.
First, create some data
library(sp)
library(RandomFields)
x <- seq(0, 10, 0.1)
y <- RFsimulate(RMexp(), x)
xy <- data.frame( x = coordinates(y), y = y@data)
l <- SpatialLinesDataFrame(SpatialLines(list(Lines(list(Line(as.matrix(xy))),
ID=1))), data.frame(V1=c(1),row.names=c(1)))
Then, pull first/last coordinates and calculate the sinuosity index and arc-chord ratio.
First <- unlist(lapply(coordinates(l), FUN=function(x) { x[[1]][1,] } ))
Last <- unlist(lapply(coordinates(l), FUN=function(x) { x[[1]][dim(x[[1]])[1],] } ) )
( s <- sqrt( ( First[1] - Last[1] ) ^ 2 +
( First[2] - Last[2] ) ^ 2 ) /
sp::SpatialLinesLengths(l) )
( acr <- sp::SpatialLinesLengths(l) /
max(spDists(cbind(First,Last))) )
Jeffrey Evans
- 31,750
- 2
- 47
- 94