wdpa_fetch: Fetch WDPA files

View source: R/wdpa_fetch.R

wdpa_fetchR Documentation

Fetch WDPA files

Description

Fetch WDPA files

Usage

wdpa_fetch(id = NULL, type = "csv", overwrite = TRUE, ...)

Arguments

id

(numeric/integer) a WDPA site ID. if not given, we get all the data

type

(character) type of file, one of shapefile (default), kml, or csv

overwrite

(logical) Overwrite if exists. Default: TRUE

...

Further named parameters passed on to crul::HttpClient

Details

If you don't have the metadata file, we download it for you and read it in. After that we jus read the cached version. If for some reason that file is deleted, we'll detect it and download again.

The path file written to is managed via rw_cache. See rw_cache.

Uses readr::read_csv for csv and sf::read_sf for shp and kml internally

Value

varies depending on value of type parameter

Examples

## Not run: 
# a single site
wdpa_fetch(id = 76200, type = "csv")
wdpa_fetch(id = 76200, "shapefile")
wdpa_fetch(id = 76200, "kml")

# another id
wdpa_fetch(id = 2137, type = "csv")
wdpa_fetch(id = 2137, "shapefile")
wdpa_fetch(id = 2137, "kml")

# entire dataset, beware, very large
# wdpa_fetch()

## End(Not run)

ropenscilabs/rwdpa documentation built on May 18, 2022, 8:31 p.m.