fast_extract | R Documentation |
Extract data from a terra::rast()
object.
fast_extract(x, y, ...)
## S4 method for signature 'Raster,Spatial'
fast_extract(x, y, fun = "mean", ...)
## S4 method for signature 'Raster,sfc'
fast_extract(x, y, fun = "mean", ...)
## S4 method for signature 'SpatRaster,sfc'
fast_extract(x, y, fun = "mean", ...)
## S4 method for signature 'Raster,sf'
fast_extract(x, y, fun = "mean", ...)
## S4 method for signature 'SpatRaster,sf'
fast_extract(x, y, fun = "mean", ...)
x |
|
y |
|
... |
not used. |
fun |
|
The performance of this function for large terra::rast()
objects
can be improved by increasing the GDAL cache size.
The default cache size is 25 MB.
For example, the following code can be used to set the cache size to 4 GB.
terra::gdalCache(size = 4000)
This function is simply a wrapper that uses
exactextractr::exact_extract()
for polygon geometries, and
terra::extract()
for other geometry types.
A 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
.
terra::extract()
, exactextractr::exact_extract()
.
# load data
sim_pu_polygons <- get_sim_pu_polygons()
sim_features <- get_sim_features()
# extract data
result <- fast_extract(sim_features, sim_pu_polygons)
# show result
print(head(result))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.