EVOLUTION-MANAGER
Edit File: sampleRandom.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: Random sample</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 sampleRandom {raster}"><tr><td>sampleRandom {raster}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Random sample</h2> <h3>Description</h3> <p>Take a random sample from the cell values of a Raster* object (without replacement). </p> <h3>Usage</h3> <pre> ## S4 method for signature 'Raster' sampleRandom(x, size, na.rm=TRUE, ext=NULL, cells=FALSE, rowcol=FALSE, xy=FALSE, sp=FALSE, asRaster=FALSE, ...) </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>size</code></td> <td> <p>positive integer giving the number of items to choose</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>logical. If <code>TRUE</code> (the default), <code>NA</code> values are removed from random sample</p> </td></tr> <tr valign="top"><td><code>ext</code></td> <td> <p>Extent object. To limit regular sampling to the area within the extent</p> </td></tr> <tr valign="top"><td><code>cells</code></td> <td> <p>logical. If <code>TRUE</code>, sampled cell numbers are also returned</p> </td></tr> <tr valign="top"><td><code>rowcol</code></td> <td> <p>logical. If <code>TRUE</code>, sampled row and column numbers are also returned</p> </td></tr> <tr valign="top"><td><code>xy</code></td> <td> <p>logical. If <code>TRUE</code>, coordinates of sampled cells are also returned</p> </td></tr> <tr valign="top"><td><code>sp</code></td> <td> <p>logical. If <code>TRUE</code>, a SpatialPointsDataFrame is returned</p> </td></tr> <tr valign="top"><td><code>asRaster</code></td> <td> <p>logical. If <code>TRUE</code>, a Raster* object is returned with random cells with values, all other cells with <code>NA</code></p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments as in <code><a href="writeRaster.html">writeRaster</a></code>. Only relevant when <code>asRaster=TRUE</code></p> </td></tr> </table> <h3>Details</h3> <p>With argument <code>na.rm=TRUE</code>, the returned sample may be smaller than requested </p> <h3>Value</h3> <p>A vector, matrix (if <code>cells=TRUE</code> or <code>x</code> is a multi-layered object), or a SpatialPointsDataFrame (if <code>sp=TRUE</code> ) </p> <h3>See Also</h3> <p><code><a href="sampleRegular.html">sampleRegular</a>, <a href="sampleStratified.html">sampleStratified</a></code></p> <h3>Examples</h3> <pre> r <- raster(system.file("external/test.grd", package="raster")) sampleRandom(r, size=10) s <- stack(r, r) sampleRandom(s, size=5, cells=TRUE, sp=TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>raster</em> version 3.3-13 <a href="00Index.html">Index</a>]</div> </body></html>