[GRASS-SVN] r67383 - grass-addons/grass7/raster/r.subdayprecip.design

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 26 05:08:17 PST 2015


Author: martinl
Date: 2015-12-26 05:08:16 -0800 (Sat, 26 Dec 2015)
New Revision: 67383

Modified:
   grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.html
   grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.py
Log:
r.subdayprecip.design: process very small areas with v.what.rast

Modified: grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.html
===================================================================
--- grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.html	2015-12-26 12:55:08 UTC (rev 67382)
+++ grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.html	2015-12-26 13:08:16 UTC (rev 67383)
@@ -51,15 +51,6 @@
 r.subdayprecip.design map=basin raster=H_002,H_005,H_010,H_020 rainlength=60
 </pre></div>    
 
-<h2>KNOWN ISSUES</h2>
-
-<ul>
-  <li>NULL values are uploaded for very small areas (smaller that
-  computational region resolution),
-  see <a href="https://trac.osgeo.org/grass/ticket/2768">related bug
-      report</a></li>
-</ul>
-
 <h2>REFERENCES</h2>
 
 <ul>

Modified: grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.py
===================================================================
--- grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.py	2015-12-26 12:55:08 UTC (rev 67382)
+++ grass-addons/grass7/raster/r.subdayprecip.design/r.subdayprecip.design.py	2015-12-26 13:08:16 UTC (rev 67383)
@@ -151,13 +151,21 @@
         if vinfo['areas'] > 0:
             Module('v.rast.stats', flags='c', map=opt['map'], raster=rast,
                    column_prefix=name, method='average', quiet=True)
+            # handle NULL values (areas smaller than raster resolution)
+            null_values = Module('v.db.select', map=opt['map'], columns='cat', flags='c',
+                                 where="{}_average is NULL".format(name), stdout_=grass.PIPE)
+            cats = null_values.outputs.stdout.splitlines()
+            if len(cats) > 0:
+                grass.warning(_("Input vector map <{}> contains very small areas (smaller than "
+                                "raster resolution). These areas will be proceeded by querying "
+                                "single raster cell.").format(opt['map']))
+                Module('v.what.rast', map=opt['map'], raster=rast, type='centroid',
+                       column='{}_average'.format(name), where="{}_average is NULL".format(name),
+                       quiet=True)
         else: # -> points
             Module('v.what.rast', map=opt['map'], raster=rast,
                    column='{}_average'.format(name), quiet=True)
-        # TODO: handle null values (very small areas)
-        # Module('v.what.rast', map=opt['map'], raster=rast, type='centroid',
-        #       column='{}_average'.format(name),
-        #       where='{}_average is NULL'.format(name))
+            
         
         # add column to the attribute table if not exists
         rl = float(opt['rainlength'])



More information about the grass-commit mailing list