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'.

Details

This function can assess 2D surface area of the projection of a mesh on the (xy) plane. The projection is assimilated to a hull, which can be a convex hull (see chull) or a concave hull (see concaveman). Note that if your mesh is a combination of two or more discontinuous surfaces (e.g., isolated cusps), you should not use either approach. As of version 1.42.2, the concave hull fails intermittently on Mac systems, so the function defaults to convex hulls (on other systems, it defaults to concave hulls)

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 Feb. 16, 2023, 11 p.m.