I've been looking through all of the GRASS commands in the QGIS 2.10 processing toolbox and it seems like one of these must be able to do this but I haven't found one yet. There is 'v.sample' which can sample a DEM at a point location. Is there a way to do something similar to sample a DEM when calculating the length of a line segment?
QGIS – How to Calculate the 3D Length of Line Segment in QGIS
grassqgisqgis-processing
Related Solutions
It is not very comfortable to do, but the following is the required syntax for that textbox (I write it in several lines only for the sake of clearness):
{'expression': u'type the expression here',
'length': <type the length>,
'type': <code of the type>,
'name': u'type the field name here',
'precision': <type the precision>}
For example (remeber to use curly brackets):
{'expression': u'"FLAG1"+"FLAG2"',
'length': 20, 'type': 6,
'name': u'FLAG1',
'precision': 5}
You need to write as many lines like the one above as the number of input fields, separated by commas. For example, if your layer contains three fields:
{'expression': u'"FLAG1"+"FLAG2"', 'length': 20, 'type': 6, 'name': u'FLAG1', 'precision': 5}, {'expression': u'100*"FLAG2"', 'length': 20, 'type': 6, 'name': u'FLAG2', 'precision': 5}, {'expression': u'"100-"FLAG2"', 'length': 20, 'type': 6, 'name': u'FLAG3', 'precision': 5}
and it should work (it worked for me).
Please note that you may avoid to use this dictionary-oriented syntax and directly use the required values. For example, with reference to the first example, you may simply use:
{u'"FLAG1"+"FLAG2"', 20, 6, u'FLAG1', 5}
If you don't use this syntax, the following error will be shown:
Missing parameter value: Fields mapping (row 1)
The following is a step-by-step process for how to take an ArcGIS D8 flow direction raster and use it to perform a D8 flow accumulation operation in Whitebox Geospatial Analysis Tools. I will preface this by saying that it would obviously be much easier if you had the original DEM from which the flow direction raster was derived. Also, I'm making the assumption that your flow direction raster was derived using the D8 flow algorithm and that it was derived using the ArcGIS flow pointer scheme.
The first step is getting your flow direction raster from ArcGIS into Whitebox GAT. There are several ways to do this, but I recommend using the Raster to Float tool in ArcGIS to convert your raster into a .flt file. This is one of the most efficient formats for getting data into Whitebox GAT. Next, open Whitebox GAT and add the layer to the map. A pop-up window will appear asking if you'd like to convert the raster to Whitebox format, and you simply need to click 'yes'.
The ArcGIS D8 flow direction raster uses the following scheme:
Which is different than Whitebox GAT's:
So you need to use the Reclass tool to convert the pointer values:
- Now all you need to do is enter your new flow direction raster as the input D8 flow pointer raster file in the D8 and Rho8 Flow Accumulation tool.
As for your question about the weight raster, you might want to take a look at the D8 Mass Flux tool, which allows for a weight (loading) file and two types of losses (efficiency, which is a proportional loss, and absorption, which is a loss amount).
Best Answer
You can also calculate the length of a line taking into account the topography the following way:
Use the "Profiles from line" (SAGA) tool, which adds points along the line, giving the length from the line start to each point ("DIST" as the length on a flat surface, "DIST_SURF" with heights included).
Select the point with the maximum length value with "extract by expression". If you have multiple lines, use this expression:
"DIST_SURF" = maximum("DIST_SURF","LINE_ID")
, which will extract the max. point for each line.Then join these values back to the original line layer, taking only "DIST_SURF" from the point layer.
Admittedly it's not in GRASS but it still works.