Skip to content

Commit 6596adc

Browse files
committed
Merge pull request #2073 from NaturalGIS/fix_grass7_r_flow
[processing] fix grass7 r.flow
2 parents cec5bde + d591ac4 commit 6596adc

File tree

5 files changed

+66
-15
lines changed

5 files changed

+66
-15
lines changed

python/plugins/processing/algs/grass7/Grass7Algorithm.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,30 @@ def processAlgorithm(self, progress):
384384
if isinstance(out, OutputVector):
385385
filename = out.value
386386
# FIXME: check if needed: -c Also export features without category (not labeled). Otherwise only features with category are exported.
387-
command = 'v.out.ogr -s -e input=' + out.name + uniqueSufix
388-
command += ' output="' + os.path.dirname(out.value) + '"'
389-
command += ' format=ESRI_Shapefile'
390-
command += ' olayer=' + os.path.basename(out.value)[:-4]
391-
typeidx = \
392-
self.getParameterValue(self.GRASS_OUTPUT_TYPE_PARAMETER)
393-
outtype = ('auto' if typeidx
387+
if self.grass7Name == 'r.flow':
388+
command = 'v.out.ogr type=line layer=0 -c -e input=' + out.name + uniqueSufix
389+
command += ' output="' + os.path.dirname(out.value) + '"'
390+
command += ' format=ESRI_Shapefile'
391+
command += ' olayer=' + os.path.basename(out.value)[:-4]
392+
typeidx = \
393+
self.getParameterValue(self.GRASS_OUTPUT_TYPE_PARAMETER)
394+
outtype = ('auto' if typeidx
394395
is None else self.OUTPUT_TYPES[typeidx])
395-
command += ' type=' + outtype
396-
commands.append(command)
397-
outputCommands.append(command)
396+
command += ' type=' + outtype
397+
commands.append(command)
398+
outputCommands.append(command)
399+
else:
400+
command = 'v.out.ogr -s -e input=' + out.name + uniqueSufix
401+
command += ' output="' + os.path.dirname(out.value) + '"'
402+
command += ' format=ESRI_Shapefile'
403+
command += ' olayer=' + os.path.basename(out.value)[:-4]
404+
typeidx = \
405+
self.getParameterValue(self.GRASS_OUTPUT_TYPE_PARAMETER)
406+
outtype = ('auto' if typeidx
407+
is None else self.OUTPUT_TYPES[typeidx])
408+
command += ' type=' + outtype
409+
commands.append(command)
410+
outputCommands.append(command)
398411

399412
# 4: Run GRASS
400413

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
r.flow
2+
r.flow.aspect.barrier - Construction of flowlines, flowpath lengths, and flowaccumulation (contributing areas) from a raster digital elevation model (DEM).
3+
Raster (r.*)
4+
ParameterRaster|elevation|Elevation|False
5+
ParameterRaster|aspect|Aspect|False
6+
ParameterRaster|barrier|Barriers|False
7+
ParameterNumber|skip|Number of cells between flowlines|None|None|7
8+
ParameterNumber|bound|Maximum number of segments per flowline|None|None|1609
9+
ParameterBoolean|-u|Compute upslope flowlines instead of default downhill flowlines|False
10+
ParameterBoolean|-3|3-D lengths instead of 2-D|False
11+
*ParameterBoolean|-m|Use less memory, at a performance penalty|False
12+
OutputVector|flowline|Flow line
13+
OutputRaster|flowlength|Flow path length
14+
OutputRaster|flowaccumulation|Flow accumulation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
r.flow
2+
r.flow.aspect - Construction of flowlines, flowpath lengths, and flowaccumulation (contributing areas) from a raster digital elevation model (DEM).
3+
Raster (r.*)
4+
ParameterRaster|elevation|Elevation|False
5+
ParameterRaster|aspect|Aspect|False
6+
ParameterNumber|skip|Number of cells between flowlines|None|None|7
7+
ParameterNumber|bound|Maximum number of segments per flowline|None|None|1609
8+
ParameterBoolean|-u|Compute upslope flowlines instead of default downhill flowlines|False
9+
ParameterBoolean|-3|3-D lengths instead of 2-D|False
10+
*ParameterBoolean|-m|Use less memory, at a performance penalty|False
11+
OutputVector|flowline|Flow line
12+
OutputRaster|flowlength|Flow path length
13+
OutputRaster|flowaccumulation|Flow accumulation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
r.flow
2+
r.flow.barrier - Construction of flowlines, flowpath lengths, and flowaccumulation (contributing areas) from a raster digital elevation model (DEM).
3+
Raster (r.*)
4+
ParameterRaster|elevation|Elevation|False
5+
ParameterRaster|barrier|Barriers|False
6+
ParameterNumber|skip|Number of cells between flowlines|None|None|7
7+
ParameterNumber|bound|Maximum number of segments per flowline|None|None|1609
8+
ParameterBoolean|-u|Compute upslope flowlines instead of default downhill flowlines|False
9+
ParameterBoolean|-3|3-D lengths instead of 2-D|False
10+
*ParameterBoolean|-m|Use less memory, at a performance penalty|False
11+
OutputVector|flowline|Flow line
12+
OutputRaster|flowlength|Flow path length
13+
OutputRaster|flowaccumulation|Flow accumulation

python/plugins/processing/algs/grass7/description/r.flow.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ r.flow
22
r.flow - Construction of flowlines, flowpath lengths, and flowaccumulation (contributing areas) from a raster digital elevation model (DEM).
33
Raster (r.*)
44
ParameterRaster|elevation|Elevation|False
5-
ParameterRaster|aspect|Aspect|False
6-
ParameterRaster|barrier|Barriers|False
7-
ParameterNumber|skip|Number of cells between flowlines|None|None|1.0
8-
ParameterNumber|bound|Maximum number of segments per flowline|None|None|5.0
5+
ParameterNumber|skip|Number of cells between flowlines|None|None|7
6+
ParameterNumber|bound|Maximum number of segments per flowline|None|None|1609
97
ParameterBoolean|-u|Compute upslope flowlines instead of default downhill flowlines|False
108
ParameterBoolean|-3|3-D lengths instead of 2-D|False
119
*ParameterBoolean|-m|Use less memory, at a performance penalty|False
12-
OutputRaster|flowline|Flow line
10+
OutputVector|flowline|Flow line
1311
OutputRaster|flowlength|Flow path length
1412
OutputRaster|flowaccumulation|Flow accumulation

0 commit comments

Comments
 (0)