pseudoRandomWeights: random_background_weights

View source: R/weights_pseudo.R

pseudoRandomWeightsR Documentation

random_background_weights

Description

Quick way to generate psuedo-random points using the terria package. Weights are taken as the the area(window)/npoints. The default unit is km^2, but other units can be used such as meters squared "m" or hectars "ha". There is an internal check to see if the input data is in lon/lat and if so, it returns the area of the cell in which the point lies.

Usage

pseudoRandomWeights(
  presences,
  quadrature,
  window,
  coord,
  mark.id,
  unit = c("geo", "m", "km", "ha")
)

Arguments

presences

The observed presence locations

quadrature

The quadrature locations

window

A SpatRaster from terra package which will represent the extent and resolution of the point process model.

coord

The names of the coordinates. Default is c("X","Y").

mark.id

character Name of the species ID column

unit

The scale of the area weights, default is kilometers squared "km" but meters squared "m" or hectars "ha" can be used.

Author(s)

Skipton Woolley

Examples

library(ppmData)
library(terra)
path <- system.file("extdata", package = "ppmData")
lst <- list.files(path=path,pattern='*.tif',full.names = TRUE)
window <- terra::rast(lst[1])
presences <- subset(snails,SpeciesID %in% "Tasmaphena sinclairi")[,1:2]
quadrature <- pseudoRandomQuad(1000,window,control=list(quiet=FALSE))
res <- pseudoRandomWeights(presences,quadrature,window,unit="geo")
plot(window)
points(res[res$presence==1,1:2],pch=16,cex=0.5,col='blue')
points(res[res$presence==0,1:2],pch='.')

skiptoniam/qrbp documentation built on May 13, 2023, 2:08 a.m.