split_raster_equally: Split a raster into equal-area parts

View source: R/spatial_tools.R

split_raster_equallyR Documentation

Split a raster into equal-area parts

Description

This function splits a raster object into parts with approximately equal area.

Usage

split_raster_equally(r, n)

Arguments

r

A raster.

n

An integer that defines the number of parts into which to split the raster.

Details

The raster (r) should not only contain NAs.

Value

The function returns a list containing the split raster components.

Note

This function requires the ‘plyr’ package.

Source

The function taken and slightly modified from the ‘greenbrown’ package (see https://rdrr.io/rforge/greenbrown/src/R/SplitRasterEqually.R). The function is defined separately in flapper to reduce reliance on non-default packages.

References

Forkel M, Wutzler T (2015) greenbrown – land surface phenology and trend analysis. A package for the R software. Version 2.2, 2015-04-15, http://greenbrown.r-forge.r-project.org/.

Examples

l <- split_raster_equally(dat_gebco, 2)
l <- split_raster_equally(dat_gebco, 3)
pp <- graphics::par(mfrow = c(1, 3))
lapply(l, function(r) prettyGraphics::pretty_map(add_rasters = list(x = r)))
graphics::par(pp)


edwardlavender/flapper documentation built on Jan. 22, 2025, 2:44 p.m.