Given a sanctuary code or link (ie URL), download the zip, unzip it, and read first shapefile as a spatial feature. This function was originally designed to pull from one of the zip links found at NOAA Sanctuaries GIS.

get_url_ply(
  sanctuary = NULL,
  url = NULL,
  dir_ply = here::here("data_ss/ply"),
  verbose = F
)

Arguments

sanctuary

NOAA Sanctuary code with which to form url. Sanctuary codes can be found at NOAA Sanctuaries GIS.

url

Link from which to fetch a polygon. Originally designed to pull from one of the zip links found at NOAA Sanctuaries GIS.

dir_ply

Directory to download locally into. This directory serves as a cache to skip operations if already performed. If zip file exists, skip downloading. If directory to unzip exists, skip unzipping.

verbose

Verbose messages describing operations and choices, such as skipping download or unzip and which shapefile used if more than one found.

Value

Returns a spatial feature sf polygon data frame.

Examples

# mbnms: Monterey Bay National Marine Sanctuary ply_mbnms <- get_url_ply(sanctuary = "mbnms") ply_mbnms
#> Geometry set for 1 feature #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -123.1401 ymin: 35.5 xmax: -121.1036 ymax: 37.88163 #> Geodetic CRS: WGS 84
#> MULTIPOLYGON (((-122.5 35.5, -123 35.5, -123 35...
plot(ply_mbnms[1])
# fknms: Florida Keys National Marine Sanctuary ply_fknms <- get_url_ply(sanctuary = "fknms") ply_fknms
#> Geometry set for 1 feature #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -83.14989 ymin: 24.30041 xmax: -80.06647 ymax: 25.65046 #> Geodetic CRS: WGS 84
#> MULTIPOLYGON (((-83.14989 24.30041, -83.14988 2...
plot(ply_fknms[1])