union_polygons: Aggregate Polygons in a SpatialPolygonsDataFrame object

Description Usage Arguments Value Examples

Description

Aggregate Polygons in a SpatialPolygonsDataFrame object, based on a vector (new_id) of the same length of the number of polygons in the starting SpatialPolygonsDataFrame (argument .sp).

Usage

1
union_polygons(.sp, new_id)

Arguments

.sp

SpatialPolygonsDataFrame

new_id

A vector defining the output Polygons objects, equal in length to the length of the polygons slot of .sp; it may be character, integer, or factor

Value

an object of class SpatialPolygonsDataFrame

Examples

1
2
3
4
5
6
7
8
data(g1k15)

# Transform data frame g1k15 in a SpatialPolygonsDataFrame
g1k15_sp <- tidy2sp(g1k15)

# Create a new SpatialPolygonsDataFrame, aggregating the polygons based on the GRNR (grand regions)
g1k15_sp_union <- union_polygons(g1k15_sp, new_id = g1k15_sp@data$GRNR)
str(g1k15_sp_union)

gibonet/tidy2spatial documentation built on May 17, 2019, 4:20 a.m.