[GRASS-SVN] r36208 - grass/branches/develbranch_6/raster/r.mapcalc
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 6 09:53:28 EST 2009
Author: epatton
Date: 2009-03-06 09:53:28 -0500 (Fri, 06 Mar 2009)
New Revision: 36208
Modified:
grass/branches/develbranch_6/raster/r.mapcalc/r.mapcalc.html
Log:
Added hint from Glynn on doing as much as possible in each r.mapcalc command to NOTES
Modified: grass/branches/develbranch_6/raster/r.mapcalc/r.mapcalc.html
===================================================================
--- grass/branches/develbranch_6/raster/r.mapcalc/r.mapcalc.html 2009-03-06 14:41:42 UTC (rev 36207)
+++ grass/branches/develbranch_6/raster/r.mapcalc/r.mapcalc.html 2009-03-06 14:53:28 UTC (rev 36208)
@@ -20,7 +20,7 @@
and functions.
-<h2>PROGRAM USE</h2>
+<h3>PROGRAM USE</h3>
If used without command line arguments, <em>r.mapcalc</em> will read its
input, one line at a time, from standard input
(which is the keyboard, unless redirected from a file or across a pipe).
@@ -47,7 +47,7 @@
<p>
-<h2>OPERATORS AND ORDER OF PRECEDENCE</h2>
+<h3>OPERATORS AND ORDER OF PRECEDENCE</h3>
The following operators are supported:
<div class="code"><pre>
Operator Meaning Type Precedence
@@ -92,7 +92,7 @@
<p>
-<h2>RASTER MAP LAYER NAMES</h2>
+<h3>RASTER MAP LAYER NAMES</h3>
Anything in the expression which is not a number, operator, or function name
is taken to be a raster map layer name.
Examples:
@@ -161,7 +161,7 @@
<p>
-<h2>THE NEIGHBORHOOD MODIFIER</h2>
+<h3>THE NEIGHBORHOOD MODIFIER</h3>
Maps and images are data base files stored in raster format, i.e.,
two-dimensional matrices of integer values.
In <em>r.mapcalc</em>, maps may be followed by a <em>neighborhood</em> modifier that
@@ -176,7 +176,7 @@
<p>
-<h2>RASTER MAP LAYER VALUES FROM THE CATEGORY FILE</h2>
+<h3>RASTER MAP LAYER VALUES FROM THE CATEGORY FILE</h3>
Sometimes it is desirable to use a value associated with a category's
<em>label</em> instead of the category value itself. If a raster
map layer name is preceded by the <b>@</b>
@@ -217,7 +217,7 @@
(no data) in the resulting raster map.
-<h2>GREY SCALE EQUIVALENTS AND COLOR SEPARATES</h2>
+<h3>GREY SCALE EQUIVALENTS AND COLOR SEPARATES</h3>
It is often helpful to manipulate the colors assigned to map categories.
This is particularly useful when the spectral properties of cells have meaning
(as with imagery data), or when the map category values represent real
@@ -297,7 +297,7 @@
<p>
-<h2>FUNCTIONS</h2>
+<h3>FUNCTIONS</h3>
The functions currently supported are listed in the table below.
The type of the result is indicated in the last column.
<em>F</em>
@@ -358,7 +358,7 @@
Note, that the row() and col() indexing starts with 1.
-<h2>FLOATING POINT VALUES IN THE EXPRESSION</h2>
+<h3>FLOATING POINT VALUES IN THE EXPRESSION</h3>
Floating point numbers are allowed in the expression. A floating point
number is a number which contains a decimal point:
<div class="code"><pre>
@@ -384,7 +384,7 @@
</pre></div>
-<h2>NULL support</h2>
+<h3>NULL support</h3>
<menu>
<li>Division by zero should result in NULL.
<li>Modulus by zero should result in NULL.
@@ -493,8 +493,69 @@
unknown quantity. E.g. if x and y are both unknown, then the values of
"x == y" and "x != y" are also unknown; if they both have unknown
values, the user doesn't know whether or not they both have the same value.
+<p>
+<h2>NOTES</h2>
+Extra care must be taken if the expression is given on the command line.
+Some characters have special meaning to the UNIX shell.
+These include, among others:
+<p>
+* ( ) > & |
+<p>
+It is advisable to put single quotes around the expression; e.g.:
+<div class="code"><pre>
+result = 'elevation * 2'
+</pre></div>
+Without the quotes, the *, which has special meaning to the UNIX shell,
+would be altered and <em>r.mapcalc</em> would see something other than the *.
+<p>
+In general, it's preferable to do as much as possible in each
+r.mapcalc command. E.g. rather than:
+<div class="code"><pre>
+ r.mapcalc "$GIS_OPT_OUTPUT.r = r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND"
+ r.mapcalc "$GIS_OPT_OUTPUT.g = g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * g#$GIS_OPT_SECOND"
+ r.mapcalc "$GIS_OPT_OUTPUT.b = b#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * b#$GIS_OPT_SECOND"
+</pre></div>
+use:
+<div class="code"><pre>
+ r.mapcalc <<EOF
+ $GIS_OPT_OUTPUT.r = r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND
+ $GIS_OPT_OUTPUT.g = g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * g#$GIS_OPT_SECOND
+ $GIS_OPT_OUTPUT.b = b#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * b#$GIS_OPT_SECOND
+ EOF
+</pre></div>
+as the latter will read each input map only once.
+</p>
+
+If the input comes directly from the keyboard and the <em>result</em> raster
+map layer exists, the user will be asked if it can be overwritten.
+Otherwise, the <em>result</em> raster map layer will automatically be
+overwritten if it exists.
+<p>
+Quoting <em>result</em> is not allowed.
+However, it is never necessary to quote <em>result</em> since
+it is always taken to be a raster map layer name.
+<p>
+For formulas that the user enters from standard input
+(rather than from the command line), a line continuation feature now exists.
+If the user adds \e to the end of an input line, <em>r.mapcalc</em> assumes that
+the formula being entered by the user continues on to the next input line.
+There is no limit to the possible number of input lines
+or to the length of a formula.
+<p>
+If the <em>r.mapcalc</em> formula entered by the user is very long,
+the map title will contain only some of it, but most (if not all) of
+the formula will be placed into the history file for the <em>result</em> map.
+<p>
+When the user enters input to <em>r.mapcalc</em> non-interactively on
+the command line, the program will not warn the user not to overwrite
+existing map layers. Users should therefore take care to assign program
+outputs raster map names that do not yet exist in their current mapsets.
+<p>
+The environment variable GRASS_RND_SEED is read to initialise the
+random number generator.
+
<h2>EXAMPLES</h2>
To compute the average of two raster map layers
<em>a</em> and <em>b</em>:
@@ -550,47 +611,6 @@
</pre></div>
-<h2>NOTES</h2>
-Extra care must be taken if the expression is given on the command line.
-Some characters have special meaning to the UNIX shell.
-These include, among others:
-<p>
-* ( ) > & |
-<p>
-It is advisable to put single quotes around the expression; e.g.:
-<div class="code"><pre>
-result = 'elevation * 2'
-</pre></div>
-Without the quotes, the *, which has special meaning to the UNIX shell,
-would be altered and <em>r.mapcalc</em> would see something other than the *.
-<p>
-If the input comes directly from the keyboard and the <em>result</em> raster
-map layer exists, the user will be asked if it can be overwritten.
-Otherwise, the <em>result</em> raster map layer will automatically be
-overwritten if it exists.
-<p>
-Quoting <em>result</em> is not allowed.
-However, it is never necessary to quote <em>result</em> since
-it is always taken to be a raster map layer name.
-<p>
-For formulas that the user enters from standard input
-(rather than from the command line), a line continuation feature now exists.
-If the user adds \e to the end of an input line, <em>r.mapcalc</em> assumes that
-the formula being entered by the user continues on to the next input line.
-There is no limit to the possible number of input lines
-or to the length of a formula.
-<p>
-If the <em>r.mapcalc</em> formula entered by the user is very long,
-the map title will contain only some of it, but most (if not all) of
-the formula will be placed into the history file for the <em>result</em> map.
-<p>
-When the user enters input to <em>r.mapcalc</em> non-interactively on
-the command line, the program will not warn the user not to overwrite
-existing map layers. Users should therefore take care to assign program
-outputs raster map names that do not yet exist in their current mapsets.
-<p>
-The environment variable GRASS_RND_SEED is read to initialise the
-random number generator.
<h2>BUGS</h2>
More information about the grass-commit
mailing list