add.area: Add areas to a Spatial Polygons Data Frame

View source: R/spatial_manipulation.R

add.areaR Documentation

Add areas to a Spatial Polygons Data Frame

Description

This function takes a Spatial Polygons Data Frame and calculates and adds area fields to the data frame. Areas can be calculated either treating the whole SPDF as a unit or for each polygon individually.

Usage

add.area(spdf, area.ha = TRUE, area.sqkm = TRUE, byid = TRUE)

Arguments

spdf

Spatial Polygons Data Frame to calculate areas for.

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.

byid

Logical. If TRUE, areas will be calculated and added for each polygon by ID. If FALSE the area of the whole SPDF will be calculated and added, so every value for that field will be the same, regardless of polygon ID. Default is TRUE.

Value

The original Spatial Polygons Data Frame with an additional field for each area unit calculated.

Examples

add.area()

nstauffer/aim.analysis documentation built on Nov. 2, 2023, 12:52 a.m.