EVOLUTION-MANAGER
Edit File: cellStats.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Statistics across cells</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cellStats {raster}"><tr><td>cellStats {raster}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Statistics across cells</h2> <h3>Description</h3> <p>Compute statistics for the cells of each layer of a Raster* object. In the <code>raster</code> package, functions such as max, min, and mean, when used with Raster* objects as argument, return a new Raster* object (with a value computed for each cell). In contrast, cellStats returns a single value, computed from the all the values of a layer. Also see <code><a href="layerStats.html">layerStats</a></code> </p> <h3>Usage</h3> <pre> ## S4 method for signature 'RasterLayer' cellStats(x, stat='mean', na.rm=TRUE, asSample=TRUE, ...) ## S4 method for signature 'RasterStackBrick' cellStats(x, stat='mean', na.rm=TRUE, asSample=TRUE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Raster* object</p> </td></tr> <tr valign="top"><td><code>stat</code></td> <td> <p>The function to be applied. See Details</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>Logical. Should <code>NA</code> values be removed?</p> </td></tr> <tr valign="top"><td><code>asSample</code></td> <td> <p>Logical. Only relevant for <code>stat=sd</code> in which case, if <code>TRUE</code>, the standard deviation for a sample (denominator is <code>n-1</code>) is computed, rather than for the population (denominator is <code>n</code>)</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments </p> </td></tr> </table> <h3>Details</h3> <p><code>cellStats</code> will fail (gracefully) for very large Raster* objects except for a number of known functions: sum, mean, min, max, sd, 'skew' and 'rms'. 'skew' (skewness) and 'rms' (Root Mean Square) must be supplied as a character value (with quotes), the other known functions may be supplied with or without quotes. For other functions you could perhaps use a sample of the RasterLayer that can be held in memory (see <code><a href="sampleRegular.html">sampleRegular</a></code> ) </p> <h3>Value</h3> <p>Numeric </p> <h3>See Also</h3> <p><code><a href="freq.html">freq</a></code>, <code><a href="quantile.html">quantile</a></code>, <code><a href="extremeValues.html">minValue</a></code>, <code><a href="extremeValues.html">maxValue</a></code>, <code><a href="setMinMax.html">setMinMax</a></code> </p> <h3>Examples</h3> <pre> r <- raster(nrow=18, ncol=36) values(r) <- runif(ncell(r)) * 10 # works for large files cellStats(r, 'mean') # same, but does not work for very large files cellStats(r, mean) # multi-layer object cellStats(brick(r,r), mean) </pre> <hr /><div style="text-align: center;">[Package <em>raster</em> version 3.3-13 <a href="00Index.html">Index</a>]</div> </body></html>