Learn R Programming

rsMove (version 0.2.3)

backSample: backSample

Description

Background sample selection.

Usage

backSample(xy = xy, region.id = region.id,
  sampling.method = sampling.method, env.data = env.data,
  nr.samples = NULL)

Arguments

xy

Object of class SpatialPoints of SpatialPointsDataFrame.

region.id

Vector of region identifiers for each sample.

sampling.method

One of random or pca. Default is random.

env.data

Object of class RasterLayer, RasterStack or RasterBrick.

nr.samples

Number of random background samples.

Value

A SpatialPoints or a SpatialPointsDataFrame of background samples for unique pixels in env.data.

Details

First, the function determines the unique pixel coordinates for xy based on the dimensions of env.data and retrieves n background samples where n is determined by nr.samples. Then, the selection of samples is dependent on the method chosen by the user. If sampling.method is set to random, the function will select samples randomly. However, if pca is used, the function will use a Principal Components Analysis (PCA) over env.data to evaluate the similarity between the samples associated to xy and the initial set of random samples First, based on this PCA, the function selects the most important Principal Components (PC's) using the kaiser rule (i.e. PC's with eigenvalues greater than 1). Then, for each PC, the function estimates the median and the Median Absolute Deviation (MAD) for each unique identifier in region.id) and selects background samples where the difference between their variance and the variance of the region samples exceeds the MAD. Then, the algorithm removes the background samples that were not selected by all sample regions.

If nr.samples is not provided all background pixels are returned

object.

References

Remelgado, R., Leutner, B., Safi, K., Sonnenschein, R., Kuebert, C. and Wegmann, M. (2017), Linking animal movement and remote sensing - mapping resource suitability from a remote sensing perspective. Remote Sens Ecol Conserv.

See Also

labelSample hotMove dataQuery

Examples

Run this code
# NOT RUN {
{

 require(raster)

 # read raster data
 file <- list.files(system.file('extdata', '', package="rsMove"), 'ndvi.tif', full.names=TRUE)
 r.stk <- stack(file)

 # read movement data
 data(shortMove)

 # find sample regions
 label <- labelSample(xy=shortMove, agg.radius=500, nr.pixels=2, pixel.res=30)

 # select background samples
 ind <- which(label>0) # selected samples
 bSamples <- backSample(xy=shortMove[ind,], region.id=label[ind],
 env.data=r.stk, sampling.method='random')

}
# }

Run the code above in your browser using DataLab