Learn R Programming

rcaiman (version 2.0.1)

chessboard: Perform chessboard segmentation

Description

Segment a raster into square regions of equal size arranged in a chessboard-like pattern.

Usage

chessboard(r, size)

Value

terra::SpatRaster with one layer and integer values, where each unique value corresponds to a square-segment ID.

Arguments

r

numeric terra::SpatRaster. One or more layers used to drive heterogeneity.

size

Numeric vector of length one. Size (in pixels) of each square segment. Must be a positive integer.

Details

This function divides the extent of a terra::SpatRaster into non-overlapping square segments of the given size, producing a segmentation map where each segment has a unique integer label. It can be an alternative to sky_grid_segmentation() in special cases.

Examples

Run this code
caim <- read_caim()
seg <- chessboard(caim, 20)
plot(caim$Blue)
plot(extract_feature(caim$Blue, seg))

Run the code above in your browser using DataLab