partition-methods: Partition raster data

Description Usage Arguments Value References See Also Examples

Description

Divide a categorical raster map into training and testing partitions. A wrapper function for
caret::createDataPartition (Kuhn, 2008).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
partition(x, ...)

## S4 method for signature 'RasterLayer'
partition(x, size = 0.5, spatial = TRUE, ...)

## S4 method for signature 'DiscreteLulcRasterStack'
partition(x, size = 0.5,
  spatial = TRUE, t, ...)

## S4 method for signature 'ContinuousLulcRasterStack'
partition(x, size = 0.5,
  spatial = TRUE, ...)

Arguments

x

RasterLayer with categorical data

...

additional arguments (none)

size

numeric value between zero and one indicating the proportion of non-NA cells that should be included in the training partition. Default is 0.5, which results in equally sized partitions

spatial

logical. If TRUE, the function returns a SpatialPoints object with the coordinates of cells in each partition. If FALSE, the cell numbers are returned

t

numeric corresponding to one of the time points for which a land use map is available.

Value

A list containing the following components:

train

a SpatialPoints object or numeric vector indicating the cells in the training partition

test

a SpatialPoints object or numeric vector indicating the cells in the testing partition

all

a SpatialPoints object or numeric vector indicating all non-NA cells in the study region

References

Kuhn, M. (2008). Building predictive models in R using the caret package. Journal of Statistical Software, 28(5), 1-26.

See Also

caret::createDataPartition

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 

## Plum Island Ecosystems

lu <- DiscreteLulcRasterStack(x=stack(pie[1:3]),
                              categories=c(1,2,3),
                              labels=c("Forest","Built","Other"),
                              t=c(0,6,14))

part <- partition(x=lu, size=0.05, spatial=TRUE, t=0)

plot(lu[[1]])
points(part[["train"]])


## End(Not run)

simonmoulds/lulcc2 documentation built on Dec. 23, 2021, 2:24 a.m.