node.statistics: raster statistics for nodes

View source: R/node.statistics.R

node.statisticsR Documentation

raster statistics for nodes

Description

returns raster value or statistics (based on specified radius) for node

Usage

node.statistics(x, r, buffer = NULL, stats = c("min", "median", "max"))

Arguments

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.

Value

data.frame object of at-node raster values or statistics

Note

If no buffer is specified, at-node raster values are returned

Author(s)

Jeffrey S. Evans <jeffrey_evans@tnc.org> and Melanie A. Murphy <melanie.murphy@uwyo.edu>

Examples


 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")) 
 } ) 
 


GeNetIt documentation built on July 9, 2023, 5:18 p.m.