order_polygons: Order polygons according to size

View source: R/spatial_manipulation.R

order_polygonsR Documentation

Order polygons according to size

Description

For a spatial polygons data frame or list of spatial polygons data frames, return character vector of all the unique identifiers in either ascending or descending order of area. If the unique identifiers have more than on observation associated with them, their polygons are combined into a single observation before the areas are calculated. If no variable for unique identifiers is provided, then all polygons in each spatial polygons data frame provided are considered to be a single observation; note that this is inappropriate unless providing a list of SPDFs. In the case of a list of SPDFs either the variable containing unique identifiers must be named identically for all (in which case there can be more than one polygon identity recognized in each) or no variable provided (in which case each SPDF will be dissolved to a single observation and assigned an identity based on the list's names or if the list is unnamed using the index of the SPDF in the list).

Usage

order_polygons(polygons, id_var = NULL, order = "ascending")

Arguments

polygons

Spatial Polygons Data Frame or list of Spatial Polygons Data Frames. If only a single SPDF, it must have at least the variable matching the value of id_var. If a list of SPDFs and using id_var then every SPDF must contain that variable, otherwise each SPDF will be dissolved and assigned the ID corresponding to the list index it occupies or, if the list is named, the name.

id_var

Optional character string. Must match the name of the variable in every SPDF in polygons@data that contains the unique identifiers to dissolve along. Must provide if polygons is a single SPDF. Defaults to NULL.

order

Charcter string. Either "ascending" or "descending" which determines the order to sort polygons in according to their areas. Defaults to "ascending".

Value

Vector of unique identifiers.


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