GeNetIt (version 0.1-4)

node.statistics: 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"))

Value

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

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.

Examples

Run this code
# \donttest{
library(sp)
library(spdep)
library(raster)
  data(rasters)
  data(ralu.site)

xvars <- stack(rasters)
  
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]],
             stats = c("min", "median", "max", "var", "skew")) 
} )

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

dist.graph@data <- data.frame(dist.graph@data, stats, nstats)
  str(dist.graph@data)
# }

Run the code above in your browser using DataLab