spatialEco (version 1.3-2)

background: Background sample

Description

Creates a point sample that can be used as a NULL for SDM's and other modeling approaches.

Usage

background(
  x,
  ext = NULL,
  p = 1000,
  known = NULL,
  d = NULL,
  type = c("regular", "random", "hexagon", "nonaligned")
)

Arguments

x

A polygon defining sample region

ext

Vector of extent coordinates (xmin, xmax, ymin, ymax)

p

Size of sample

known

SpatialPoints of known locations (same CSR as x)

d

Threshold distance for known proximity

type

Type of sample c("systematic", "random", "hexagon", "nonaligned")

Value

A SpatialPointsDataFrame or data.frame with x,y coordinates

Examples

Run this code
# NOT RUN {
library(sp)
library(raster)
library(rgeos)
  data(meuse)
  coordinates(meuse) <- ~x+y

# create "known" locations  
locs <- meuse[sample(1:nrow(meuse), 5),]

# systematic sample using extent polygon
e <- as(extent(meuse), "SpatialPolygons")
s <- background(e, p=1000, known=locs, d=300)
  plot(s,pch=20)
    points(locs, pch=20, col="red")

# systematic sample using irregular polygon
data(meuse.grid)
  coordinates(meuse.grid) = c("x", "y")
  gridded(meuse.grid) = TRUE
meuse.poly = gUnaryUnion(as(meuse.grid, "SpatialPolygons"))

s <- background(meuse.poly, p=1000, known=locs, d=200)
  plot(s,pch=20)
    plot(meuse.poly, add=TRUE)
    points(locs, pch=20, col="red")

# random sample using irregular polygon
s <- background(meuse.poly, p=500, known=locs, 
                d=200, type="random")
  plot(s,pch=20)
    plot(meuse.poly, add=TRUE)
    points(locs, pch=20, col="red")

# systematic sample using defined extent
extent(meuse)
s <- background(ext=c(178605, 181390, 329714, 333611), 
                p=1000, known=locs, d=300)
  plot(s,pch=20)
    points(locs, pch=20, col="red")

# }

Run the code above in your browser using DataCamp Workspace