[GRASS-SVN] r73666 - grass/trunk/scripts/v.rast.stats
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 12 17:57:08 PST 2018
Author: veroandreo
Date: 2018-11-12 17:57:07 -0800 (Mon, 12 Nov 2018)
New Revision: 73666
Modified:
grass/trunk/scripts/v.rast.stats/v.rast.stats.py
Log:
v.rast.stats: add where option (thanks Markus Metz)
Modified: grass/trunk/scripts/v.rast.stats/v.rast.stats.py
===================================================================
--- grass/trunk/scripts/v.rast.stats/v.rast.stats.py 2018-11-12 09:32:58 UTC (rev 73665)
+++ grass/trunk/scripts/v.rast.stats/v.rast.stats.py 2018-11-13 01:57:07 UTC (rev 73666)
@@ -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
@@ -104,6 +106,7 @@
colprefixes = options['column_prefix'].split(',')
vector = options['map']
layer = options['layer']
+ where = options['where']
percentile = options['percentile']
basecols = options['method'].split(',')
@@ -155,13 +158,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