Created
June 11, 2018 11:58
-
-
Save scbrown86/ccf754217c9b4968c81241e305659f73 to your computer and use it in GitHub Desktop.
geoJSON to multilayer geopackage R
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
# Convert a GeoJSON object to a geopackage | |
# Add a second geoJSON object in as a second layer | |
# https://gis.stackexchange.com/q/223240/24249 | |
library(rgdal) | |
library(sf) | |
# Here I open a shapefile, but readOGR can be used to read geoJSON files | |
nc <- st_as_sf(readOGR(system.file("shape/nc.shp", package = "sf"))) | |
storms <- st_as_sf(readOGR(system.file("shape/storms_xyz.shp", package = "sf"))) | |
# Export, and add an extra layer | |
st_write(nc, "./export_geopackage.gpkg", "nc_state") | |
st_write(storms, "./export_geopackage.gpkg", "storms_state", update = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment