chessboard: Perform chessboard segmentation

View source: R/chessboard.R

chessboardR Documentation

Perform chessboard segmentation

Description

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

Usage

chessboard(r, size)

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.

Value

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

Examples

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

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.