area2d: 2D surface area

View source: R/topography.R

area2dR Documentation

2D surface area

Description

Compute the area of a 2d projection on the (xy) plane.

Usage

area2d(mesh, method = "concave")

Arguments

mesh

object of class mesh3d

method

the method used to compute the hull of the 2d projection, either 'convex' (see chull), or 'concave' (see concaveman). The default method is 'concave'.

Value

A single 2D surface area value, corresponding to the footprint of the mesh.

See Also

rfi

Examples

#The following objects should have the exact same footprints:
area2d(dkmodel$basin)
area2d(dkmodel$complex)
area2d(dkmodel$cusp)
area2d(dkmodel$flat)

#Graphical rendering of convex hull
x <- dkmodel$cusp
FootprintVerts <- t(x$vb[1:2, ])
Hull <- grDevices::chull(x = FootprintVerts[, 1], y = FootprintVerts[, 2])
plot(x$vb[1, ], x$vb[2, ], xlab = "x", ylab = "y")
points(x$vb[1, Hull], x$vb[2, Hull], col = "orange1")

#Graphical rendering of concave hull
x <- dkmodel$cusp
FootprintVerts <- t(x$vb[1:2, ])
FootprintVerts[, 1] <- FootprintVerts[, 1] - min(FootprintVerts[, 1])
FootprintVerts[, 2] <- FootprintVerts[, 2] - min(FootprintVerts[, 2])
Hull <- concaveman::concaveman(points = FootprintVerts)
plot(x$vb[1, ] - min(x$vb[1, ]), x$vb[2, ] - min(x$vb[2, ]), xlab = "x", ylab = "y")
points(Hull, col = "green1")

doolkit documentation built on May 14, 2022, 9:05 a.m.