Skip to contents

Randomly combine given polygons into contiguous, larger polygons.

Usage

make_parent_polygons(polygons, ids = NULL, n = 2, strict_n = TRUE,
  n_as_min = FALSE, buffer_dist = 5e-05, min_overlap = NULL,
  verbose = TRUE)

Arguments

polygons

An sf object with polygons to be reformed.

ids

A vector of IDs the same length as polygons, or the column name in polygons to use as IDs.

n

Number of polygons to aim to combine for each new polygon.

strict_n

Logical; if TRUE (default), n represents the number of intersecting polygons to select, depending on availability (with a minimum of 2). If FALSE, n represents the number of nearest polygons (by centroid) to use when calculating a box to use when selecting polygons (with a minimum of 1).

n_as_min

Logical; if TRUE, will merge any parents with fewer than n children with a random neighbor. Otherwise (and by default), parents may have fewer than n children. Applies if strict_n is TRUE.

buffer_dist

Distance around each initial shape or set of shapes, used to define neighboring shapes. Applies if strict_n is TRUE

min_overlap

Minimal area of overlap between potential neighboring shapes and the buffered target shape, used to define neighboring shapes. Applies if strict_n is TRUE

verbose

Logical; if FALSE, will not print status messages.

Value

A list with entries for new (an sf object containing the new polygons) and map (a list mapping between the old and new polygon indices).