View source: R/node.statistics.R
node.statistics | R Documentation |
returns raster value or statistics (based on specified radius) for node
node.statistics(x, r, buffer = NULL, stats = c("min", "median", "max"))
x |
sp class SpatialPointsDataFrame object |
r |
A rasterLayer, rasterStack or rasterBrick object |
buffer |
Buffer distance, radius in projection units |
stats |
Statistics to calculate. If vectorized, can pass a custom statistic function. |
data.frame object of at-node raster values or statistics
If no buffer is specified, at-node raster values are returned
Jeffrey S. Evans <jeffrey_evans@tnc.org> and Melanie A. Murphy <melanie.murphy@uwyo.edu>
library(sf)
library(terra)
data(ralu.site)
xvars <- rast(system.file("extdata/covariates.tif", package="GeNetIt"))
skew <- function(x, na.rm = TRUE) {
if (na.rm) x <- x[!is.na(x)]
sum( (x - mean(x)) ^ 3) / ( length(x) * sd(x) ^ 3 )
}
# without buffer (values at point)
system.time( {
stats <- node.statistics(ralu.site, r = xvars[[-6]])
} )
# with 1000m buffer (values around points)
system.time( {
stats <- node.statistics(ralu.site, r = xvars[[-6]], buffer = 1000,
stats = c("min", "median", "max", "var", "skew"))
} )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.