#' This function creates a dataframe from a shapefile using Team 1's solution
#'
#' @param file The full file path to your shapefile data.
#' @param tolerance A number indicating the tolerance used to thin the shapefile.
#' @export
#' @return Returns a dataframe.
#' @examples
#' datapath <- system.file("extdata", "gadm36_AUS_shp/gadm36_AUS_1.shp", package = "STAT585.Lab3.Group8.2019")
#' australia <- team_1(datapath, tolerance = 0.01)
team_1 <- function(file, tolerance){
checkmate::assertNumber(tolerance, lower = 0, upper = 1) # Check to see if tolerance is a single number
checkmate::assertCharacter(file) # Assert that file is a character string
assertthat::assert_that(file.exists(file), msg = "File does not exist. Please enter a valid file name")
unthinned.list <- read_sf(file) # unthinned list object, must thin
thinned.list <- maptools::thinnedSpatialPoly(as(unthinned.list, "Spatial"),
tolerance = tolerance,
minarea = 0.001,
topologyPreserve = TRUE)
reformed.object <- st_as_sf(thinned.list) # Now in usable thinned format
# GENERIC CODE ENDS HERE NOW TEAM SPECIFIC CODE
df.oz.purr <- reformed.object$geometry %>%
purrr::map_depth(3, data.frame) %>%
purrr::flatten() %>%
purrr::flatten() %>%
dplyr::bind_rows(.id = "group") %>%
dplyr::rename("lat" = y, "long" = x)
df.oz.purr
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.