[GRASS-SVN] r66326 - grass/trunk/scripts/v.what.strds
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 25 03:32:20 PDT 2015
Author: lucadelu
Date: 2015-09-25 03:32:20 -0700 (Fri, 25 Sep 2015)
New Revision: 66326
Modified:
grass/trunk/scripts/v.what.strds/v.what.strds.py
Log:
add capabilities to add columns and values in the input vector file
Modified: grass/trunk/scripts/v.what.strds/v.what.strds.py
===================================================================
--- grass/trunk/scripts/v.what.strds/v.what.strds.py 2015-09-25 09:19:06 UTC (rev 66325)
+++ grass/trunk/scripts/v.what.strds/v.what.strds.py 2015-09-25 10:32:20 UTC (rev 66326)
@@ -32,6 +32,7 @@
#%end
#%option G_OPT_V_OUTPUT
+#% required: no
#%end
#%option G_OPT_DB_WHERE
@@ -41,6 +42,12 @@
#% key: t_where
#%end
+#%flag
+#% key: u
+#% label: Update input vector
+#% description: Instead create a new vector update the input vector with the values
+#%end
+
import grass.script as grass
import grass.temporal as tgis
from grass.pygrass.utils import copy as gcopy
@@ -87,6 +94,13 @@
where = options["where"]
tempwhere = options["t_where"]
+ if output and flags['u']:
+ grass.fatal(_("Cannot combine 'output' option and 'u' flag"))
+ elif not output and not flags['u']:
+ grass.fatal(_("'output' option or 'u' flag must be given"))
+ elif not output and flags['u']:
+ grass.warning(_("Vector {name} will be update...").format(name=input))
+
if where == "" or where == " " or where == "\n":
where = None
@@ -172,7 +186,10 @@
samples.append(s)
# Get the layer and database connections of the input vector
- gcopy(input, output, 'vect')
+ if output:
+ gcopy(input, output, 'vect')
+ else:
+ output = input
msgr = Messenger()
perc_curr = 0
More information about the grass-commit
mailing list