Learn R Programming

habtools (version 1.1.1)

perimeter: Calculate perimeter of a 2D shape

Description

Calculates the perimeter of a 2D shape.

Usage

perimeter(data, keep_data = FALSE)

Value

The perimeter.

Arguments

data

A data frame with the first two columns ordered x and y coordinates.

keep_data

Logical. Keep lengths of all segments of the perimeter? Defaults to FALSE.

Examples

Run this code
mcap_2d <- mesh_to_2d(mcap)
plot(mcap_2d)

perimeter(mcap_2d)

r <- 1 # radius
circ <- sim_circle(r=r) # simulate xy coordinates for a circle of radius 1
plot(circ, asp=1)
perimeter(circ)

2 * pi * r # Note xy resolution affects output

Run the code above in your browser using DataLab