sumRaster | R Documentation |
Returns the sum of raster cells within a polygon. When the raster is coded as a typical SDM (where 1 = suitable habitat and 0 = non-suitable habitat), returns the number of suitable cells within the polygon.
sumRaster(rast, poly)
rast |
A raster object of class RasterLayer. |
poly |
A spatial polygon object of class SpatialPolygons. |
The same process can be done with raster::extract
; however, this
function (uses raster::mask
and raster::cellStats
) performed faster in a local test using large raster objects.
Numeric, sum of raster cells within a polygon.
Jason D. Carlisle, University of Wyoming, <jason.d.carlisle@gmail.com>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.