GetPolygonBoundaries() returns the longitudinal and latitudinal points - coordinate pairs - that make up the boundary of the polygon.

GetPolygonBoundaries(my.polygon, labels)

Arguments

my.polygon

Either a SpatialPolygonsDataFrame data or a sf object. See ?sp::`SpatialPolygonsDataFrame-class` or help(package = "sf") for more help.

labels

A character vector of polygon boundary labels used to name each matrix

Details

my.polygon accepts a spatial object that contains a singular polygon (i.e. the boundary of the City of Chicago) or many polygons (i.e. a polygon for each the 77 Chicago community areas).

Value

If my.polygon is of length 1, a matrix of coordinate pairs will be returned; otherwise, a list of labeled matrices, with each matrix representing the coordinate pairs that make the boundary of each particular polygon in my.polygon.

See also

Examples

## SpatialPolygonsDataFrame, one polygon example ## ----- # load necessary data ---- data("city_boundary_spdf") # obtain boundaries for the City of Chicago ---- boundaries <- GetPolygonBoundaries(my.polygon = city_boundary_spdf) ## SpatialPolygonsDataFrame, multipolygon polygon example ## ----- # load necessary data ---- data("community_areas_spdf") # obtain boundaries for each of the 77 Chicago community areas ---- boundaries <- GetPolygonBoundaries(my.polygon = community_areas_spdf , labels = community_areas_spdf$community)
## sf, one polygon example ## ----- # load necessary package ---- library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.3, PROJ 4.9.3
# load necessary data ---- data("city_boundary_sf") # obtain boundaries for the City of Chicago ---- boundaries <- GetPolygonBoundaries(my.polygon = city_boundary_sf)
## sf, multipolygon example ## ----- # load necessary package ---- library(sf) # load necessary data ---- data("community_areas_sf") # obtain boundaries for each of the 77 Chicago community areas ---- boundaries <- GetPolygonBoundaries(my.polygon = community_areas_sf , labels = community_areas_sf$community)