#' unzipShapefiles
#'
#' Unzips compressed files containing ESRI shapefiles from the
#' 'data-raw' folder of the OFPEDATA package. Takes a zipped file
#' name and returns a 'sf' object.
#'
#' @param path character
#' @param zip_file character
#'
#' @return sf
#'
#' @importFrom magrittr %>%
#'
#' @examples
#' \dontrun{
#' unzipShapefiles("zipped_data_filename", "path/to/data")
#' }
#'
#' @export
unzipShapefiles <- function(zip_file, path) {
temp <- tempfile()
utils::unzip(paste0(path, zip_file), exdir = temp)
temp_files <- list.files(temp, full.names = TRUE)
temp_shp_name <- temp_files[grep(".shp", temp_files)]
unzipped <- sf::read_sf(temp_shp_name) %>%
sf::st_zm()
return(unzipped)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.