rpolygon: Random polygon

View source: R/units.R

rpolygonR Documentation

Random polygon

Description

Generates a single, random polygon.

Usage

rpolygon(crs = 3395, origin = c(0, 0), area = 1e+05,
  composite = 64, square = FALSE)

Arguments

crs

An integer EPSG code specifying the coordinate reference system of the polygon to be generated. Default: 3395 (World Mercator, https://epsg.io/3395)

origin

Numeric. The approximate origin coordinates of the polygon to be generated (x,y).

area

Integer. The approximate area of the polygon to be generated, in map units (see crs).

composite

Integer. Higher values take longer, but generate more complex polygons with more sides. See details. Default: 64.

square

Logical. If TRUE, the algorithm tends to create squared corners and edges. If this is undesirable, set to FALSE (the default).

Details

rpolygon() generates a random tessellation using mosaic() and returns a random polygon sampled for it. If composite > 1, several contiguious tiles are dissolved, creating more complex polygons with more sides. The polygon may contain holes.

Value

An sf object containing a single polygon.

Examples


# Simple polygon
polygon <- rpolygon()
plot(polygon)

# More complex polygon
polygon <- rpolygon(composite = 8)


joeroe/fieldwalkr documentation built on Feb. 17, 2024, 12:15 a.m.