[GRASS-SVN] r46130 - grass-addons/raster/r.hazard.flood

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 28 11:30:45 EDT 2011


Author: madi
Date: 2011-04-28 08:30:45 -0700 (Thu, 28 Apr 2011)
New Revision: 46130

Modified:
   grass-addons/raster/r.hazard.flood/r.hazard.flood.py
Log:
Removing small areas bug fixed

Modified: grass-addons/raster/r.hazard.flood/r.hazard.flood.py
===================================================================
--- grass-addons/raster/r.hazard.flood/r.hazard.flood.py	2011-04-28 12:27:22 UTC (rev 46129)
+++ grass-addons/raster/r.hazard.flood/r.hazard.flood.py	2011-04-28 15:30:45 UTC (rev 46130)
@@ -92,18 +92,18 @@
 
     # flood map
     print 'Calculating flood raster map.. '
-    grass.mapcalc("r_flood = if($rast1 >  $mti_th, 1, null())", rast1 = r_mti, mti_th = mti_th)
+    grass.mapcalc("r_flood = if($rast1 >  $mti_th, 1, 0)", rast1 = r_mti, mti_th = mti_th)
 
-    ## # Attempt to eliminate isolated pixels (doesn't seem to work properly)
+    ## # Deleting isolated pixels 
     # Recategorizes data in a raster map by grouping cells that form physically discrete areas into unique categories (preliminar to r.area)
     print 'Running r.clump..'
-    grass.run_command('r.clump', input = 'r_flood', output = 'r_clump')
+    grass.run_command('r.clump', input = 'r_flood', output = 'r_clump', flags = '-o')
     
     # Delete areas of less than a threshold of cells (corresponding to 1 square kilometer)
     # Calculating threshold
-    th = 1000000 / resolution**2
-    print 'Deleting areas of less than ', th, ' cells.. '
-    grass.run_command('r.area', input = 'r_clump', output = 'r_flood_th', treshold = 'th')
+    th = int(1000000 / resolution**2)
+    print 'Deleting areas of less than ', th, ' cells.. '   
+    grass.run_command('r.area', input = 'r_clump', output = 'r_flood_th', treshold = th, flags = 'b')
 
     # New flood map
     grass.mapcalc("$r_flood_map = $rast1 / $rast1", r_flood_map = r_flood_map, rast1 = 'r_flood_th')



More information about the grass-commit mailing list