EVOLUTION-MANAGER
Edit File: approxNA.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: Estimate values for cell values that are 'NA' by...</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 approxNA {raster}"><tr><td>approxNA {raster}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Estimate values for cell values that are <code>NA</code> by interpolating between layers</h2> <h3>Description</h3> <p>approxNA uses the <code>stats</code> function <code><a href="../../stats/html/approxfun.html">approx</a></code> to estimate values for cells that are <code>NA</code> by interpolation across layers. Layers are considered equidistant, unless an argument 'z' is used, or <code><a href="zvalues.html">getZ</a></code> returns values, in which case these values are used to determine distance between layers. </p> <p>For estimation based on neighbouring cells see <code><a href="focal.html">focal</a></code> </p> <h3>Usage</h3> <pre> ## S4 method for signature 'RasterStackBrick' approxNA(x, filename="", method="linear", yleft, yright, rule=1, f=0, ties=mean, z=NULL, NArule=1, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>RasterStack or RasterBrick object</p> </td></tr> <tr valign="top"><td><code>filename</code></td> <td> <p>character. Output filename (optional)</p> </td></tr> <tr valign="top"><td><code>method</code></td> <td> <p>specifies the interpolation method to be used. Choices are "linear" or "constant" (step function; see the example in <code><a href="../../stats/html/approxfun.html">approx</a></code></p> </td></tr> <tr valign="top"><td><code>yleft</code></td> <td> <p>the value to be returned before a non-<code>NA</code> value is encountered. The default is defined by the value of rule given below</p> </td></tr> <tr valign="top"><td><code>yright</code></td> <td> <p>the value to be returned after the last non-<code>NA</code> value is encountered. The default is defined by the value of rule given below</p> </td></tr> <tr valign="top"><td><code>rule</code></td> <td> <p>an integer (of length 1 or 2) describing how interpolation is to take place at for the first and last cells (before or after any non-<code>NA</code> values are encountered). If rule is 1 then NAs are returned for such points and if it is 2, the value at the closest data extreme is used. Use, e.g., <code>rule = 2:1</code>, if the left and right side extrapolation should differ</p> </td></tr> <tr valign="top"><td><code>f</code></td> <td> <p>for method = "constant" a number between 0 and 1 inclusive, indicating a compromise between left- and right-continuous step functions. If y0 and y1 are the values to the left and right of the point then the value is <code>y0*(1-f)+y1*f</code> so that <code>f = 0)</code> is right-continuous and <code>f = 1</code> is left-continuous</p> </td></tr> <tr valign="top"><td><code>ties</code></td> <td> <p>Handling of tied 'z' values. Either a function with a single vector argument returning a single number result or the string "ordered"</p> </td></tr> <tr valign="top"><td><code>z</code></td> <td> <p>numeric vector to indicate the distance between layers (e.g., time, depth). The default is 1:nlayers(x) </p> </td></tr> <tr valign="top"><td><code>NArule</code></td> <td> <p>single integer used to determine what to do when only a single layer with a non-<code>NA</code> value is encountered (and linear interpolation is not possible). The default value of 1 indicates that all layers will get this value for that cell; all other values do not change the cell values</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>additional arguments as for <code><a href="writeRaster.html">writeRaster</a></code></p> </td></tr> </table> <h3>Value</h3> <p>RasterBrick </p> <h3>See Also</h3> <p><code> <a href="focal.html">focal</a></code> </p> <h3>Examples</h3> <pre> r <- raster(ncols=5, nrows=5) r1 <- setValues(r, runif(ncell(r))) r2 <- setValues(r, runif(ncell(r))) r3 <- setValues(r, runif(ncell(r))) r4 <- setValues(r, runif(ncell(r))) r5 <- setValues(r, NA) r6 <- setValues(r, runif(ncell(r))) r1[6:10] <- NA r2[5:15] <- NA r3[8:25] <- NA s <- stack(r1,r2,r3,r4,r5,r6) s[1:5] <- NA x1 <- approxNA(s) x2 <- approxNA(s, rule=2) x3 <- approxNA(s, rule=2, z=c(1,2,3,5,14,15)) </pre> <hr /><div style="text-align: center;">[Package <em>raster</em> version 3.3-13 <a href="00Index.html">Index</a>]</div> </body></html>