add_area: Add areas to a polygon or multipolygon sf object

View source: R/spatial_manipulation.R

add_areaR Documentation

Add areas to a polygon or multipolygon sf object

Description

This function takes a polygon or multipolygon sf object and calculates and adds area fields to the data frame. It will always add square meters, but may additionally add square kilometers and hectares as well.

Usage

add_area(polygons, area_ha = TRUE, area_sqkm = TRUE, byid = TRUE)

Arguments

polygons

Polygon or multipolygon sf object. These are the polygons to add the area variables to. Areas will be added to each observation in the attributes, so make sure that polygons are "dissolved" by their identities before calculating areas.

area_ha

Logical. If TRUE, areas will be calculated and added in hectares. Default is TRUE.

area_sqkm

Logical. If TRUE, areas will be calculated and added in square kilometers. Default is TRUE.

Value

The original sf object with an additional field for each area unit calculated, always with at least "area_sqm".


nstauffer/aim.analysis documentation built on Oct. 9, 2024, 2:41 a.m.