Last active
March 24, 2024 04:56
-
-
Save kadyb/69b55caca364ea7f6a8167079d78772f to your computer and use it in GitHub Desktop.
Directly load and save zipped shapefiles in {sf}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("sf") | |
file = system.file("shape/nc.shp", package = "sf") | |
shp = read_sf(file) | |
## write zipped shapefile | |
write_sf(shp, "myshapefile.shp.zip", driver = "ESRI Shapefile") | |
## read zipped shapefile | |
read_sf("myshapefile.shp.zip") | |
## read zipped shapefile using `vsizip` | |
## see: https://gdal.org/user/virtual_file_systems.html | |
f = paste0("/vsizip/", "myshapefile.shp.zip") | |
read_sf(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment