divpol: Divide polygons into equal area parts

divide_polygonsR Documentation

Divide polygons into equal area parts

Description

stripper divides polygons into horizontal or vertical strips of a specified relative size.

divider divides a SpatVector of polygons into n compact and approximately equal area parts. The results are not deterministic so you should use set.seed to be able to reproduce your results. If you get a warning about non-convergence, you can increase the number of iterations used with additional argument iter.max

Usage

divider(x, n, env=NULL, alpha=1, ...)
stripper(x, f=c(1/3, 2/3), vertical=TRUE)

Arguments

x

SpatVector of polygons

n

positive integer. The number of parts requested

env

SpatRaster with environmental data

alpha

numeric. One or two numbers that act as weights for the x and y coordinates

...

additional arguments such as iter.max passed on to kmeans

f

numeric vector of fractions. These must be > 0 and < 1, and in ascending order

vertical

logical. If TRUE the strips are vertical

Value

SpatVector

Author(s)

stripper was derived from a function by Barry Rowlingson

Examples

f <- system.file("ex/lux.shp", package="terra")
v <- aggregate(vect(f))
set.seed(33)
d1 <- divider(v, 10)
plot(d1)

d2 <- divider(v, 100)
boxplot(expanse(d2, "km"))

x <- stripper(v, seq(0.1, 0.9, 0.1))
round(expanse(x,"km"), 1)
plot(x, col=rainbow(12))


predicts documentation built on Oct. 7, 2024, 9:06 a.m.