EVOLUTION-MANAGER
Edit File: as.matrix.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: Get a vector, matrix, or array with raster cell values</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 as.matrix {raster}"><tr><td>as.matrix {raster}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Get a vector, matrix, or array with raster cell values</h2> <h3>Description</h3> <p><code>as.vector</code> returns a vector of cell values. For a RasterLayer it is equivalent to getValues(x). </p> <p><code>as.matrix</code> returns all values of a Raster* object as a matrix. For RasterLayers, rows and columns in the matrix represent rows and columns in the RasterLayer object. For other Raster* objects, the matrix returned by <code>as.matrix</code> has columns for each layer and rows for each cell. </p> <p><code>as.array</code> returns an array of matrices that are like those returned by <code>as.matrix</code> for a RasterLayer </p> <p>If there is insufficient memory to load all values, you can use <code><a href="getValues.html">getValues</a></code> or <code><a href="getValuesBlock.html">getValuesBlock</a></code> to read chunks of the file. </p> <p><code>as.matrix</code> and <code>as.vector</code> can also be used to obtain the coordinates from an Extent object. </p> <h3>Usage</h3> <pre> as.matrix(x, ...) as.array(x, ...) ## S4 method for signature 'Extent' as.vector(x, mode='any') ## S4 method for signature 'Raster' as.vector(x, mode='any') </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> Raster* or (for <code>as.matrix</code> and <code>as.vector</code>) Extent object </p> </td></tr> <tr valign="top"><td><code>mode</code></td> <td> <p>Character string giving an atomic mode (such as "numeric" or "character") or "list", or "any". Note: this argument is currently ignored!</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> additional arguments: </p> <p><code>maxpixels</code> Integer. To regularly subsample very large objects </p> <p><code>transpose</code> Logical. Transpose the data? (for as.array only) </p> </td></tr></table> <h3>Value</h3> <p>matrix, array, or vector </p> <h3>Examples</h3> <pre> r <- raster(ncol=3, nrow=3) values(r) <- 1:ncell(r) as.matrix(r) s <- stack(r,r) as.array(s) as.vector(extent(s)) </pre> <hr /><div style="text-align: center;">[Package <em>raster</em> version 3.3-13 <a href="00Index.html">Index</a>]</div> </body></html>