Learn R Programming

rsMove (version 0.2.4)

backSample: backSample

Description

Background sample selection.

Usage

backSample(x, y, z, sampling.method = "random", nr.samples = NULL)

Arguments

x

Object of class SpatialPoints of SpatialPointsDataFrame.

y

Object of class RasterLayer, RasterStack or RasterBrick.

z

Vector of region identifiers for each sample.

sampling.method

One of random or pca. Default is random.

nr.samples

Number of random background samples.

Value

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

Details

First, the function determines the unique pixel coordinates for x based on the dimensions of y 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 y to evaluate the similarity between the samples associated to x 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 z) 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.

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(shortMove, agg.radius=30, nr.pixels=2, pixel.res=30)

 # select background samples (pca)
 bSamples <- backSample(shortMove, r.stk, label, sampling.method='pca')

 # select background samples (random)
 bSamples <- backSample(shortMove, r.stk, sampling.method='random')

}
# }

Run the code above in your browser using DataLab