sumRaster: Sum of raster within polygon

View source: R/sumRaster.R

sumRasterR Documentation

Sum of raster within polygon

Description

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.

Usage

sumRaster(rast, poly)

Arguments

rast

A raster object of class RasterLayer.

poly

A spatial polygon object of class SpatialPolygons.

Details

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.

Value

Numeric, sum of raster cells within a polygon.

Author(s)

Jason D. Carlisle, University of Wyoming, <jason.d.carlisle@gmail.com>


jcarlis3/umbrella documentation built on March 26, 2022, 7:20 p.m.