backSample: backSample

Description Usage Arguments Details Value See Also Examples

View source: R/backSample.R

Description

Background sample selection.

Usage

1
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.

Details

First, the function determines the unique pixel coordinates for x based on the dimensions of y and retrieves n, random background samples where n is determined by nr.samples. If sampling.method is set to "random", the function will return the selected samples as a SpatialPoints object. However, if sampling.method is set to "pca", the function performs a Principal Components Analysis (PCA) over y to evaluate the similarity between the samples associated to x and the initial set of random samples. To achieve this, the function selects the most important Principal Components (PC's) using the kaiser rule (i.e. PC's with eigenvalues greater than 1) and, for each PC, estimates the median and the Median Absolute Deviation (MAD) based on the samples of related ot each unique identifier in z). Based on this data, the function selects background samples where the difference between their variance and the variance of the region samples exceeds the absolute difference between the median and the MAD. Finally, the algorithm filteres out all the background samples that were not selected by all sample regions. The ouptut is a SpatialPointsDataFrame containing the selected samples and the corresponding y values. If nr.samples is not provided all background pixels are considered.

Value

A SpatialPoints or a SpatialPointsDataFrame.

See Also

labelSample hotMove dataQuery

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{

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

 # 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')

}

RRemelgado/rsMove documentation built on June 7, 2020, 5:12 p.m.