| 1 | <h2>DESCRIPTION</h2>
|
|---|
| 2 | <em>r.mapcalc</em> performs arithmetic on raster map layers.
|
|---|
| 3 | New raster map layers can be created which are arithmetic expressions
|
|---|
| 4 | involving existing raster map layers, integer or floating point constants,
|
|---|
| 5 | and functions.
|
|---|
| 6 |
|
|---|
| 7 | <h3>Program use</h3>
|
|---|
| 8 |
|
|---|
| 9 | <em>r.mapcalc</em> expression have the form:
|
|---|
| 10 | <p><b>result =</b><em> expression</em>
|
|---|
| 11 | <p>where <em>result</em> is the name of a raster map layer
|
|---|
| 12 | to contain the result of the calculation and
|
|---|
| 13 | <b>expression</b> is any legal arithmetic expression involving existing
|
|---|
| 14 | raster map layers (except <em>result</em> itself), integer or floating point constants,
|
|---|
| 15 | and functions known to the calculator.
|
|---|
| 16 | Parentheses are allowed in the expression and may be nested to any depth.
|
|---|
| 17 | <em>result</em> will be created in the user's current mapset.
|
|---|
| 18 | <p>
|
|---|
| 19 | As <b>expression=</b> is the first option, it is the default. This
|
|---|
| 20 | means that passing an expression on the command line is possible
|
|---|
| 21 | as long as the expression is quoted and a space is included before the
|
|---|
| 22 | first <em>=</em> sign.
|
|---|
| 23 |
|
|---|
| 24 | Example ('foo' is the resulting map):
|
|---|
| 25 | <div class="code"><pre>
|
|---|
| 26 | r.mapcalc "foo = 1"
|
|---|
| 27 | </pre></div>
|
|---|
| 28 | or:
|
|---|
| 29 | <div class="code"><pre>
|
|---|
| 30 | r.mapcalc 'foo = 1'
|
|---|
| 31 | </pre></div>
|
|---|
| 32 |
|
|---|
| 33 | An unquoted expression (i.e. split over multiple arguments) won't
|
|---|
| 34 | work, nor will omitting the space before the = sign:
|
|---|
| 35 |
|
|---|
| 36 | <div class="code"><pre>
|
|---|
| 37 | r.mapcalc 'foo=1'
|
|---|
| 38 | Sorry, <foo> is not a valid parameter
|
|---|
| 39 | </pre></div>
|
|---|
| 40 |
|
|---|
| 41 | To read command from the file, use file=
|
|---|
| 42 | explicitly, e.g.:
|
|---|
| 43 |
|
|---|
| 44 | <div class="code"><pre>
|
|---|
| 45 | r.mapcalc file=file
|
|---|
| 46 | </pre></div>
|
|---|
| 47 | or:
|
|---|
| 48 | <div class="code"><pre>
|
|---|
| 49 | r.mapcalc file=- < file
|
|---|
| 50 | </pre></div>
|
|---|
| 51 | or:
|
|---|
| 52 | <div class="code"><pre>
|
|---|
| 53 | r.mapcalc file=- <<EOF
|
|---|
| 54 | foo = 1
|
|---|
| 55 | EOF
|
|---|
| 56 | </pre></div>
|
|---|
| 57 |
|
|---|
| 58 | <p>The formula entered to <em>r.mapcalc</em> by the user is recorded both in the
|
|---|
| 59 | <em>result</em> map title (which appears in the category file for <em>result</em>)
|
|---|
| 60 | and in the history file for <em>result</em>.
|
|---|
| 61 | <p>Some characters have special meaning to the command shell. If the user
|
|---|
| 62 | is entering input to <em>r.mapcalc</em> on the command line, expressions
|
|---|
| 63 | should be enclosed within single quotes. See NOTES, below.
|
|---|
| 64 | </p>
|
|---|
| 65 | <h3>Computational regions in r.mapcalc</h3>
|
|---|
| 66 | <p>
|
|---|
| 67 | By default <em>r.mapcalc</em> uses the current region
|
|---|
| 68 | as computational region that
|
|---|
| 69 | was set with <a href="g.region.html">g.region</a> for processing.
|
|---|
| 70 | Sometimes it is necessary to use a region that is derived from the
|
|---|
| 71 | raster maps in the expression to set the computational region.
|
|---|
| 72 | This is of high importance for modules that use r.mapcalc internally
|
|---|
| 73 | to process time series of satellite images that all have different
|
|---|
| 74 | spatial extents. A module that requires this feature
|
|---|
| 75 | is <a href="t.rast.algebra.html">t.rast.algebra</a>.
|
|---|
| 76 | The <em>region</em> option of <em>r.mapcalc</em>
|
|---|
| 77 | was implemented to address this requirement.
|
|---|
| 78 | It allows computing and using a region based on
|
|---|
| 79 | all raster maps in an expression. Three modes are supported:
|
|---|
| 80 | </p>
|
|---|
| 81 | <ul>
|
|---|
| 82 | <li>
|
|---|
| 83 | Setting the <em>region</em> parameter to <em>current</em>
|
|---|
| 84 | will result in the use of the current region
|
|---|
| 85 | as computational region. This is the default.
|
|---|
| 86 | The current region can be set with <a href="g.region.html">g.region</a>.
|
|---|
| 87 | </li>
|
|---|
| 88 | <li>
|
|---|
| 89 | The parameter <em>union</em> will force r.mapcalc
|
|---|
| 90 | to compute the disjoint union of all regions from raster
|
|---|
| 91 | maps specified in the expression. This
|
|---|
| 92 | computed region will then be used as computational region at runtime.
|
|---|
| 93 | The region of the mapset will not be modified.
|
|---|
| 94 | The smallest spatial resolution
|
|---|
| 95 | of all raster maps will be used for processing.
|
|---|
| 96 | </li>
|
|---|
| 97 | <li>
|
|---|
| 98 | The parameter <em>intersect</em> will force r.mapcalc
|
|---|
| 99 | to compute the intersection of all regions from raster
|
|---|
| 100 | maps specified in the expression. This
|
|---|
| 101 | computed region will then be used as computational region at runtime.
|
|---|
| 102 | The region of the mapset will not be modified.
|
|---|
| 103 | The smallest spatial resolution
|
|---|
| 104 | of all raster maps will be used for processing.
|
|---|
| 105 | </li>
|
|---|
| 106 | </ul>
|
|---|
| 107 |
|
|---|
| 108 | <h3>Operators and order of precedence</h3>
|
|---|
| 109 |
|
|---|
| 110 | The following operators are supported:
|
|---|
| 111 | <div class="code"><pre>
|
|---|
| 112 | Operator Meaning Type Precedence
|
|---|
| 113 | --------------------------------------------------------------
|
|---|
| 114 | - negation Arithmetic 12
|
|---|
| 115 | ~ one's complement Bitwise 12
|
|---|
| 116 | ! not Logical 12
|
|---|
| 117 | ^ exponentiation Arithmetic 11
|
|---|
| 118 | % modulus Arithmetic 10
|
|---|
| 119 | / division Arithmetic 10
|
|---|
| 120 | * multiplication Arithmetic 10
|
|---|
| 121 | + addition Arithmetic 9
|
|---|
| 122 | - subtraction Arithmetic 9
|
|---|
| 123 | << left shift Bitwise 8
|
|---|
| 124 | >> right shift Bitwise 8
|
|---|
| 125 | >>> right shift (unsigned) Bitwise 8
|
|---|
| 126 | > greater than Logical 7
|
|---|
| 127 | >= greater than or equal Logical 7
|
|---|
| 128 | < less than Logical 7
|
|---|
| 129 | <= less than or equal Logical 7
|
|---|
| 130 | == equal Logical 6
|
|---|
| 131 | != not equal Logical 6
|
|---|
| 132 | & bitwise and Bitwise 5
|
|---|
| 133 | | bitwise or Bitwise 4
|
|---|
| 134 | && logical and Logical 3
|
|---|
| 135 | &&& logical and[1] Logical 3
|
|---|
| 136 | || logical or Logical 2
|
|---|
| 137 | ||| logical or[1] Logical 2
|
|---|
| 138 | ?: conditional Logical 1
|
|---|
| 139 | </pre></div>
|
|---|
| 140 | (modulus is the remainder upon division)
|
|---|
| 141 | <p>[1] The &&& and ||| operators handle null values differently to other
|
|---|
| 142 | operators. See the section entitled <b>NULL support</b> below for more
|
|---|
| 143 | details.
|
|---|
| 144 | <p>The operators are applied from left to right, with those of higher precedence
|
|---|
| 145 | applied before those with lower precedence.
|
|---|
| 146 | Division by 0 and modulus by 0 are acceptable and give a NULL result.
|
|---|
| 147 | The logical operators give a 1 result if the comparison is true, 0 otherwise.
|
|---|
| 148 | <p><p>
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 | <h3>Raster map layer names</h3>
|
|---|
| 152 |
|
|---|
| 153 | Anything in the expression which is not a number, operator, or function name
|
|---|
| 154 | is taken to be a raster map layer name.
|
|---|
| 155 | Examples:
|
|---|
| 156 | <p><div class="code"><pre>
|
|---|
| 157 | elevation
|
|---|
| 158 | x3
|
|---|
| 159 | 3d.his
|
|---|
| 160 | </pre></div>
|
|---|
| 161 | <p>Most GRASS raster map layers meet this naming convention.
|
|---|
| 162 | However, if a raster map layer has a name which conflicts with the
|
|---|
| 163 | above rule, it should be quoted. For example, the expression
|
|---|
| 164 | <p><div class="code"><pre>
|
|---|
| 165 | x = a-b
|
|---|
| 166 | </pre></div>
|
|---|
| 167 | <p>would be interpreted as: x equals a minus b, whereas
|
|---|
| 168 | <p><div class="code"><pre>
|
|---|
| 169 | x = "a-b"
|
|---|
| 170 | </pre></div>
|
|---|
| 171 | <p>would be interpreted as: x equals the raster map layer named <em>a-b</em>
|
|---|
| 172 | <p>Also
|
|---|
| 173 | <p><div class="code"><pre>
|
|---|
| 174 | x = 3107
|
|---|
| 175 | </pre></div>
|
|---|
| 176 | <p>would create <em>x</em> filled with the number 3107, while
|
|---|
| 177 | <p><div class="code"><pre>
|
|---|
| 178 | x = "3107"
|
|---|
| 179 | </pre></div>
|
|---|
| 180 | <p>would copy the raster map layer <em>3107</em> to the raster map layer <em>x</em>.
|
|---|
| 181 |
|
|---|
| 182 | <p>Quotes are not required unless the raster map layer names
|
|---|
| 183 | look like numbers or contain operators, OR unless the program
|
|---|
| 184 | is run non-interactively. Examples given here assume the
|
|---|
| 185 | program is run interactively. See NOTES, below.
|
|---|
| 186 | <p><em>r.mapcalc</em> will look for the raster map layers according to the
|
|---|
| 187 | user's current mapset search path.
|
|---|
| 188 | It is possible to override the search path and specify the mapset
|
|---|
| 189 | from which to select the raster map layer.
|
|---|
| 190 | This is done by specifying the raster map layer name in the form:
|
|---|
| 191 | <p><div class="code"><pre>
|
|---|
| 192 | name@mapset
|
|---|
| 193 | </pre></div>
|
|---|
| 194 | <p>For example, the following is a legal expression:
|
|---|
| 195 | <p><div class="code"><pre>
|
|---|
| 196 | result = x@PERMANENT / y@SOILS
|
|---|
| 197 | </pre></div>
|
|---|
| 198 | <p>The mapset specified does not have to be in the mapset search path.
|
|---|
| 199 | (This method of overriding the mapset search path is common to all
|
|---|
| 200 | GRASS commands, not just <em>r.mapcalc</em>.)
|
|---|
| 201 | <p>
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 | <h3>The neighborhood modifier</h3>
|
|---|
| 205 |
|
|---|
| 206 | Maps and images are data base files stored in raster format, i.e.,
|
|---|
| 207 | two-dimensional matrices of integer values.
|
|---|
| 208 | In <em>r.mapcalc</em>, maps may be followed by a <em>neighborhood</em> modifier that
|
|---|
| 209 | specifies a relative offset from the current cell being evaluated. The format is
|
|---|
| 210 | <em>map[r,c]</em>, where <em>r</em> is the row offset and <em>c</em> is the column offset.
|
|---|
| 211 | For example, <em>map[1,2]</em> refers to the cell one row below and two columns
|
|---|
| 212 | to the right of the current cell, <em>map[-2,-1]</em> refers to the cell
|
|---|
| 213 | two rows above and one column to the left of the current cell,
|
|---|
| 214 | and <em>map[0,1]</em> refers to the cell one column to the right of the current cell.
|
|---|
| 215 | This syntax permits the development of neighborhood-type filters within a single
|
|---|
| 216 | map or across multiple maps.
|
|---|
| 217 | <p>
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 | <h3>Raster map layer values from the category file</h3>
|
|---|
| 221 |
|
|---|
| 222 | Sometimes it is desirable to use a value associated with a category's
|
|---|
| 223 | <em>label</em> instead of the category value itself. If a raster
|
|---|
| 224 | map layer name is preceded by the <b>@</b>
|
|---|
| 225 | operator, then the labels in the category file for the raster map layer
|
|---|
| 226 | are used in the expression instead of the category value.
|
|---|
| 227 | <p>For example, suppose that the raster map layer <em>soil.ph</em>
|
|---|
| 228 | (representing soil pH values) has a category file with labels as follows:
|
|---|
| 229 | <p><div class="code"><pre>
|
|---|
| 230 | cat label
|
|---|
| 231 | ------------------
|
|---|
| 232 | 0 no data
|
|---|
| 233 | 1 1.4
|
|---|
| 234 | 2 2.4
|
|---|
| 235 | 3 3.5
|
|---|
| 236 | 4 5.8
|
|---|
| 237 | 5 7.2
|
|---|
| 238 | 6 8.8
|
|---|
| 239 | 7 9.4
|
|---|
| 240 | </pre></div>
|
|---|
| 241 | <p>Then the expression:
|
|---|
| 242 | <p><div class="code"><pre>
|
|---|
| 243 | result = @soils.ph
|
|---|
| 244 | </pre></div>
|
|---|
| 245 | <p>would produce a result with category values
|
|---|
| 246 | 0, 1.4, 2.4, 3.5, 5.8, 7.2, 8.8 and 9.4.
|
|---|
| 247 | <p>Note that this operator may only be applied to raster map layers
|
|---|
| 248 | and produces a floating point value in the expression.
|
|---|
| 249 | Therefore, the category label must start with a valid number.
|
|---|
| 250 | If the category label is integer, it will be represented by
|
|---|
| 251 | a floating point number. I the category label does not start
|
|---|
| 252 | with a number or is missing, it will be represented by NULL
|
|---|
| 253 | (no data) in the resulting raster map.
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 | <h3>Grey scale equivalents and color separates</h3>
|
|---|
| 257 |
|
|---|
| 258 | It is often helpful to manipulate the colors assigned to map categories.
|
|---|
| 259 | This is particularly useful when the spectral properties of cells have meaning
|
|---|
| 260 | (as with imagery data), or when the map category values represent real
|
|---|
| 261 | quantities (as when category values reflect true elevation values).
|
|---|
| 262 | Map color manipulation can also aid visual recognition, and map printing.
|
|---|
| 263 | <p>The # operator can be used to either convert map category values to their
|
|---|
| 264 | grey scale equivalents or to extract the red, green, or blue components
|
|---|
| 265 | of a raster map layer into separate raster map layers.
|
|---|
| 266 | <p><div class="code"><pre>
|
|---|
| 267 | result = #map
|
|---|
| 268 | </pre></div>
|
|---|
| 269 | <p>converts each category value in <em>map</em> to a value in the range 0-255 which
|
|---|
| 270 | represents the grey scale level implied by the color for the category.
|
|---|
| 271 | If the map has a grey scale color table, then the grey level is what
|
|---|
| 272 | #map evaluates to. Otherwise, it is computed as:
|
|---|
| 273 | <p><div class="code"><pre>
|
|---|
| 274 | 0.10 * red + 0.81 * green + 0.01 * blue
|
|---|
| 275 | </pre></div>
|
|---|
| 276 | <p>Alternatively, you can use:
|
|---|
| 277 | <p><div class="code"><pre>
|
|---|
| 278 | result = y#map
|
|---|
| 279 | </pre></div>
|
|---|
| 280 | <p>to use the NTSC weightings:
|
|---|
| 281 | <p><div class="code"><pre>
|
|---|
| 282 | 0.30 * red + 0.59 * green + 0.11 * blue
|
|---|
| 283 | </pre></div>
|
|---|
| 284 | <p>Or, you can use:
|
|---|
| 285 | <p><div class="code"><pre>
|
|---|
| 286 | result = i#map
|
|---|
| 287 | </pre></div>
|
|---|
| 288 | <p>to use equal weightings:
|
|---|
| 289 | <p><div class="code"><pre>
|
|---|
| 290 | 0.33 * red + 0.33 * green + 0.33 * blue
|
|---|
| 291 | </pre></div>
|
|---|
| 292 | <p>The # operator has three other forms: r#map, g#map, b#map.
|
|---|
| 293 | These extract the red, green, or blue components in the named raster map,
|
|---|
| 294 | respectively. The GRASS shell script <em><a href="r.blend.html">r.blend</a></em> extracts each of these
|
|---|
| 295 | components from two raster map layers, and combines them by a user-specified
|
|---|
| 296 | percentage.
|
|---|
| 297 | These forms allow color separates to be made. For example, to
|
|---|
| 298 | extract the red component from <em>map</em>
|
|---|
| 299 | and store it in the new 0-255 map layer <em>red</em>,
|
|---|
| 300 | the user could type:
|
|---|
| 301 | <p><div class="code"><pre>
|
|---|
| 302 | red = r#map
|
|---|
| 303 | </pre></div>
|
|---|
| 304 | <p>To assign this map grey colors type:
|
|---|
| 305 | <p><div class="code"><pre>
|
|---|
| 306 | <a href="r.colors.html">r.colors</a> map=red color=rules
|
|---|
| 307 | black
|
|---|
| 308 | white
|
|---|
| 309 | </pre></div>
|
|---|
| 310 | <p>To assign this map red colors type:
|
|---|
| 311 | <p><div class="code"><pre>
|
|---|
| 312 | <a href="r.colors.html">r.colors</a> map=red color=rules
|
|---|
| 313 | black
|
|---|
| 314 | red
|
|---|
| 315 | </pre></div>
|
|---|
| 316 | <p>
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 | <h3>Functions</h3>
|
|---|
| 320 |
|
|---|
| 321 | The functions currently supported are listed in the table below.
|
|---|
| 322 | The type of the result is indicated in the last column.
|
|---|
| 323 | <em>F</em> means that the functions always results in a floating point value,
|
|---|
| 324 | <em>I</em> means that the function gives an integer result, and
|
|---|
| 325 | <em>*</em> indicates that the result is float if any of the arguments to the
|
|---|
| 326 | function are floating point values and integer if all arguments are integer.
|
|---|
| 327 |
|
|---|
| 328 | <p><div class="code"><pre>
|
|---|
| 329 | function description type
|
|---|
| 330 | ---------------------------------------------------------------------------
|
|---|
| 331 | abs(x) return absolute value of x *
|
|---|
| 332 | acos(x) inverse cosine of x (result is in degrees) F
|
|---|
| 333 | asin(x) inverse sine of x (result is in degrees) F
|
|---|
| 334 | atan(x) inverse tangent of x (result is in degrees) F
|
|---|
| 335 | atan(x,y) inverse tangent of y/x (result is in degrees) F
|
|---|
| 336 | ceil(x) the smallest integral value not less than x *
|
|---|
| 337 | cos(x) cosine of x (x is in degrees) F
|
|---|
| 338 | double(x) convert x to double-precision floating point F
|
|---|
| 339 | eval([x,y,...,]z) evaluate values of listed expr, pass results to z
|
|---|
| 340 | exp(x) exponential function of x F
|
|---|
| 341 | exp(x,y) x to the power y F
|
|---|
| 342 | float(x) convert x to single-precision floating point F
|
|---|
| 343 | floor(x) the largest integral value not greater than x *
|
|---|
| 344 | graph(x,x1,y1[x2,y2..]) convert the x to a y based on points in a graph F
|
|---|
| 345 | graph2(x,x1[,x2,..],y1[,y2..])
|
|---|
| 346 | alternative form of graph() F
|
|---|
| 347 | if decision options: *
|
|---|
| 348 | if(x) 1 if x not zero, 0 otherwise
|
|---|
| 349 | if(x,a) a if x not zero, 0 otherwise
|
|---|
| 350 | if(x,a,b) a if x not zero, b otherwise
|
|---|
| 351 | if(x,a,b,c) a if x > 0, b if x is zero, c if x < 0
|
|---|
| 352 | int(x) convert x to integer [ truncates ] I
|
|---|
| 353 | isnull(x) check if x = NULL
|
|---|
| 354 | log(x) natural log of x F
|
|---|
| 355 | log(x,b) log of x base b F
|
|---|
| 356 | max(x,y[,z...]) largest value of those listed *
|
|---|
| 357 | median(x,y[,z...]) median value of those listed *
|
|---|
| 358 | min(x,y[,z...]) smallest value of those listed *
|
|---|
| 359 | mode(x,y[,z...]) mode value of those listed *
|
|---|
| 360 | nmax(x,y[,z...]) largest value of those listed, excluding NULLs *
|
|---|
| 361 | nmedian(x,y[,z...]) median value of those listed, excluding NULLs *
|
|---|
| 362 | nmin(x,y[,z...]) smallest value of those listed, excluding NULLs *
|
|---|
| 363 | nmode(x,y[,z...]) mode value of those listed, excluding NULLs *
|
|---|
| 364 | not(x) 1 if x is zero, 0 otherwise
|
|---|
| 365 | pow(x,y) x to the power y *
|
|---|
| 366 | rand(a,b) random value x : a <= x < b *
|
|---|
| 367 | round(x) round x to nearest integer I
|
|---|
| 368 | round(x,y) round x to nearest multiple of y
|
|---|
| 369 | round(x,y,z) round x to nearest y*i+z for some integer i
|
|---|
| 370 | sin(x) sine of x (x is in degrees) F
|
|---|
| 371 | sqrt(x) square root of x F
|
|---|
| 372 | tan(x) tangent of x (x is in degrees) F
|
|---|
| 373 | xor(x,y) exclusive-or (XOR) of x and y I
|
|---|
| 374 | </pre></div>
|
|---|
| 375 |
|
|---|
| 376 | <div class="code"><pre>
|
|---|
| 377 | Internal variables:
|
|---|
| 378 | row() current row of moving window I
|
|---|
| 379 | col() current col of moving window I
|
|---|
| 380 | nrows() number of rows in computation region I
|
|---|
| 381 | ncols() number of columns in computation region I
|
|---|
| 382 | x() current x-coordinate of moving window F
|
|---|
| 383 | y() current y-coordinate of moving window F
|
|---|
| 384 | ewres() current east-west resolution F
|
|---|
| 385 | nsres() current north-south resolution F
|
|---|
| 386 | area() area of current cell in square meters F
|
|---|
| 387 | null() NULL value
|
|---|
| 388 | </pre></div>
|
|---|
| 389 | Note, that the row() and col() indexing starts with 1.
|
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 | <h3>Floating point values in the expression</h3>
|
|---|
| 393 |
|
|---|
| 394 | Floating point numbers are allowed in the expression. A floating point
|
|---|
| 395 | number is a number which contains a decimal point:
|
|---|
| 396 | <div class="code"><pre>
|
|---|
| 397 | 2.3 12.0 12. .81
|
|---|
| 398 | </pre></div>
|
|---|
| 399 | Floating point values in the expression are handled in a special way.
|
|---|
| 400 | With arithmetic and logical operators, if either operand is float,
|
|---|
| 401 | the other is converted to float and the result of the operation is float.
|
|---|
| 402 | This means, in particular that division of integers results in a
|
|---|
| 403 | (truncated) integer, while division of floats results in an accurate
|
|---|
| 404 | floating point value. With functions of type * (see table above),
|
|---|
| 405 | the result is float if any argument is float, integer otherwise.
|
|---|
| 406 | <p>Note: If you calculate with integer numbers, the resulting map will
|
|---|
| 407 | be integer. If you want to get a float result, add the decimal point
|
|---|
| 408 | to integer number(s).
|
|---|
| 409 | <p>If you want floating point division, at least one of the arguments has
|
|---|
| 410 | to be a floating point value. Multiplying one of them by 1.0 will
|
|---|
| 411 | produce a floating-point result, as will using float():
|
|---|
| 412 | <div class="code"><pre>
|
|---|
| 413 | r.mapcalc "ndvi = float(lsat.4 - lsat.3) / (lsat.4 + lsat.3)"
|
|---|
| 414 | </pre></div>
|
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 | <h3>NULL support</h3>
|
|---|
| 418 |
|
|---|
| 419 | <ul>
|
|---|
| 420 | <li>Division by zero should result in NULL.
|
|---|
| 421 | <li>Modulus by zero should result in NULL.
|
|---|
| 422 | <li>NULL-values in any arithmetic or logical operation should result
|
|---|
| 423 | in NULL. (however, &&& and ||| are treated specially, as described below).
|
|---|
| 424 | <li>The &&& and ||| operators observe the following axioms even when x is NULL:
|
|---|
| 425 | <div class="code"><pre>
|
|---|
| 426 | x &&& false == false
|
|---|
| 427 | false &&& x == false
|
|---|
| 428 | x ||| true == true
|
|---|
| 429 | true ||| x == true
|
|---|
| 430 | </pre></div>
|
|---|
| 431 | <li>NULL-values in function arguments should result in NULL (however,
|
|---|
| 432 | if(), eval() and isnull() are treated specially, as described below).
|
|---|
| 433 | <li>The eval() function always returns its last argument
|
|---|
| 434 | <li>The situation for if() is:
|
|---|
| 435 | <div class="code"><pre>
|
|---|
| 436 | if(x)
|
|---|
| 437 | NULL if x is NULL; 0 if x is zero; 1 otherwise
|
|---|
| 438 | if(x,a)
|
|---|
| 439 | NULL if x is NULL; a if x is non-zero; 0 otherwise
|
|---|
| 440 | if(x,a,b)
|
|---|
| 441 | NULL if x is NULL; a if x is non-zero; b otherwise
|
|---|
| 442 | if(x,n,z,p)
|
|---|
| 443 | NULL if x is NULL; n if x is negative;
|
|---|
| 444 | z if x is zero; p if x is positive
|
|---|
| 445 | </pre></div>
|
|---|
| 446 | <li>The (new) function isnull(x) returns: 1 if x is NULL;
|
|---|
| 447 | 0 otherwise. The (new) function null()
|
|---|
| 448 | (which has no arguments) returns an integer NULL.
|
|---|
| 449 | <li>Non-NULL, but invalid, arguments to functions should result in NULL.
|
|---|
| 450 | <div class="code"><pre>
|
|---|
| 451 | Examples:
|
|---|
| 452 | log(-2)
|
|---|
| 453 | sqrt(-2)
|
|---|
| 454 | pow(a,b) where a is negative and b is not an integer
|
|---|
| 455 | </pre></div>
|
|---|
| 456 | </ul>
|
|---|
| 457 | <p>NULL support: Please note that any math performed with NULL cells always
|
|---|
| 458 | results in a NULL value for these cells. If you want to replace a NULL cell
|
|---|
| 459 | on-the-fly, use the isnull() test function in a if-statement.
|
|---|
| 460 | <p>Example: The users wants the NULL-valued cells to be treated like zeros. To
|
|---|
| 461 | add maps A and B (where B contains NULLs) to get a map C the user can use a
|
|---|
| 462 | construction like:<p><div class="code"><pre>
|
|---|
| 463 | C = A + if(isnull(B),0,B)
|
|---|
| 464 | </pre></div>
|
|---|
| 465 | <p><b>NULL and conditions:</b>
|
|---|
| 466 | <p>For the one argument form:
|
|---|
| 467 | <div class="code"><pre>
|
|---|
| 468 | if(x) = NULL if x is NULL
|
|---|
| 469 | if(x) = 0 if x = 0
|
|---|
| 470 | if(x) = 1 otherwise (i.e. x is neither NULL nor 0).
|
|---|
| 471 | </pre></div>
|
|---|
| 472 | <p>For the two argument form:
|
|---|
| 473 | <div class="code"><pre>
|
|---|
| 474 | if(x,a) = NULL if x is NULL
|
|---|
| 475 | if(x,a) = 0 if x = 0
|
|---|
| 476 | if(x,a) = a otherwise (i.e. x is neither NULL nor 0).
|
|---|
| 477 | </pre></div>
|
|---|
| 478 | <p>For the three argument form:
|
|---|
| 479 | <div class="code"><pre>
|
|---|
| 480 | if(x,a,b) = NULL if x is NULL
|
|---|
| 481 | if(x,a,b) = b if x = 0
|
|---|
| 482 | if(x,a,b) = a otherwise (i.e. x is neither NULL nor 0).
|
|---|
| 483 | </pre></div>
|
|---|
| 484 | <p>For the four argument form:
|
|---|
| 485 | <div class="code"><pre>
|
|---|
| 486 | if(x,a,b,c) = NULL if x is NULL
|
|---|
| 487 | if(x,a,b,c) = a if x > 0
|
|---|
| 488 | if(x,a,b,c) = b if x = 0
|
|---|
| 489 | if(x,a,b,c) = c if x < 0
|
|---|
| 490 | </pre></div>
|
|---|
| 491 | More generally, all operators and most functions return NULL if *any*
|
|---|
| 492 | of their arguments are NULL.
|
|---|
| 493 | <br>
|
|---|
| 494 | The functions if(), isnull() and eval() are exceptions.
|
|---|
| 495 | <br>
|
|---|
| 496 | The function isnull() returns 1 if its argument is NULL and 0 otherwise.
|
|---|
| 497 | If the user wants the opposite, the ! operator, e.g. "!isnull(x)" must be
|
|---|
| 498 | used.
|
|---|
| 499 | <p>All forms of if() return NULL if the first argument is NULL. The 2, 3
|
|---|
| 500 | and 4 argument forms of if() return NULL if the "selected" argument is
|
|---|
| 501 | NULL, e.g.:
|
|---|
| 502 | <div class="code"><pre>
|
|---|
| 503 | if(0,a,b) = b regardless of whether a is NULL
|
|---|
| 504 | if(1,a,b) = a regardless of whether b is NULL
|
|---|
| 505 | </pre></div>
|
|---|
| 506 | eval() always returns its last argument, so it only returns NULL if
|
|---|
| 507 | the last argument is NULL.
|
|---|
| 508 | <p><b>Note</b>: The user cannot test for NULL using the == operator, as that
|
|---|
| 509 | returns NULL if either or both arguments are NULL, i.e. if x and y are
|
|---|
| 510 | both NULL, then "x == y" and "x != y" are both NULL rather than 1 and
|
|---|
| 511 | 0 respectively.
|
|---|
| 512 | <br>
|
|---|
| 513 | The behaviour makes sense if the user considers NULL as representing an
|
|---|
| 514 | unknown quantity. E.g. if x and y are both unknown, then the values of
|
|---|
| 515 | "x == y" and "x != y" are also unknown; if they both have unknown
|
|---|
| 516 | values, the user doesn't know whether or not they both have the same value.
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 | <h2>NOTES</h2>
|
|---|
| 520 |
|
|---|
| 521 | <h3>Usage from command line</h3>
|
|---|
| 522 |
|
|---|
| 523 | Extra care must be taken if the expression is given on the command line.
|
|---|
| 524 | Some characters have special meaning to the UNIX shell.
|
|---|
| 525 | These include, among others:
|
|---|
| 526 | <div class="code"><pre>
|
|---|
| 527 | * ( ) > & |
|
|---|
| 528 | </pre></div>
|
|---|
| 529 | <p>It is advisable to put single quotes around the expression; e.g.:
|
|---|
| 530 | <div class="code"><pre>
|
|---|
| 531 | 'result = elevation * 2'
|
|---|
| 532 | </pre></div>
|
|---|
| 533 | Without the quotes, the *, which has special meaning to the UNIX shell,
|
|---|
| 534 | would be altered and <em>r.mapcalc</em> would see something other than the *.
|
|---|
| 535 |
|
|---|
| 536 | <h3>Multiple computations</h3>
|
|---|
| 537 | <p>
|
|---|
| 538 | In general, it's preferable to do as much as possible in each
|
|---|
| 539 | r.mapcalc command. E.g. rather than:
|
|---|
| 540 | <div class="code"><pre>
|
|---|
| 541 | r.mapcalc "$GIS_OPT_OUTPUT.r = r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND"
|
|---|
| 542 | r.mapcalc "$GIS_OPT_OUTPUT.g = g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * g#$GIS_OPT_SECOND"
|
|---|
| 543 | r.mapcalc "$GIS_OPT_OUTPUT.b = b#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * b#$GIS_OPT_SECOND"
|
|---|
| 544 | </pre></div>
|
|---|
| 545 | <p>use:
|
|---|
| 546 | <div class="code"><pre>
|
|---|
| 547 | r.mapcalc <<EOF
|
|---|
| 548 | $GIS_OPT_OUTPUT.r = r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND
|
|---|
| 549 | $GIS_OPT_OUTPUT.g = g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * g#$GIS_OPT_SECOND
|
|---|
| 550 | $GIS_OPT_OUTPUT.b = b#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * b#$GIS_OPT_SECOND
|
|---|
| 551 | EOF
|
|---|
| 552 | </pre></div>
|
|---|
| 553 | <p>as the latter will read each input map only once.
|
|---|
| 554 |
|
|---|
| 555 | <h3>Backwards compatibility</h3>
|
|---|
| 556 |
|
|---|
| 557 | For the backwards compatibility with GRASS 6,
|
|---|
| 558 | <!-- check wording: -->
|
|---|
| 559 | if no options are given, it manufactures <tt>file=-</tt> (which reads from
|
|---|
| 560 | stdin), so you can continue to use e.g.:
|
|---|
| 561 | <div class="code"><pre>
|
|---|
| 562 | r.mapcalc < file
|
|---|
| 563 | </pre></div>
|
|---|
| 564 | or:
|
|---|
| 565 | <div class="code"><pre>
|
|---|
| 566 | r.mapcalc <<EOF
|
|---|
| 567 | foo = 1
|
|---|
| 568 | EOF
|
|---|
| 569 | </pre></div>
|
|---|
| 570 | But unless you need compatibility with previous GRASS GIS versions, use <tt>file=</tt>
|
|---|
| 571 | explicitly, as stated above.
|
|---|
| 572 | <p>
|
|---|
| 573 | When the map name contains uppercase letter(s) or a dot which are not
|
|---|
| 574 | allowed to be in module option names, the <em>r.mapcalc</em> command will
|
|---|
| 575 | be valid also without quotes:
|
|---|
| 576 | <div class="code"><pre>
|
|---|
| 577 | r.mapcalc elevation_A=1
|
|---|
| 578 | r.mapcalc elevation.1=1
|
|---|
| 579 | </pre></div>
|
|---|
| 580 | However, this syntax is not recommended as quotes as stated above more safe.
|
|---|
| 581 | Using quotes is both backwards compatible and valid in future.
|
|---|
| 582 |
|
|---|
| 583 | <h3>Interactive input in command line</h3>
|
|---|
| 584 |
|
|---|
| 585 | For formulas that the user enters from standard input
|
|---|
| 586 | (rather than from the command line), a line continuation feature now exists.
|
|---|
| 587 | If the user adds a backslash to the end of an input line, <em>r.mapcalc</em> assumes that
|
|---|
| 588 | the formula being entered by the user continues on to the next input line.
|
|---|
| 589 | There is no limit to the possible number of input lines
|
|---|
| 590 | or to the length of a formula.
|
|---|
| 591 | <p>If the <em>r.mapcalc</em> formula entered by the user is very long,
|
|---|
| 592 | the map title will contain only some of it, but most (if not all) of
|
|---|
| 593 | the formula will be placed into the history file for the <em>result</em> map.
|
|---|
| 594 |
|
|---|
| 595 | <h3>Raster MASK handling</h3>
|
|---|
| 596 | <p>
|
|---|
| 597 | <em>r.mapcalc</em> follows the common GRASS behavior of raster MASK handling,
|
|---|
| 598 | so the MASK is only applied when reading an existing GRASS raster map.
|
|---|
| 599 | This implies that, for example, the command:
|
|---|
| 600 | <div class="code"><pre>
|
|---|
| 601 | r.mapcalc "elevation_exaggerated = elevation * 3"
|
|---|
| 602 | </pre></div>
|
|---|
| 603 | create a map respecting the masked pixels if MASK is active.
|
|---|
| 604 |
|
|---|
| 605 | <p>
|
|---|
| 606 | However, when creating a map which is not based on any map,
|
|---|
| 607 | e.g. a map from a constant:
|
|---|
| 608 | <div class="code"><pre>
|
|---|
| 609 | r.mapcalc "base_height = 200.0"
|
|---|
| 610 | </pre></div>
|
|---|
| 611 | the created raster map is limited only by a computation region
|
|---|
| 612 | but it is not affected by an active MASK.
|
|---|
| 613 | This is expected because, as mentioned above, MASK is only applied when reading,
|
|---|
| 614 | not when writing a raster map.
|
|---|
| 615 | <p>
|
|---|
| 616 | If also in this case the MASK should be applied, an if() statement including the
|
|---|
| 617 | MASK should be used, e.g.:
|
|---|
| 618 | <div class="code"><pre>
|
|---|
| 619 | r.mapcalc "base_height = if(MASK, 200.0, null())"
|
|---|
| 620 | </pre></div>
|
|---|
| 621 |
|
|---|
| 622 | When testing MASK related expressions keep in mind that when MASK is active
|
|---|
| 623 | you don't see data in masked areas even if they are not NULL.
|
|---|
| 624 | See <em><a href="r.mask.html">r.mask</a></em> for details.
|
|---|
| 625 |
|
|---|
| 626 | <h3>eval function</h3>
|
|---|
| 627 | If the output of the computation should be only one map
|
|---|
| 628 | but the expression is so complex that it is better to split it
|
|---|
| 629 | to several expressions, the <tt>eval</tt> function can be used:
|
|---|
| 630 | <div class="code"><pre>
|
|---|
| 631 | r.mapcalc << EOF
|
|---|
| 632 | eval(elev_200 = elevation - 200, \
|
|---|
| 633 | elev_5 = 5 * elevation, \
|
|---|
| 634 | elev_p = pow(elev_5, 2))
|
|---|
| 635 | elevation_result = (0.5 * elev_200) + 0.8 * elev_p
|
|---|
| 636 | EOF
|
|---|
| 637 | </pre></div>
|
|---|
| 638 | This example uses unix-like <tt><< EOF</tt> syntax to provide
|
|---|
| 639 | input to <em>r.mapcalc</em>.
|
|---|
| 640 | <p>
|
|---|
| 641 | Note that the temporary variables (maps) are not created
|
|---|
| 642 | and thus it does not matter whether they exists or not.
|
|---|
| 643 | In the example above, if map <tt>elev_200</tt> exists it will not be
|
|---|
| 644 | overwritten and no error will be generated.
|
|---|
| 645 | The reason is that the name <tt>elev_200</tt> now denotes the temporary
|
|---|
| 646 | variable (map) and not the existing map.
|
|---|
| 647 | The following parts of the expression will use the temporary <tt>elev_200</tt>
|
|---|
| 648 | and the existing <tt>elev_200</tt> will be left intact and will not be used.
|
|---|
| 649 | If a user want to use the existing map, the name of the temporary variable
|
|---|
| 650 | (map) must be changed.
|
|---|
| 651 |
|
|---|
| 652 | <h3>Using the same map for input and output results</h3>
|
|---|
| 653 | A map cannot be used both as an input and as an output as in
|
|---|
| 654 | this invalid expression <tt>oldmap = oldmap + 1</tt>, instead
|
|---|
| 655 | a subsequent rename using <em><a href="g.rename.html">g.rename</a></em> is
|
|---|
| 656 | needed when the same name is desired:
|
|---|
| 657 |
|
|---|
| 658 | <div class="code"><pre>
|
|---|
| 659 | r.mapcalc "newmap = oldmap + 1"
|
|---|
| 660 | g.rename raster=newmap,oldmap
|
|---|
| 661 | </pre></div>
|
|---|
| 662 |
|
|---|
| 663 | <h3>Random number generator initialization</h3>
|
|---|
| 664 | <p>The pseudo-random number generator used by the rand() function can
|
|---|
| 665 | be initialised to a specific value using the <b>seed</b> option.
|
|---|
| 666 | This can be used to replicate a previous calculation.
|
|---|
| 667 | <p>Alternatively, it can be initialised from the system time and the
|
|---|
| 668 | PID using the <b>-r</b> flag. This should result in a different seed
|
|---|
| 669 | being used each time.
|
|---|
| 670 | <p>In either case, the seed will be written to the map's history, and
|
|---|
| 671 | can be seen using <em>r.info</em>.
|
|---|
| 672 | <p>If you want other people to be able to verify your results, it's
|
|---|
| 673 | preferable to use the <b>seed</b> option to supply a seed which is
|
|---|
| 674 | either specified in the script or generated from a determenistic process
|
|---|
| 675 | such as a pseudo-random number generator given an explicit seed.
|
|---|
| 676 | <p>Note that the rand() function will generate a fatal error if neither
|
|---|
| 677 | the <b>seed</b> option nor the <b>-s</b> flag are given.
|
|---|
| 678 |
|
|---|
| 679 |
|
|---|
| 680 | <h2>EXAMPLES</h2>
|
|---|
| 681 |
|
|---|
| 682 | To compute the average of two raster map layers
|
|---|
| 683 | <em>a</em> and <em>b</em>:
|
|---|
| 684 | <div class="code"><pre>
|
|---|
| 685 | ave = (a + b)/2
|
|---|
| 686 | </pre></div>
|
|---|
| 687 |
|
|---|
| 688 | <p>
|
|---|
| 689 | To form a weighted average:
|
|---|
| 690 | <div class="code"><pre>
|
|---|
| 691 | ave = (5*a + 3*b)/8.0
|
|---|
| 692 | </pre></div>
|
|---|
| 693 |
|
|---|
| 694 | <p>
|
|---|
| 695 | To produce a binary representation of the raster map layer
|
|---|
| 696 | <em>a</em> so that category 0 remains 0 and all other categories become 1:
|
|---|
| 697 | <div class="code"><pre>
|
|---|
| 698 | mapmask = a != 0
|
|---|
| 699 | </pre></div>
|
|---|
| 700 | This could also be accomplished by:
|
|---|
| 701 | <div class="code"><pre>
|
|---|
| 702 | mapmask = if(a)
|
|---|
| 703 | </pre></div>
|
|---|
| 704 |
|
|---|
| 705 | <p>
|
|---|
| 706 | To mask raster map layer <em>b</em> by raster map layer <em>a</em>:
|
|---|
| 707 | <div class="code"><pre>
|
|---|
| 708 | result = if(a,b)
|
|---|
| 709 | </pre></div>
|
|---|
| 710 |
|
|---|
| 711 | <p>
|
|---|
| 712 | To change all values below 5 to NULL:
|
|---|
| 713 | <div class="code"><pre>
|
|---|
| 714 | newmap = if(map<5, null(), 5)
|
|---|
| 715 | </pre></div>
|
|---|
| 716 |
|
|---|
| 717 | <p>
|
|---|
| 718 | To create a map with random values in a defined range (needs either the
|
|---|
| 719 | usage of <b>-s</b> flag or the <em>seed</em> parameter). The precision of
|
|---|
| 720 | the input values determines the output precision (the resulting
|
|---|
| 721 | <a href="rasterintro.html#raster-format">raster map type</a>):
|
|---|
| 722 |
|
|---|
| 723 | <div class="code"><pre>
|
|---|
| 724 | # write result as integer map (CELL)
|
|---|
| 725 | random_int = rand(-100,100)
|
|---|
| 726 |
|
|---|
| 727 | # write result as double precision floating point map (DCELL)
|
|---|
| 728 | random_dcell = rand(-100.0,100.0)
|
|---|
| 729 |
|
|---|
| 730 | # write result as single precision floating point map (FCELL)
|
|---|
| 731 | random_fcell = float(rand(-100.0,100.0))
|
|---|
| 732 | </pre></div>
|
|---|
| 733 |
|
|---|
| 734 | <p>
|
|---|
| 735 | The graph() function allows users to specify a x-y conversion using
|
|---|
| 736 | pairs of x,y coordinates.
|
|---|
| 737 | In some situations a transformation from one value to another is not
|
|---|
| 738 | easily established mathematically, but can be represented by a 2-D
|
|---|
| 739 | graph and then linearly interpolated. The graph() function provides
|
|---|
| 740 | the opportunity to accomplish this.
|
|---|
| 741 | An x-axis value is provided to the graph function along with
|
|---|
| 742 | the associated graph represented by a series of x,y pairs. The x
|
|---|
| 743 | values must be monotonically increasing (each larger than or equal to
|
|---|
| 744 | the previous). The graph function linearly interpolates between
|
|---|
| 745 | pairs. Any x value lower the lowest x value (i.e. first) will have
|
|---|
| 746 | the associated y value returned. Any x value higher than the last
|
|---|
| 747 | will similarly have the associated y value returned. Consider the
|
|---|
| 748 | request:
|
|---|
| 749 | <div class="code"><pre>
|
|---|
| 750 | newmap = graph(map, 1,10, 2,25, 3,50)
|
|---|
| 751 | </pre></div>
|
|---|
| 752 | X (map) values supplied and y (newmap) values returned:
|
|---|
| 753 | <div class="code"><pre>
|
|---|
| 754 | 0, 10
|
|---|
| 755 | 1, 10
|
|---|
| 756 | 1.5, 17.5
|
|---|
| 757 | 2.9, 47.5
|
|---|
| 758 | 4, 50
|
|---|
| 759 | 100, 50
|
|---|
| 760 | </pre></div>
|
|---|
| 761 |
|
|---|
| 762 |
|
|---|
| 763 | <h2>KNOWN ISSUES</h2>
|
|---|
| 764 |
|
|---|
| 765 | The <em>result</em> variable on the left hand side of the equation should not
|
|---|
| 766 | appear in the <em>expression</em> on the right hand side.
|
|---|
| 767 |
|
|---|
| 768 | <div class="code"><pre>
|
|---|
| 769 | <s>mymap = if( mymap > 0, mymap, 0)</s>
|
|---|
| 770 | </pre></div>
|
|---|
| 771 |
|
|---|
| 772 | <p>Any maps generated by a <em>r.mapcalc</em> command only exist after the entire
|
|---|
| 773 | command has completed. All maps are generated concurrently, row-by-row
|
|---|
| 774 | (i.e. there is an implicit "for row in rows {...}" around the entire expression).
|
|---|
| 775 | Thus the <tt>#</tt>, <tt>@</tt>, and <tt>[ ]</tt> operators cannot be used on a map
|
|---|
| 776 | generated within same <em>r.mapcalc</em> command run.
|
|---|
| 777 | Consequently, the following (strikethrough code) does not work:
|
|---|
| 778 |
|
|---|
| 779 | <div class="code"><pre>
|
|---|
| 780 | newmap = oldmap * 3.14
|
|---|
| 781 | <s>othermap = newmap[-1, 0] / newmap[1, 0]</s>
|
|---|
| 782 | </pre></div>
|
|---|
| 783 |
|
|---|
| 784 | <p>Continuation lines must end with a <tt>\</tt> and have <em>no</em> trailing
|
|---|
| 785 | white space (blanks or tabs). If the user does leave white space at the end of
|
|---|
| 786 | continuation lines, the error messages produced by <em>r.mapcalc</em> will
|
|---|
| 787 | be meaningless and the equation will not work as the user intended.
|
|---|
| 788 | This is particularly important for the <tt>eval()</tt> function.
|
|---|
| 789 | <p><!-- STILL TRUE ??-->
|
|---|
| 790 | Currently, there is no comment mechanism in <em>r.mapcalc</em>.
|
|---|
| 791 | Perhaps adding a capability that would cause the entire line to be
|
|---|
| 792 | ignored when the user inserted a # at the start of a line
|
|---|
| 793 | as if it were not present, would do the trick.
|
|---|
| 794 | <p>The function should require the user to type "end" or "exit" instead
|
|---|
| 795 | of simply a blank line. This would make separation of multiple scripts
|
|---|
| 796 | separable by white space.
|
|---|
| 797 | <p><em>r.mapcalc</em> does not print a warning in case of operations on
|
|---|
| 798 | NULL cells. It is left to the user to utilize the <tt>isnull()</tt> function.
|
|---|
| 799 |
|
|---|
| 800 |
|
|---|
| 801 | <h2>SEE ALSO</h2>
|
|---|
| 802 |
|
|---|
| 803 | <em>
|
|---|
| 804 | <a href="g.region.html">g.region</a>,
|
|---|
| 805 | <a href="r.bitpattern.html">r.bitpattern</a>,
|
|---|
| 806 | <a href="r.blend.html">r.blend</a>,
|
|---|
| 807 | <a href="r.colors.html">r.colors</a>,
|
|---|
| 808 | <a href="r.fillnulls.html">r.fillnulls</a>,
|
|---|
| 809 | <a href="r.mapcalc.simple.html">r.mapcalc.simple</a>
|
|---|
| 810 | </em>
|
|---|
| 811 |
|
|---|
| 812 |
|
|---|
| 813 | <h2>REFERENCES</h2>
|
|---|
| 814 |
|
|---|
| 815 | <b><a href="http://grass.osgeo.org/uploads/grass/history_docs/mapcalc-algebra.pdf">r.mapcalc: An Algebra for GIS and Image
|
|---|
| 816 | Processing</a></b>, by Michael Shapiro and Jim Westervelt, U.S. Army
|
|---|
| 817 | Construction Engineering Research Laboratory (March/1991).
|
|---|
| 818 | <p>
|
|---|
| 819 | <b><a href="http://grass.osgeo.org/uploads/grass/history_docs/mapcalc.pdf">Performing Map Calculations on GRASS Data:
|
|---|
| 820 | r.mapcalc Program Tutorial</a></b>, by Marji Larson, Michael Shapiro and Scott
|
|---|
| 821 | Tweddale, U.S. Army Construction Engineering Research Laboratory (December
|
|---|
| 822 | 1991)
|
|---|
| 823 | <p>Grey scale conversion is based on the C.I.E. x,y,z system where y represents
|
|---|
| 824 | luminance. See "Fundamentals of Digital Image Processing,"
|
|---|
| 825 | by Anil K. Jain (Prentice Hall, NJ, 1989; p 67).
|
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 | <h2>AUTHORS</h2>
|
|---|
| 829 | Michael Shapiro, U.S.Army Construction Engineering
|
|---|
| 830 | Research Laboratory
|
|---|
| 831 | <p>Glynn Clements
|
|---|
| 832 |
|
|---|
| 833 | <p>
|
|---|
| 834 | <i>Last changed: $Date: 2018-12-14 21:41:06 +0000 (Fri, 14 Dec 2018) $</i>
|
|---|