team_1: Impletement the Team 1 Solution in Lab 2

Description Usage Arguments Value Examples

Description

This function need a file path as an input to read the .shp file, and it will extract the geometry information to the top level.

Usage

1
team_1(file, tolerance = 0.1)

Arguments

file

A path to the .shp file. Or a loaded sf shape file created using sf package with a geometry type of mutipolygon. If a loaded sf shape is supplied, the the tolerance is turned off.

tolerance

The value used to thin the data.

Value

A data.frame with the geometry information extracted to the top level. All other columns are kept. The new columns are as follows:

listno The orginal rows that the expanded data coming from.
long Longitude.
lat Latitude.
group The group used to draw polygen.
order The order for the points within group.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# A shape file for Puerto Rico is already stored in the package
puerto_rico

# Use the team_1 function to convert the shape file to a dataframe
puerto_rico_df <- team_1(puerto_rico)
head(puerto_rico_df)

# Create a plot of Puerto Rico using the dataframe
library(ggplot2)
ggplot(puerto_rico_df, aes(x = long, y = lat, group = group)) + geom_polygon()

yaweige/lab3group3 documentation built on May 28, 2019, 12:23 p.m.