Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fast_extract

Fast extract


Description

Extract data from a Raster object.

Usage

fast_extract(x, y, ...)

## S4 method for signature 'Raster,SpatialPolygons'
fast_extract(x, y, fun = "mean", ...)

## S4 method for signature 'Raster,SpatialPoints'
fast_extract(x, y, fun = "mean", ...)

## S4 method for signature 'Raster,SpatialLines'
fast_extract(x, y, fun = "mean", ...)

## S4 method for signature 'Raster,sfc'
fast_extract(x, y, fun = "mean", ...)

## S4 method for signature 'Raster,sf'
fast_extract(x, y, fun = "mean", ...)

Arguments

x

Raster object.

y

Spatial or sf::sf() object.

...

not used.

fun

character name of statistic to summarize data. Defaults to "mean". Available options include "sum" or "mean". Defaults to "mean".

Details

This function is simply a wrapper that uses raster::extract() to extract data for SpatialPoints and SpatialLines and non-polygonal sf::sf() data, and exactextractr::exact_extract() for SpatialPolygons and polygonal sf::sf() data.

Value

matrix containing the summary amount of each feature within each planning unit. Rows correspond to different spatial features in the argument to y and columns correspond to different raster layers in the argument to x.

See Also

Examples

# load data
data(sim_pu_sf, sim_features)

# extract data
result <- fast_extract(sim_features, sim_pu_sf)

# show result
print(head(result))

prioritizr

Systematic Conservation Prioritization in R

v7.0.1
GPL-3
Authors
Jeffrey O Hanson [aut] (<https://orcid.org/0000-0002-4716-6134>), Richard Schuster [aut, cre] (<https://orcid.org/0000-0003-3191-7869>), Nina Morrell [aut], Matthew Strimas-Mackey [aut] (<https://orcid.org/0000-0001-8929-7776>), Matthew E Watts [aut], Peter Arcese [aut] (<https://orcid.org/0000-0002-8097-482X>), Joseph Bennett [aut] (<https://orcid.org/0000-0002-3901-9513>), Hugh P Possingham [aut] (<https://orcid.org/0000-0001-7755-996X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.