Description Usage Arguments Details Value Examples
Function based on the work by lab group 5 that converts a country shape file into a dataframe.
1 |
file |
This is the shape file that will be converted to a datafarme. It can either be a file path in the form of a character string (ends in .shp) or a sf shape file object created using the sf package with a geometry type of multipolygon. |
tolerance |
This controls how much the shape file is thinned. The larger it is made the less detail the shape file will have. The tolerance is set to 0.1 by default. |
The variables included in the dataframe that is returned from team_5
are as follows.
country = country depicted by the data
group = indicates which polygon a set of points corresponds to
order = order in which the points in a polygon should be arranged
long = longitude of the point
lat = latitude of the point
A dataframe created from the shape file. See the details for the variables included in the dataframe.
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_5 function to convert the shape file to a dataframe
puerto_rico_df <- team_5(puerto_rico, 0.001)
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()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.