wdpa_fetch {wdpar} | R Documentation |
Fetch data
Description
Fetch data from Protected Planet. Specifically, data are downloaded from the World Database on Protected Areas (WDPA) and the World Database on Other Effective Area-Based Conservation Measures (WDOECM). Note that data are downloaded assuming non-commercial use.
Usage
wdpa_fetch(
x,
wait = FALSE,
download_dir = tempdir(),
force_download = FALSE,
check_version = TRUE,
n = NULL,
page_wait = 2,
verbose = interactive()
)
Arguments
x |
|
wait |
|
download_dir |
|
force_download |
|
check_version |
|
n |
|
page_wait |
|
verbose |
|
Details
This function obtains and imports data from Protected Planet.
By default (per force_download = FALSE
), it will check to see if the
data have already been downloaded and, if so, simply import the previously
downloaded data.
It will also check to see if a newer version of the dataset is available
on Protected Planet (per check_version = TRUE
) and, if so, provide an
alert.
If the latest version is not required, this alert can be safely ignored.
However, if the latest version of the data is required,
then using force_download = TRUE
will ensure that the latest version
is always obtained.
After importing the data, it is strongly recommended to clean the data
prior to analysis (see wdpa_clean()
).
Value
sf::sf()
object.
Data source
The PA_DEF
column indicates the data source for individual
areas and sites that comprise the imported dataset.
Specifically, data obtained through the World Database on Protected Areas
(WDPA) are indicated with a value of 1
in the PA_DEF
column.
Additionally, data obtained through the World Database on Other Effective
Area-Based Conservation Measures (WDOECM) are indicated with a value of 0
in the PA_DEF
column.
For more details on data conventions, please consult the official manual
(UNEP-WCMC 2019).
Troubleshooting
This function will sometimes return the error message
PhantomJS signals port = 4567 is already in use
.
This error message can occur when you have previously run the function and
it threw an error, or it terminated early.
It can also occur when attempting to run the the function in multiple
sessions on the same computer.
To address this issue, you will need to restart your computer.
References
UNEP-WCMC (2019). User Manual for the World Database on Protected Areas and world database on other effective area-based conservation measures: 1.6. UNEP-WCMC: Cambridge, UK. Available at: https://wcmc.io/WDPA_Manual.
See Also
wdpa_clean()
, wdpa_read()
,
wdpa_url()
, countrycode::countrycode()
.
Examples
## Not run:
# fetch data for Liechtenstein
lie_raw_data <- wdpa_fetch("Liechtenstein", wait = TRUE)
# print data
print(lie_raw_data)
# plot data
plot(lie_raw_data)
# fetch data for Liechtenstein using the ISO3 code
lie_raw_data <- wdpa_fetch("LIE", wait = TRUE)
# since data are saved in a temporary directory by default,
# a persistent directory can be specified to avoid having to download the
# same dataset every time the R session is restarted
lie_raw_data <- wdpa_fetch("LIE", wait = TRUE,
download_dir = rappdirs::user_data_dir("wdpar"))
# data for multiple countries can be downloaded separately and combined,
# this is useful to avoid having to download the global dataset
## load packages to easily merge datasets
library(dplyr)
library(tibble)
## define country names to download
country_codes <- c("LIE", "MHL")
## download data for each country
mult_data <- lapply(country_codes, wdpa_fetch, wait = TRUE)
## merge datasets together
mult_dat <- st_as_sf(as_tibble(bind_rows(mult_data)))
## print data
print(mult_dat)
## End(Not run)