[GRASS-SVN] r42772 - grass-addons/LandDyn/r.catchment.py

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 12 15:57:53 EDT 2010


Author: isaacullah
Date: 2010-07-12 19:57:53 +0000 (Mon, 12 Jul 2010)
New Revision: 42772

Modified:
   grass-addons/LandDyn/r.catchment.py/r.catchment.py
Log:
Added small code snippet to make sure that the grass python scripting libs can be found even if the module is called by an external process (e.g. our ABM model). Added -A and -i flags to an r.stats call to make sure key values comeout as a single integer value rather than a range of values.

Modified: grass-addons/LandDyn/r.catchment.py/r.catchment.py
===================================================================
--- grass-addons/LandDyn/r.catchment.py/r.catchment.py	2010-07-12 19:53:00 UTC (rev 42771)
+++ grass-addons/LandDyn/r.catchment.py/r.catchment.py	2010-07-12 19:57:53 UTC (rev 42772)
@@ -137,6 +137,8 @@
 import os
 import subprocess
 import tempfile
+grass_install_tree = os.getenv('GISBASE')
+sys.path.append(grass_install_tree + os.sep + 'etc' + os.sep + 'python')
 import grass.script as grass
 # first define a useful custom method 
 
@@ -203,7 +205,7 @@
             grass.message('\n\nCalculating list of possible catchment configurations\n')
             grass.message("cost value | catchment area")
             areadict = {}
-            out2dictnum('r.stats -a -n input=' + cost + ' fs=, nv=* nsteps=255', ',', areadict)
+            out2dictnum('r.stats -Aani input=' + cost + ' fs=, nv=* nsteps=255', ',', areadict)
             testarea = 0
             #start the loop, and list the values
             for key in sorted(areadict):



More information about the grass-commit mailing list