Skip to content

Instantly share code, notes, and snippets.

@gtm19
Last active June 20, 2019 08:17
Show Gist options
  • Save gtm19/d3f57b88c7d496cb76be768eb76ca8e3 to your computer and use it in GitHub Desktop.
Save gtm19/d3f57b88c7d496cb76be768eb76ca8e3 to your computer and use it in GitHub Desktop.
Example code to download shapefile from NSIDC website
library(tidyverse)
library(sf)
url <- "ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/north/monthly/shapefiles/shp_extent/12_Dec/extent_N_201012_polygon_v3.0.zip"
tempdir <- tempdir(check = TRUE)
tempfile <- tempfile()
download.file(url, tempfile, mode = "wb")
unzipped <- unzip(tempfile, exdir = tempdir)
sf <- read_sf(unzipped[grepl(".shp$", unzipped)]) %>%
summarise()
unlink(tempdir, recursive = TRUE, force = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment