View source: R/spatial_tools.R
split_raster_equally | R Documentation |
This function splits a raster object into parts with approximately equal area.
split_raster_equally(r, n)
r |
A |
n |
An integer that defines the number of parts into which to split the raster. |
The raster (r
) should not only contain NAs.
The function returns a list containing the split raster components.
This function requires the ‘plyr’ package.
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.
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/.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.