Last data update: 2014.03.03

R: Statistics for edges (lines) based on a defined scale (area).
area.graph.statisticsR Documentation

Statistics for edges (lines) based on a defined scale (area).

Description

Samples rasters for each edge and calculates specified statistics

Usage

area.graph.statistics(x, r, s = 500, stats = c("min", "mean", "max"),
  echo = FALSE)

Arguments

x

sp class SpatialLinesDataFrame object

r

A rasterLayer, rasterStack or rasterBrick object

s

Scale (buffer distance) for analysis

stats

Statistics to calculate. If vectorized, can pass a custom statistic function.

echo

Echo progress (TRUE/FALSE)

Value

data.frame object with defined statistics, for each raster, at each edge in graph

Examples

## Not run: 
library(sp)
library(spdep)
library(raster)
  data(rasters)
  data(ralu.site)

xvars <- stack(rasters[-6])

dist.graph <- knn.graph(ralu.site, row.names = ralu.site@data[,"SiteName"], 
                        max.dist = 500)
  str(dist.graph@data)
  
skew <- function(x, na.rm = TRUE) {  
          if (na.rm) x <- x[!is.na(x)]
          sum( (x - mean(x)) ^ 3) / ( length(x) * sd(x) ^ 3 )  
		}
		
area.graph.statistics(dist.graph[1:5,], r = xvars, s = 500, 
           stats = c("min", "median", "max", "var", "skew")) 

## End(Not run)

Results