[GRASS-SVN] r73678 - grass/branches/releasebranch_7_6/scripts/v.rast.stats

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 13 15:02:37 PST 2018


Author: veroandreo
Date: 2018-11-13 15:02:37 -0800 (Tue, 13 Nov 2018)
New Revision: 73678

Modified:
   grass/branches/releasebranch_7_6/scripts/v.rast.stats/v.rast.stats.py
Log:
v.rast.stats: add where option (trunk r73666)

Modified: grass/branches/releasebranch_7_6/scripts/v.rast.stats/v.rast.stats.py
===================================================================
--- grass/branches/releasebranch_7_6/scripts/v.rast.stats/v.rast.stats.py	2018-11-13 16:36:50 UTC (rev 73677)
+++ grass/branches/releasebranch_7_6/scripts/v.rast.stats/v.rast.stats.py	2018-11-13 23:02:37 UTC (rev 73678)
@@ -40,6 +40,8 @@
 #%end
 #%option G_OPT_V_FIELD
 #%end
+#%option G_OPT_DB_WHERE
+#%end
 #%option G_OPT_R_INPUTS
 #% key: raster
 #% description: Name of input raster map to calculate statistics from
@@ -103,6 +105,7 @@
     colprefixes = options['column_prefix'].split(',')
     vector = options['map']
     layer = options['layer']
+    where = options['where']
     percentile = options['percentile']
     basecols = options['method'].split(',')
 
@@ -154,13 +157,15 @@
     # prepare base raster for zonal statistics
     try:
         nlines = grass.vector_info_topo(vector)['lines']
+	kwargs = {}
+	if where:
+	    kwargs['where'] = where
         # Create densified lines rather than thin lines
         if flags['d'] and nlines > 0:
-            grass.run_command('v.to.rast', input=vector, layer=layer, output=rastertmp,
-                              use='cat', flags='d', quiet=True)
-        else:
-            grass.run_command('v.to.rast', input=vector, layer=layer, output=rastertmp,
-                              use='cat', quiet=True)
+	    kwargs['flags'] = 'd'
+
+	grass.run_command('v.to.rast', input=vector, layer=layer, output=rastertmp,
+			  use='cat', quiet=True, **kwargs)
     except CalledModuleError:
         grass.fatal(_("An error occurred while converting vector to raster"))
 



More information about the grass-commit mailing list