[GRASS-SVN] r36808 - in grass-addons/raster: . r.surf.volcano

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 20 04:59:05 EDT 2009


Author: hamish
Date: 2009-04-20 04:59:05 -0400 (Mon, 20 Apr 2009)
New Revision: 36808

Added:
   grass-addons/raster/r.surf.volcano/
   grass-addons/raster/r.surf.volcano/Makefile
   grass-addons/raster/r.surf.volcano/description.html
   grass-addons/raster/r.surf.volcano/r.surf.volcano
Log:
new module to create an artificial surface

Added: grass-addons/raster/r.surf.volcano/Makefile
===================================================================
--- grass-addons/raster/r.surf.volcano/Makefile	                        (rev 0)
+++ grass-addons/raster/r.surf.volcano/Makefile	2009-04-20 08:59:05 UTC (rev 36808)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.surf.volcano
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

Added: grass-addons/raster/r.surf.volcano/description.html
===================================================================
--- grass-addons/raster/r.surf.volcano/description.html	                        (rev 0)
+++ grass-addons/raster/r.surf.volcano/description.html	2009-04-20 08:59:05 UTC (rev 36808)
@@ -0,0 +1,53 @@
+<H2>DESCRIPTION</H2>
+
+
+<EM>r.surf.volcano</EM> creates an artifical surface resembling a seamount
+or volcano. The user can alter the size and shape of the mountain and
+optionally roughen its surface.
+
+
+<H2>NOTES</H2>
+
+The friction of distance controls the shape of the mountain.
+Higher values generate steeper slopes.
+<P>
+The surface roughness factor controls the fixed standard deviation
+distance (<b>sigma</b>) used in the Gaussian random number generator.
+It is only used when the <B>-r</B> roughen surface flag is turned on.
+A value closer to zero makes a smoother surface, a higher value makes
+a rougher surface.
+<P>
+It is possible to set a negative value for the <B>peak</B> in order
+to create a pit.
+
+
+<H2>EXAMPLE</H2>
+
+<div class="code"><pre>
+r.surf.volcano -r output=seamount
+
+r.colors seamount color=sepia -e
+d.rast seamount
+
+r.colors seamount color=srtm
+nviz seamount
+</pre></div>
+
+
+<H2>SEE ALSO</H2>
+
+<EM>
+<A HREF="r.surf.fractal.html">r.surf.fractal</A><BR>
+<A HREF="r.surf.gauss.html">r.surf.gauss</A><BR>
+<A HREF="r.surf.random.html">r.surf.random</A>
+</EM>
+
+<H2>AUTHOR</H2>
+
+Hamish Bowman<BR>
+<i>Dept. Marine Science<BR>
+University of Otago<BT>
+Dunedin, New Zealand</i>
+
+<p>
+<i>Last changed: $Date$</i>


Property changes on: grass-addons/raster/r.surf.volcano/description.html
___________________________________________________________________
Name: svn:keywords
   + Date

Added: grass-addons/raster/r.surf.volcano/r.surf.volcano
===================================================================
--- grass-addons/raster/r.surf.volcano/r.surf.volcano	                        (rev 0)
+++ grass-addons/raster/r.surf.volcano/r.surf.volcano	2009-04-20 08:59:05 UTC (rev 36808)
@@ -0,0 +1,143 @@
+#!/bin/sh
+############################################################################
+#
+# MODULE:       r.surf.volcano
+# AUTHOR:       M. Hamish Bowman, Dept. Marine Science, University of Otago
+#			Dunedin, New Zealand
+# PURPOSE:      Create an artificial surface resembling a seamount or cone volcano
+#
+# COPYRIGHT:    (c) 2009 Hamish Bowman, and 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.
+#
+#		This program is distributed in the hope that it will be useful,
+#		but WITHOUT ANY WARRANTY; without even the implied warranty of
+#		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#		GNU General Public License for more details.
+#
+#############################################################################
+
+#%Module
+#% description: Creates an artificial surface resembling a seamount or cone volcano.
+#% keywords: raster
+#%End
+#%Option
+#% key: output
+#% type: string
+#% required: yes
+#% key_desc: name
+#% description: Name for output raster map
+#% gisprompt: new,cell,raster
+#%End
+#%Option
+#% key: peak
+#% type: double
+#% required: no
+#% description: Height of cone
+#% answer: 1000
+#%End
+#%Option
+#% key: friction
+#% type: integer
+#% required: no
+#% options: 1-25
+#% description: Friction of distance, (the 'n' in 1/d^n)
+#% answer: 6
+#%End
+#%Option
+#% key: sigma
+#% type: double
+#% required: no
+#% description: Surface roughness factor
+#% answer: 1.0
+#%End
+#%Flag
+#% key: r
+#% description: Roughen the surface
+#%End
+## TODO
+##%Flag
+##% key: n
+##% description: Use (d^n)*log(d) instead of 1/(d^n) for radial basis function
+##%End
+
+if [ -z "$GISBASE" ] ; then
+    echo "You must be in GRASS GIS to run this program." 1>&2
+    exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+    exec g.parser "$0" "$@"
+fi
+
+FRICTION="$GIS_OPT_FRICTION"
+PEAK="$GIS_OPT_PEAK"
+SIGMA="$GIS_OPT_SIGMA"
+
+
+# test for overwrite as r.mapcalc doesn't
+eval `g.findfile element=cell file="$GIS_OPT_OUTPUT" mapset=.`
+if [ -n "$name" ] ; then
+   # map already exists
+   if [ -z "$GRASS_OVERWRITE" ] || [ "$GRASS_OVERWRITE" -ne 1 ] ; then
+      G_message -e "option <output>: <$GIS_OPT_OUTPUT> exists."
+      exit 1
+   fi
+fi
+
+
+g.message -v "Finding cost from center of current region ..."
+eval `g.region -gc`
+r.mapcalc "volc.dist_units.$$ = \
+   sqrt( (x() - $center_easting)^2 + (y() - $center_northing)^2 )"
+
+
+g.message -v "Normalizing cost map with 1 in the center and 0 at outer edge ..."
+eval `r.info -r "volc.dist_units.$$"`
+r.mapcalc "volc.dist_norm.$$ = ($max - volc.dist_units.$$) / $max"
+
+
+g.message -v "Creating IDW surface ..."
+r.mapcalc "volc.surf.$$ = $PEAK * pow( volc.dist_norm.$$, $FRICTION )"
+
+
+if [ "$GIS_FLAG_R" -eq 0 ] ; then
+   g.rename rast="volc.surf.$$,$GIS_OPT_OUTPUT" --quiet
+   g.remove rast="volc.dist_units.$$,volc.dist_norm.$$" --quiet
+else
+   # roughen it up a bit
+   g.message -v "Creating random Gaussian mottle ..."
+   r.surf.gauss out="volc.surf_gauss.$$" sigma="$SIGMA"
+
+   g.message -v "Applying Gaussian mottle ..."
+   r.mapcalc "volc.surf_rough.$$ = \
+	volc.surf.$$ + (volc.surf_gauss.$$ * $PEAK/400 )"
+
+   g.rename rast="volc.surf_rough.$$,$GIS_OPT_OUTPUT" --quiet
+   g.remove rast="volc.dist_units.$$,volc.dist_norm.$$,volc.surf_gauss.$$" --quiet
+
+fi
+
+# test for overwrite as r.mapcalc doesn't
+eval `g.findfile element=cell file="$GIS_OPT_OUTPUT" mapset=.`
+if [ -z "$name" ] ; then
+   G_message -e "Surface creation failed"
+   exit 1
+fi
+
+# write metadata
+r.support map="$GIS_OPT_OUTPUT" \
+    description="generated by r.surf.volcano" \
+    source1="Peak height = $PEAK" \
+    source2="Friction of distance = $FRICTION" \
+    title="Artificial surface resembling a seamount or cone volcano"
+
+if [ "$GIS_FLAG_R" -eq 1 ] ; then
+   r.support map="$GIS_OPT_OUTPUT" \
+     history="Surface roughness used a Gaussian deviate with sigma of $SIGMA."
+fi
+
+g.message -v "Done."
+
+exit


Property changes on: grass-addons/raster/r.surf.volcano/r.surf.volcano
___________________________________________________________________
Name: svn:executable
   + *



More information about the grass-commit mailing list