Skip to contents

Save a `sf` as a shapefile to disk

Usage

saveShapefile(shape, mapId, dir = getwd(), overwrite = FALSE)

Arguments

shape

the sf shape

mapId

a mapId - will become the zip filename, and the filename of the zipped `.shp` file

dir

the directory (defaults to current working directory)

overwrite

the save function will not write over existing files unless this is set to true

Value

a the filename of the zipped shapefile

Examples

if (interactive()) {
  svc = "https://services1.arcgis.com/ESMARspQHYMw9BZ9/ArcGIS/rest/services"
  fs = sprintf("%s/%s",svc,"Countries_December_2024_Boundaries_UK_BUC/FeatureServer")
  layer = sprintf("%s/%s",fs,"0")
  map = downloadGeojson(layer)
  map %>% dplyr::glimpse()
  map2 = map %>% standardiseMap(codeCol = CTRY24CD, nameCol = CTRY24NM)
  map2 %>% dplyr::glimpse()
  saveShapefile(map2, "ctry24", dir = tempdir())
}