[GRASS-SVN] r38697 - grass-addons/raster/r.roughness

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 12 05:50:41 EDT 2009


Author: hamish
Date: 2009-08-12 05:50:40 -0400 (Wed, 12 Aug 2009)
New Revision: 38697

Modified:
   grass-addons/raster/r.roughness/r.roughness.sh
   grass-addons/raster/r.roughness/r.roughness.window.area
   grass-addons/raster/r.roughness/r.roughness.window.vector
   grass-addons/raster/r.roughness/r.roughness.window.vector.html
Log:
quote file names (in case they contain spaces);
fix tempfile cleanup;
use WIND_OVERRIDE instead of actually changing region on disk;
--overwrite not needed in v.surf.rst, it propogates from script;
+svn props


Modified: grass-addons/raster/r.roughness/r.roughness.sh
===================================================================
--- grass-addons/raster/r.roughness/r.roughness.sh	2009-08-12 05:58:31 UTC (rev 38696)
+++ grass-addons/raster/r.roughness/r.roughness.sh	2009-08-12 09:50:40 UTC (rev 38697)
@@ -95,13 +95,10 @@
     exit 1
 fi
 
-# setting environment, so that awk works properly in all languages
+# set environment so that awk works properly in all languages
 unset LC_ALL
 export LC_NUMERIC=C
 
-eval `g.gisenv`
-: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
-LOCATION=$GISDBASE/$LOCATION_NAME/$MAPSET
 
 TMP_ascii="`g.tempfile pid=$$`"
 if [ $? -ne 0 ] || [ -z "${TMP_ascii}" ] ; then
@@ -139,10 +136,13 @@
 #######################################################################
 cleanup() 
 {
-    g.region region=oldregion 
-    rm -f $GISDBASE/$LOCATION_NAME/$MAPSET/windows/oldregion
-    rm -f $TMP ${TMP} TMP_*
-    g.remove vect=TMP_vect > /dev/null
+    eval `g.findfile elem=windows file="tmp_region.$$" | grep '^name='`
+    if [ -n "$name" ] ; then
+	unset WIND_OVERRIDE
+	g.remove region="tmp_region.$$" --quiet
+    fi
+    rm -f "$TMP_ascii"
+    g.remove vect="TMP_vect_$$" --quiet
 }
 
 # what to do in case of user break:
@@ -165,20 +165,22 @@
 maxwest="` g.region -p | grep west | sed -e s/.*:\ *//`"
 maxeast="` g.region -p | grep east | sed -e s/.*:\ *//`"
 
-g.region save=oldregion
+# setup internal region
+g.region save="tmp_region.$$"
+WIND_OVERRIDE="tmp_region.$$"
+export WIND_OVERRIDE
 
-
 ns_dist="`echo $maxnorth $maxsouth |awk '{printf("%f", $1 - $2);}'`"
-ew_dist="`echo $maxeast $maxwest |awk '{printf("%f", $1 - $2);}'`"
-rows="`echo $ns_dist $grid |awk '{printf("%.0f", $1 / $2);}'`"
-cols="`echo $ew_dist $grid |awk '{printf("%.0f", $1 / $2);}'`"
+ew_dist="`echo $maxeast $maxwest | awk '{printf("%f", $1 - $2);}'`"
+rows="`echo $ns_dist $grid | awk '{printf("%.0f", $1 / $2);}'`"
+cols="`echo $ew_dist $grid | awk '{printf("%.0f", $1 / $2);}'`"
 
 ########################################################################
 
 north=$maxnorth
 west=$maxwest
-south="`echo $north $grid |awk '{printf("%f", $1 - $2);}'`"
-east="`echo $west $grid |awk '{printf("%f", $1 + $2);}'`"
+south="`echo $north $grid | awk '{printf("%f", $1 - $2);}'`"
+east="`echo $west $grid | awk '{printf("%f", $1 + $2);}'`"
 
 # number of region
 no_of_region="0"
@@ -202,7 +204,8 @@
         planarea="`r.surf.area input=$elev | grep Current | sed -e s/.*:\ *//`"
         realarea="`r.surf.area input=$elev | grep Estimated | sed -e s/.*:\ *//`"
 
-echo "$coord_x $coord_y $realarea $planarea" | awk '{printf "%d %d %f\n", $1, $2, $3 / $4}'>> $TMP_ascii
+	echo "$coord_x $coord_y $realarea $planarea" | \
+	   awk '{printf "%d %d %f\n", $1, $2, $3 / $4}'>> "$TMP_ascii"
 
         west=$east
         east="`echo $west $grid |awk '{printf("%f", $1 + $2);}'`"
@@ -214,19 +217,25 @@
     done
     
     north=$south
-    south="`echo $north $grid |awk '{printf("%f", $1 - $2);}'`";
+    south="`echo $north $grid |awk '{printf("%f", $1 - $2);}'`"
     
     # go west
     west=$maxwest
-    east="`echo $west $grid |awk '{printf("%f", $1 + $2);}'`";
-done;
+    east="`echo $west $grid |awk '{printf("%f", $1 + $2);}'`"
+done
 
 
+# back to original region
+unset WIND_OVERRIDE
+g.remove region="tmp_region.$$" --quiet
 
-g.region region=oldregion;
-v.in.ascii input=$TMP_ascii output=TMP_vect format=point fs=space skip=0 x=1 y=2 z=3 cat=0 -z;
-v.surf.rst input=TMP_vect layer=0 elev=$ROUGHNESS zmult=1.0 tension=$GIS_OPT_TENSION smooth=$GIS_OPT_SMOOTH --overwrite;
 
+v.in.ascii input="$TMP_ascii" output="TMP_vect_$$" format=point \
+   fs=space skip=0 x=1 y=2 z=3 cat=0 -z
+
+v.surf.rst input="TMP_vect_$$" layer=0 elev="$ROUGHNESS" zmult=1.0 \
+   tension="$GIS_OPT_TENSION" smooth="$GIS_OPT_SMOOTH"
+
 r.colors "$ROUGHNESS" color=rainbow
 
 # record metadata


Property changes on: grass-addons/raster/r.roughness/r.roughness.sh
___________________________________________________________________
Added: svn:mime-type
   + text/x-sh
Added: svn:eol-style
   + native


Property changes on: grass-addons/raster/r.roughness/r.roughness.window.area
___________________________________________________________________
Added: svn:mime-type
   + text/x-sh
Added: svn:eol-style
   + native


Property changes on: grass-addons/raster/r.roughness/r.roughness.window.vector
___________________________________________________________________
Added: svn:mime-type
   + text/x-sh
Added: svn:eol-style
   + native

Modified: grass-addons/raster/r.roughness/r.roughness.window.vector.html
===================================================================
--- grass-addons/raster/r.roughness/r.roughness.window.vector.html	2009-08-12 05:58:31 UTC (rev 38696)
+++ grass-addons/raster/r.roughness/r.roughness.window.vector.html	2009-08-12 09:50:40 UTC (rev 38697)
@@ -43,7 +43,7 @@
 wants to create several map (with different window sizes, for
 instance), it is recommended to create those maps with <span style="font-style: italic;">r.mapcalc</span> and use them as input:<br><br><span style="font-style: italic;">r.mapcalc compass = "if(aspect==0,0,if(aspect &lt; 90, 90-aspect, 360+90-aspect))"</span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">r.mapcalc colatitude = "90 -&nbsp;slope"</span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">r.mapcalc xcos = "sin(colatitude)*cos(compass)"</span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">r.mapcalc ycos = "sin(colatitude)*sin(compass)"</span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">r.mapcalc zcos = "cos(colatitude)"</span><br style="font-style: italic;"><br><br><br>If the user does not specify the output maps names, they will be set to <span style="font-style: italic;"><br><br>INPUT_MAP_vector_strength_NxN</span> <br>and<br><span style="font-style: italic;">INPUT_MAP_fisher_K_NxN</span><br><br>where N is the window size.<p>
 </p><h2>REFERENCES</h2><p>Hobson, R.D., 1972. Surface roughness in topography: quantitative approach. In: Chorley, R.J. (ed) <span style="font-style: italic;">Spatial analysis in geomorphology</span>. Methuer, London, p.225-245.<br></p><p>McKean, J. &amp; Roering, J., 2004. <span style="font-style: italic;">Objective landslide detection and surface morphology mapping using high-resolution airborne laser altimetry. Geomorphology</span>, 57:331-351</p><h2>AUTHOR</h2>Carlos Henrique Grohmann<br>Institute of Geosciences, University of São Paulo, Brazil.
-<p><i>Last changed: $Date: 2006/04/20 02:43:23 $</i>
+<p><i>Last changed: $Date$</i>
 </p><hr><p><a href="index.html">Main
 index</a> - <a href="raster.html">raster index</a>
 - <a href="full_index.html">Full index</a></p>


Property changes on: grass-addons/raster/r.roughness/r.roughness.window.vector.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native



More information about the grass-commit mailing list