[GRASS-SVN] r56855 - grass-addons/grass6/raster/r.hazard.flood
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 20 19:55:25 PDT 2013
Author: hamish
Date: 2013-06-20 19:55:25 -0700 (Thu, 20 Jun 2013)
New Revision: 56855
Modified:
grass-addons/grass6/raster/r.hazard.flood/r.hazard.flood.py
Log:
sync with grass7 version
Modified: grass-addons/grass6/raster/r.hazard.flood/r.hazard.flood.py
===================================================================
--- grass-addons/grass6/raster/r.hazard.flood/r.hazard.flood.py 2013-06-21 02:47:05 UTC (rev 56854)
+++ grass-addons/grass6/raster/r.hazard.flood/r.hazard.flood.py 2013-06-21 02:55:25 UTC (rev 56855)
@@ -13,6 +13,7 @@
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
+# TODO: add overwrite check for resulting flood/mti maps
#############################################################################
#%module
@@ -59,6 +60,13 @@
sys.exit(1)
def main():
+
+ #### check if we have the r.area addon
+ if not grass.find_program('r.area', ['help']):
+ grass.fatal(_("The 'r.area' module was not found, install it first:") +
+ "\n" +
+ "g.extension r.area")
+
r_elevation = options['map'].split('@')[0]
mapname = options['map'].replace("@"," ")
mapname = mapname.split()
@@ -66,11 +74,6 @@
r_flood_map = options['flood']
r_mti = options['mti']
- #FIXME: find_program() not working for modules
- ## check if we have the r.area addon
- #if not grass.find_program('r.area'):
- # grass.fatal(_("The r.area module is required, please install it from Addons first"))
-
# Detect cellsize of the DEM
info_region = grass.read_command('g.region', flags = 'p', rast = '%s' % (r_elevation))
dict_region = grass.parse_key_val(info_region, ':')
@@ -94,7 +97,7 @@
grass.message("MTI threshold : %s " % mti_th)
# MTI map
- grass.message("Calculating mti raster map.. ")
+ grass.message("Calculating MTI raster map.. ")
grass.mapcalc("$r_mti = log((exp((($rast1+1)*$resolution) , $n)) / (tan($rast2+0.001)))",
r_mti = r_mti,
rast1 = 'r_accumulation',
@@ -104,8 +107,8 @@
# Cleaning up
grass.message("Cleaning up.. ")
- grass.run_command('g.remove', rast = 'r_accumulation')
- grass.run_command('g.remove', rast = 'r_slope')
+ grass.run_command('g.remove', quiet = True, rast = 'r_accumulation')
+ grass.run_command('g.remove', quiet = True, rast = 'r_slope')
# flood map
grass.message("Calculating flood raster map.. ")
More information about the grass-commit
mailing list