[GRASS-SVN] r56256 - in grass-addons/grass7/raster: . r.shalstab

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 15 01:11:12 PDT 2013


Author: kikapu
Date: 2013-05-15 01:11:11 -0700 (Wed, 15 May 2013)
New Revision: 56256

Added:
   grass-addons/grass7/raster/r.shalstab/
   grass-addons/grass7/raster/r.shalstab/Makefile
   grass-addons/grass7/raster/r.shalstab/r.shalstab.html
   grass-addons/grass7/raster/r.shalstab/r.shalstab.py
Log:
Some useful comment

Added: grass-addons/grass7/raster/r.shalstab/Makefile
===================================================================
--- grass-addons/grass7/raster/r.shalstab/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.shalstab/Makefile	2013-05-15 08:11:11 UTC (rev 56256)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+   
+PGM = r.shalstab
+   
+include $(MODULE_TOPDIR)/include/Make/Script.make
+   
+default: script

Added: grass-addons/grass7/raster/r.shalstab/r.shalstab.html
===================================================================
--- grass-addons/grass7/raster/r.shalstab/r.shalstab.html	                        (rev 0)
+++ grass-addons/grass7/raster/r.shalstab/r.shalstab.html	2013-05-15 08:11:11 UTC (rev 56256)
@@ -0,0 +1,36 @@
+<h1>DESCRIPTION</h1>
+<div>R.shalstab</div>
+<div>This command allows to apply the algorithm developed by Montgomery and Dietrich (1994) in GRASS GIS. According to these authors, the models associate the theories of infinite slope, where the strength of soil share at the discretion of rupture of Mohr Coulomb, with the hydrological model O'Loughlin (1986), resulting in equation.
+Requested input and output.
+The command requires some input:
+<ul><li>DEM a digital terrain model of the study area;</li>
+<li>Raster map or single value for soil cohesion (N/m^2);</li>
+<li>Raster map or single value for soil friction angle (°);</li>
+<li>Raster map or single value for soil density (kg/m^3);</li>
+<li>Raster map or single value for vertical thickness of soil (m);</li>
+<li>Raster map or single value for hydraulic conductivity k (m/h);</li>
+<li>Raster map or single value for root cohesion (N/m^2); (default = 0)</li>
+<li>Raster map or single value for wet soil density (kg/m^3). (default = 2100)</li>
+</ul>
+The output are:
+<ul>A landslide susceptibility map (value range from 1 to 7):</ul>
+<ul>
+<li>1 Unconditionally Unstable</li>
+<li>2 0-50 mm/day</li>
+<li>3 0-100 mm/day</li>
+<li>4 100-200 mm/day</li>
+<li>5 200-400 mm/day</li>
+<li>6 400-1000 mm/day</li>
+<li>7 Stable</li>
+</ul>
+<ul>A map for of critical rainfall map (mm/day)
+</ul>
+</div>
+<h1>AUTHORS</h1>
+<div>
+Andrea Filipello, University of Turin, Italy mail</div>
+<div>Daniele Strigaro, University of Milan, Italy mail
+</div>
+<h1>REFERENCES</h1>
+<div>Montgomery, D. R. and Dietrich, W. E.: A physically based model for the topographic control of shallow landsliding,Water Resour. Res., 30, 1153–1171, 1994.</div>
+

Added: grass-addons/grass7/raster/r.shalstab/r.shalstab.py
===================================================================
--- grass-addons/grass7/raster/r.shalstab/r.shalstab.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.shalstab/r.shalstab.py	2013-05-15 08:11:11 UTC (rev 56256)
@@ -0,0 +1,187 @@
+#!/usr/bin/env python
+
+###########################################################################################
+#
+# MODULE:      r.shalstab
+# VERSION:     0.1 Beta
+# AUTHOR(S):   Andrea Filipello & Daniele Strigaro
+# PURPOSE:     A model based on the algorithm developet by Montgomery and Dietrich (1994)
+# COPYRIGHT:   (C) 2013 by Andrea Filipello & Daniele Strigaro
+#              andrea.filipello at gmail.com; daniele.strigaro at gmail.com
+#
+#              This program is free software under the GNU General Public
+#              License (>=v2). Read the file COPYING that comes with GRASS
+#              for details.
+#
+###########################################################################################
+
+#%module
+#%  description: A model for shallow landslide susceptibility
+#%  keywords: raster, critical rainfall, landslide
+#%end
+#%option
+#%  key: dem
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: dem
+#%  description: Name of dem 
+#%  required: yes
+#%end
+#%option
+#%  key: phy
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: phy
+#%  description: Soil friction angle (angle)
+#%  required: yes
+#%end
+#%option
+#%  key: c_soil
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: c_soil
+#%  description: Soil cohesion (N/m^2)
+#%  required: yes
+#%end
+#%option
+#%  key: root
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: root
+#%  description: Root cohesion k (N/m^2)
+#%  required: no
+#%end
+#%option
+#%  key: gamma
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: gamma
+#%  description: Soil density(angle)
+#%  required: yes
+#%end
+#%option
+#%  key: z
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: z
+#%  description: Vertical thickness of soil (m),
+#%  required: yes
+#%end
+#%option
+#%  key: k
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: k
+#%  description: hydraulic conductivity (m/h)
+#%  required: yes
+#%end
+#%option
+#%  key: gamma_wet
+#%  type: string
+#%  gisprompt: old,raster,raster
+#%  key_desc: gamma_wet
+#%  description: Wet soil density (kg/m^3); default: 2100
+#%  required: no
+#%end
+################################################################################################
+# output 
+################################################################################################
+#%option
+#% key: susceptibility
+#% type: string
+#% gisprompt: new,cell,raster
+#% key_desc: susceptibility
+#% description: Output: name of landslide susceptibility map (from 1 to 7)
+#% required : yes
+#%end
+#%option
+#% key: critic_rain
+#% type: string
+#% gisprompt: new,cell,raster
+#% key_desc: critical rain
+#% description: Output: name of critical rainfall map (mm/day)
+#% required : yes
+#%END
+
+import sys
+import os 
+
+try:
+    import grass.script as grass
+except:
+    try:
+	    from grass.script import core as grass
+    except:
+        sys.exit( "grass.script can't be imported.")
+
+if not os.environ.has_key("GISBASE"):
+    print "You must be in GRASS GIS to run this program."
+    sys.exit(1)
+def main():
+	r_elevation = options['dem'].split('@')[0] 
+	mapname = options['dem'].replace("@"," ")
+	mapname = mapname.split()
+	mapname[0] = mapname[0].replace(".","_")
+	c_soil = options['c_soil']
+	phy = options['phy']
+	gamma = options['gamma']
+	gamma_wet = options['gamma_wet']
+	z = options['z']
+	#b = options['b']
+	k = options['k']
+	root = options['root']
+	susceptibility = options['susceptibility']
+	critic_rain = options['critic_rain']
+	if root == '':
+		root = 0
+	if gamma_wet == '':
+		gamma_wet = 2100
+	#calcola slope 
+	# bash r.slope.aspect elevation=$dem slope=slopes --o format=degrees prec=float min_slp_allowed=0.0
+	grass.run_command('r.slope.aspect', elevation = r_elevation, slope = 'slopes', min_slp_allowed = 0.0, overwrite = 'True') #format = 'degrees', precision = float, 
+	# Calcolo soil transmissivity T (m^2/day)
+	# bash r.mapcalc "T=$k*24*$z*cos(slopes)"
+	grass.mapcalc("T=$k*24*$z*cos(slopes)",
+				k = k,
+				z = z)
+	# Calcolo coesione (dimensionless)
+	#r.mapcalc "C=($root+$c_soil)/($z*cos(slopes)*9.81*$gamma_wet)"
+	grass.mapcalc("C=($root+$c_soil)/($z*cos(slopes)*9.81*$gamma_wet)",
+				root = root,
+				c_soil = c_soil,
+				z = z,
+				gamma_wet = gamma_wet)
+	# Calcolo contribution area
+	# bash r.watershed -f elev=$dem accum=rwater.accum
+	grass.run_command('r.watershed', elevation = r_elevation, accumulation = 'accum')
+	# bash r.mapcalc "A=rwater.accum*((ewres()+nsres())/2)*((ewres()+nsres())/2)"
+	grass.mapcalc("A=accum*((ewres()+nsres())/2)*((ewres()+nsres())/2)")
+	# Calcolo 1(m/day)
+	# basc r.mapcalc "i_crit_m=T*sin(slopes)*$b/A*($gamma/1000*(1-(1-C/(sin(slopes)*cos(slopes)))*tan(slopes)/tan($phy)))"
+	grass.mapcalc("i_crit_m=T*sin(slopes)*((ewres()+nsres())/2)/A*($gamma/1000*(1-(1-C/(sin(slopes)*cos(slopes)))*tan(slopes)/tan($phy)))",
+				phy = phy,
+				gamma = gamma)
+	# Calcolo pioggia critica (mm/ora) e riclassifico
+	# bash r.mapcalc "i_cri_mm=i_crit_m*24000"
+	grass.mapcalc("i_cri_mm=i_crit_m*24000")
+	reclass_rules = "0 thru 50 = 0\n50 thru 100 = 3\n100 thru 200 = 4\n200 thru 400 = 5\n400 thru 999 = 6"
+	grass.write_command('r.reclass', input = 'i_cri_mm', output = 'i_recl', overwrite = 'True', rules = '-', stdin = reclass_rules)
+	grass.mapcalc("copia_reclass=i_recl+0")
+	grass.run_command('r.null', map = 'copia_reclass', null = 0)
+	# bash r.null map=copia_reclass null=0
+	grass.mapcalc("Stable=if (i_cri_mm>1000, 7, 0)")
+	grass.mapcalc("Unstable=if (i_cri_mm<0, 1, 0)")
+	grass.mapcalc("Icritica=copia_reclass+Unstable+Stable")
+	colors_rules = "1 255:85:255\n2 255:0:0\n3 255:170:0\n4 255:255:0\n5 85:255:0\n6 170:255:255\n7 255:255:255"
+	grass.write_command('r.colors', map = 'Icritica', rules = '-', stdin = colors_rules, quiet=True)
+	# bash r.neighbors input=Icritica method=average size=3 output=I_cri_average
+	grass.run_command('r.neighbors', input = 'Icritica', method = 'average', size = 3, output = 'I_cri_average')
+	# rinomina
+	grass.run_command('g.rename', rast = ("I_cri_average", susceptibility))
+	grass.run_command('g.rename', rast = ("i_cri_mm", critic_rain))
+	# Rimuovi
+	grass.run_command('g.remove',rast=("A","copia_reclass","i_crit_m","i_recl","accum","slopes","Stable","T","Unstable","C"))
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    sys.exit(main())



More information about the grass-commit mailing list