EVOLUTION-MANAGER
Edit File: extractIndex.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: Indexing to extract values of a Raster* object</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 Extract by index {raster}"><tr><td>Extract by index {raster}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Indexing to extract values of a Raster* object</h2> <h3>Description</h3> <p>These are shorthand methods that call other methods that should normally be used, such as <code><a href="getValues.html">getValues</a></code>, <code><a href="extract.html">extract</a></code>, <code><a href="crop.html">crop</a></code>. </p> <p><code>object[i]</code> can be used to access values of a Raster* object, using cell numbers. You can also use row and column numbers as index, using <code>object[i,j]</code> or <code>object[i,]</code> or <code>object[,j]</code>. In addition you can supply an Extent, SpatialPolygons, SpatialLines or SpatialPoints object. </p> <p>If <code>drop=TRUE</code> (the default) cell values are returned (a vector for a RasterLayer, a matrix for a RasterStack or RasterBrick). If <code>drop=FALSE</code> a Raster* object is returned that has the extent covering the requested cells, and with all other non-requested cells within this extent set to <code>NA</code>. </p> <p>If you supply a RasterLayer, its values will be used as logical (TRUE/FALSE) indices if both Raster objects have the same extent and resolution; otherwise the cell values within the extent of the RasterLayer are returned. </p> <p>Double brackes '[[ ]]' can be used to extract one or more layers from a multi-layer object. </p> <h3>Methods</h3> <p><code>x[i]</code> </p> <p><code>x[i,j]</code> </p> <p>Arguments </p> <table summary="Rd table"> <tr> <td style="text-align: right;"> </td><td style="text-align: left;"> <code>x</code> </td><td style="text-align: left;"> a Raster* object </td> </tr> <tr> <td style="text-align: right;"> </td><td style="text-align: left;"> <code>i</code> </td><td style="text-align: left;"> cell number(s), row number(s), a (logical) RasterLayer, Spatial* object </td> </tr> <tr> <td style="text-align: right;"> </td><td style="text-align: left;"> <code>j</code> </td><td style="text-align: left;"> column number(s) (only available if i is (are) a row number(s)) </td> </tr> <tr> <td style="text-align: right;"> </td><td style="text-align: left;"> <code>drop</code> </td><td style="text-align: left;"> If <code>TRUE</code>, cell values are returned. Otherwise, a Raster* object is returned </td> </tr> <tr> <td style="text-align: right;"> </td> </tr> </table> <h3>See Also</h3> <p><code><a href="getValues.html">getValues</a>, <a href="setValues.html">setValues</a>, <a href="extract.html">extract</a>, <a href="crop.html">crop</a>, <a href="rasterize.html">rasterize</a></code> </p> <h3>Examples</h3> <pre> r <- raster(ncol=10, nrow=5) values(r) <- 1:ncell(r) r[1] r[1:10] r[1,] r[,1] r[1:2, 1:2] s <- stack(r, sqrt(r)) s[1:3] s[[2]] </pre> <hr /><div style="text-align: center;">[Package <em>raster</em> version 3.3-13 <a href="00Index.html">Index</a>]</div> </body></html>