[GRASS-SVN] r72824 - grass-addons/grass7/raster/r.lfp
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 14 07:03:57 PDT 2018
Author: hcho
Date: 2018-06-14 07:03:57 -0700 (Thu, 14 Jun 2018)
New Revision: 72824
Modified:
grass-addons/grass7/raster/r.lfp/r.lfp.py
Log:
r.lfp: Support layer
Modified: grass-addons/grass7/raster/r.lfp/r.lfp.py
===================================================================
--- grass-addons/grass7/raster/r.lfp/r.lfp.py 2018-06-14 11:45:47 UTC (rev 72823)
+++ grass-addons/grass7/raster/r.lfp/r.lfp.py 2018-06-14 14:03:57 UTC (rev 72824)
@@ -43,6 +43,8 @@
#% label: Name of outlet vector map
#% required: no
#%end
+#%option G_OPT_V_FIELD
+#%end
#%option G_OPT_DB_COLUMN
#% key: outlet_id_column
#% description: Name of longest flow path ID column in outlet map
@@ -80,11 +82,12 @@
id = options["id"]
coords = options["coordinates"]
outlet = options["outlet"]
+ layer = options["layer"]
outletidcol = options["outlet_id_column"]
- calculate_lfp(input, output, idcol, id, coords, outlet, outletidcol)
+ calculate_lfp(input, output, idcol, id, coords, outlet, layer, outletidcol)
-def calculate_lfp(input, output, idcol, id, coords, outlet, outletidcol):
+def calculate_lfp(input, output, idcol, id, coords, outlet, layer, outletidcol):
prefix = "r_lfp_%d_" % os.getpid()
if id:
@@ -104,7 +107,8 @@
# append outlet points to coordinates
if outlet:
- p = grass.pipe_command("v.report", map=outlet, option="coor")
+ p = grass.pipe_command("v.report", map=outlet, layer=layer,
+ option="coor")
for line in p.stdout:
line = line.rstrip("\n")
if line.startswith("cat|"):
@@ -224,8 +228,8 @@
# calculate the longest flow path in vector format
path = prefix + "path"
try:
- grass.run_command("r.path", input=input, vector_path=path,
- start_points=heads)
+ grass.run_command("r.path", overwrite=True,
+ input=input, vector_path=path, start_points=heads)
except CalledModuleError:
grass.fatal(_("Cannot create the longest flow path vector map"))
More information about the grass-commit
mailing list