Learn R Programming

potential (version 0.1.0)

equipotential: Create Polygons of Equipotential

Description

This function creates polygons of equipotential from a regular grid of potential points.

Usage

equipotential(x, var, nclass = 8, breaks, mask, buffer, xcoords, ycoords)

Arguments

x

an sf object of regularly spaced points. It must contain "X", "Y" and "OUTPUT" fields.

var

name of the OUTPUT field in x.

nclass

a number of class.

breaks

a vector of break values.

mask

an sf object of polygons or multipolygons. /codemask is used to clip polygons of contours equipotential.

buffer

if set, a buffer is internaly added to the mask in order to reach more precisely the number of breaks. The buffer is defined in x units.

xcoords

name of the X coordinates field in x, not needed if x is constructed with create_grid.

ycoords

name of the Y coordinates field in x, not needed if x is constructed with create_grid.

Value

The output is an sf object (POLYGONS). The data frame contains four fields: id (id of each polygon), min and max (minimum and maximum breaks of the polygon) and center (central values of classes).

Examples

Run this code
# NOT RUN {
library(sf)
y <- create_grid(x = n3_poly, res = 200000)
d <- create_matrix(n3_pt, y)
pot <- potential(
  x = n3_pt, y = y, d = d, var = "POP19",
  fun = "e", span = 200000, beta = 2
)
y$OUTPUT <- pot
equipot <- equipotential(y, var = "OUTPUT", mask = n3_poly)
plot(equipot["center"], pal = hcl.colors(nrow(equipot), "cividis"))
# }

Run the code above in your browser using DataLab