[GRASS-SVN] r60426 - grass-addons/grass7/raster/r.northerness.easterness
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 22 16:39:37 PDT 2014
Author: hellik
Date: 2014-05-22 16:39:37 -0700 (Thu, 22 May 2014)
New Revision: 60426
Added:
grass-addons/grass7/raster/r.northerness.easterness/Makefile
grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.html
grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py
Log:
add addon script grass7/raster/r.northerness.easterness: step 2
Added: grass-addons/grass7/raster/r.northerness.easterness/Makefile
===================================================================
--- grass-addons/grass7/raster/r.northerness.easterness/Makefile (rev 0)
+++ grass-addons/grass7/raster/r.northerness.easterness/Makefile 2014-05-22 23:39:37 UTC (rev 60426)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.northerness.easterness
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Added: grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.html
===================================================================
--- grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.html (rev 0)
+++ grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.html 2014-05-22 23:39:37 UTC (rev 60426)
@@ -0,0 +1,61 @@
+<h2>DESCRIPTION</h2>
+
+<p>
+<em>r.northerness.easterness</em> calculates northerness, easterness and
+the interaction between northerness and slope (northerness*slope). The
+user must specify the input <b>elevation raster</b> map.
+</p>
+
+<h2>NOTES</h2>
+
+<p>
+As aspect is a circular land-surface parameter, in ecology a sine or
+cosine transformation is often used to obtain a continuous gradient,
+stressing the north-south or east-west gradient (northness or eastness).
+</p>
+
+<p>
+The GRASS GIS default aspect angles (cartesian) are converted to compass
+angles.
+</p>
+
+<p>
+Calculated raster maps are:
+</p>
+
+<ul>
+ <li>northerness: <em>cos(aspect)</em></li>
+ <li>easterness: <em>sin(aspect)</em></li>
+ <li>interaction between northerness and slope: <em>northerness*slope</em></li>
+</ul>
+
+<p>
+The color of these raster maps are set to <em>grey</em>.
+</p>
+
+<h2>EXAMPLE</h2>
+
+<div class="code">
+ <pre>
+ # align region to DEM and habitat vector
+ g.region -a rast=DEM align=DEM
+
+ # run <em>r.northerness.easterness</em>
+ r.northerness.easterness elevation=DEM
+ </pre>
+</div>
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="r.mapcalc.html">r.mapcalc</a>,
+<a href="r.slope.aspect.html">r.slope.aspect</a>
+</em>
+
+<h2>AUTHOR</h2>
+
+Helmut Kudrnovsky
+
+<p>
+<i>Last changed: $Date: 2014-05-13 23:17:32 +0200 (Di, 13 Mai 2014) $</i>
+</p>
\ No newline at end of file
Added: grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py
===================================================================
--- grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py (rev 0)
+++ grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py 2014-05-22 23:39:37 UTC (rev 60426)
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+
+"""
+MODULE: r.northerness.easterness
+
+AUTHOR(S): Helmut Kudrnovsky <alectoria AT gmx at>
+
+PURPOSE: Calculates northerness and easterness of a DEM
+
+COPYRIGHT: (C) 2014 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+"""
+
+#%module
+#% description: DEM derived characteristics of habitats
+#% keywords: raster
+#% keywords: terrain
+#% keywords: aspect
+#% keywords: slope
+#% keywords: sun
+#%end
+
+#%option G_OPT_R_ELEV
+#% key: elevation
+#% description: Name of elevation raster map
+#% required: yes
+#%end
+
+import sys
+import os
+import grass.script as grass
+import math
+
+if not os.environ.has_key("GISBASE"):
+ grass.message( "You must be in GRASS GIS to run this program." )
+ sys.exit(1)
+
+def main():
+ r_elevation = options['elevation'].split('@')[0]
+ r_aspect = r_elevation+'_aspect'
+ r_slope = r_elevation+'_slope'
+ r_aspect_compass = r_elevation+'_aspect_compass'
+ r_northerness = r_elevation+'_northerness'
+ r_easterness = r_elevation+'_easterness'
+ r_northerness_slope = r_elevation+'_northerness_slope'
+
+
+ # Calculation of slope and aspect maps
+ grass.message( "----" )
+ grass.message( "Calculation of slope and aspect by r.slope.aspect ..." )
+ grass.run_command('r.slope.aspect', elevation = r_elevation,
+ slope = r_slope,
+ aspect = r_aspect,
+ overwrite = True)
+ grass.message( "Calculation of slope and aspect done." )
+ grass.message( "----" )
+
+ # Correction aspect angles from cartesian (GRASS default) to compass angles
+ # if((A < 90, 90-A, 360+90-A))
+ grass.message( "Convert aspect angles from cartesian (GRASS GIS default) to compass angles ..." )
+ grass.mapcalc("$outmap = if( $cartesian == 0, 0, if( $cartesian < 90, 90 - $cartesian, 360 + 90 - $cartesian) )",
+ outmap = r_aspect_compass,
+ cartesian = r_aspect)
+ grass.message( "..." )
+ grass.run_command('r.info', map = r_aspect_compass)
+ grass.message( "Aspect conversion done." )
+ grass.message( "----" )
+
+ # Calculation of northerness
+ grass.message( "Calculate northerness ..." )
+ grass.mapcalc("$outmap = cos( $compass )",
+ outmap = r_northerness,
+ compass = r_aspect_compass)
+ grass.message( "..." )
+ grass.run_command('r.info', map = r_northerness)
+ grass.message( "Northerness calculation done." )
+ grass.message( "----" )
+
+ # Calculation of easterness
+ grass.message( "Calculate easterness ..." )
+ grass.mapcalc("$outmap = sin( $compass )",
+ outmap = r_easterness,
+ compass = r_aspect_compass)
+ grass.message( "..." )
+ grass.run_command('r.info', map = r_easterness)
+ grass.message( "Easterness calculation done." )
+ grass.message( "----" )
+
+ # Calculation of northerness*slope
+ grass.message( "Calculate northerness*slope ..." )
+ grass.mapcalc("$outmap = $northerness * $slope",
+ outmap = r_northerness_slope,
+ northerness = r_northerness,
+ slope = r_slope)
+ grass.message( "..." )
+ grass.run_command('r.info', map = r_northerness_slope)
+ grass.message( "Northerness*slope calculation done." )
+ grass.message( "----" )
+
+ # adjust color
+ grass.message( "Adjust color ..." )
+ grass.run_command('r.colors', map = r_northerness,
+ color = 'grey')
+ grass.run_command('r.colors', map = r_easterness,
+ color = 'grey')
+ grass.run_command('r.colors', map = r_northerness_slope,
+ color = 'grey')
+
+ grass.message( "Color adjustment done." )
+ grass.message( "----" )
+
+ # clean up some temporay files and maps
+ grass.message( "Some clean up ..." )
+ grass.run_command("g.remove", rast = r_slope,
+ quiet = True)
+ grass.run_command("g.remove", rast = r_aspect,
+ quiet = True)
+ grass.run_command("g.remove", rast = r_aspect_compass,
+ quiet = True)
+ grass.message( "Clean up done." )
+ grass.message( "----" )
+
+ # r.northerness.easterness done!
+ grass.message( "r.northerness.easterness done!" )
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ sys.exit(main())
More information about the grass-commit
mailing list