Learn R Programming

spatialEco (version 0.1-1)

land.metrics: Landscape metrics for points and polygons

Description

Calculates a variety of landscape metrics, on binary rasters, for polygons or points with a buffer distance

Usage

land.metrics(x, y, bkgd = NA, metrics = c(4, 14, 33, 34, 35, 37, 38),
  bw = 1000, latlon = FALSE, Trace = TRUE)

Arguments

x
SpatalPointsDataFrame or SpatalPolgonsDataFrame class object
y
raster class object (binary raster)
bkgd
Background value
metrics
Numeric index of desired metric (see available metrics)
bw
Buffer distance (ignored if x is SpatalPolgonsDataFrame)
latlon
Is raster data in lat-long (TRUE/FALSE)
Trace
Plot raster subsets and echo object ID at each iteration (TRUE | FALSE)

Value

  • data.frame with specified metrics in columns. The data.frame is ordered the same as the input feature class and can be directly joined to the @data slot

Examples

Run this code
require(raster)
require(sp)
r <- raster(ncol=1000, nrow=1000)
  r[] <- rpois(ncell(r), lambda=1)
    r <- calc(r, fun=function(x) { x[x >= 1] <- 1; return(x) } )
xy <- SpatialPointsDataFrame(SpatialPoints(cbind(-50, seq(-80, 80, by=20))),
                             data.frame(ID=seq(1,9,1)))

land.metrics(x=xy, y=r, bw=0.72, bkgd = 0, Trace=FALSE)

Run the code above in your browser using DataLab