Learn R Programming

fieldRS (version 0.2.3)

ccLabel: ccLabel

Description

Labels groups of pixels in a raster object that share similar attributes.

Usage

ccLabel(x, method = "simple", change.threshold = NULL)

Arguments

x

Object of class RasterLayer, RasterStack or RasterBrick.

method

Labeling method. Choose between 'simple' and 'change'. Default is 'simple'.

change.threshold

Numeric element.

Value

A list.

Details

Uses a 8-neighbor connected component labeling algorithm (determined by method) to identify groups of pixels of the same value. Each group receives a distinct numeric label. The function provides two connected component labeling algorithms:

  • simple - Connects neighboring pixels with the same value. Suitable for categorical data.

  • spatial - Estimates the MAPE using a 3x3 moving window distinguishes neighboring pixels when the spatial change surpasses change.threshold.

  • temporal - Estimates the MAPE among all bands in a raster object and distinguishes spatially neighboring pixels when the temporal change surpasses change.threshold.

When using the spatial and temporal methods, the value of change.threshold will influence the output. If the value is negative, the function will return the pixels that are below the threshold and vice versa when positive. Let's assume we are dealing with crop fields. When, using a negative threshold and the spatial method, the function will return homogeneous groups of pixels. This happens because the borders of between fields offer a contract and thus receive higher MAPE values. However, if we apply the same threshold when using the temporal method, the borders will be highlighted. This happens because the crop fields are more variant over time due to their fast growth while the borders remain virtually unchanged. The final output of the function is a list consisting of:
  • regions - RasterLayer object with region labels.

  • frequency - data.frame object with the pixel count for each unique value in regions.

See Also

classModel rankPlots

Examples

Run this code
# NOT RUN {
{

require(raster)

# read raster data
r <- brick(system.file("extdata", "ndvi.tif", package="fieldRS"))

# spatial change labeling
or <- ccLabel(r[[1]], method="spatial", change.threshold=10)
plot(or$regions)

# temporal change labeling
or <- ccLabel(r, method="temporal", change.threshold=80)
plot(or$regions)

}
# }

Run the code above in your browser using DataLab