Learn R Programming

pointdexter (version 0.1.1)

GetPolygonBoundaries: Obtains the boundaries of the polygon(s)

Description

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

Usage

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

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.

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).

See Also

  • ?pointdexter::city_boundary_spdf

  • ?pointdexter::city_boundary_sf

  • ?pointdexter::community_areas_spdf

  • ?pointdexter::community_areas_sf

Examples

Run this code
# NOT RUN {
## 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)
# }
# NOT RUN {
## sf, one polygon example ## -----

# load necessary package ----
library(sf)

# load necessary data ----
data("city_boundary_sf")

# obtain boundaries for the City of Chicago ----
boundaries <- GetPolygonBoundaries(my.polygon = city_boundary_sf)
# }
# NOT RUN {
# }
# NOT RUN {
## 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)
# }

Run the code above in your browser using DataLab