Skip to content

Instantly share code, notes, and snippets.

@mtreg
Created July 13, 2023 14:56
Show Gist options
  • Save mtreg/12bb5588c0fa3d5ab12615979c0feae0 to your computer and use it in GitHub Desktop.
Save mtreg/12bb5588c0fa3d5ab12615979c0feae0 to your computer and use it in GitHub Desktop.
Load layer from gpkg in zipped folder within a Zenodo repository directly into R
# Example of loading data from gpkg in zipped folder on Zenodo into R
# Data from the repository 'The State of the Urban Forest in New York City - Supplemental Datasets'
# at https://zenodo.org/record/5210261
# Load sf package
library(sf)
# URL to Files on Zenodo
vurl <- "/vsizip//vsicurl/https://zenodo.org/record/5210261/files/canopy_streettree_summaries.zip/canopystreettree_supp.gpkg"
# Get layer names for next step
st_layers(vurl)
# Read in Layer by name
x <- st_read(vurl, "canopystreettree_supp_boro")
# Read in Layer by where it is in the vector of names from st_layers
x2 <- st_read(vurl, st_layers(vurl)$name[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment