Overview


The R package {worldpa} is an interface to the World Database on Protected Areas (WDPA) hosted on the Protected Planet website: https://www.protectedplanet.net. It allows users to download spatial layers of terrestrial and marine protected areas (PA) for world countries using the WDPA API (https://api.protectedplanet.net).

This package contains three main functions:


This package is not yet hosted on the CRAN but you can install it from GitHub:

# install.packages("remotes")
remotes::install_github("FRBCesab/worldpa")


Managing WDPA API Token


This package uses the WDPA API to access data on the World protected areas. You must first have obtained a Personal API PAT by filling in the form available at: https://api.protectedplanet.net/request. Once you have obtained this token, you must store it on your computer. As recommended by Hadley Wickham in his Managing secrets vignette, you can store your API PAT as an R Environment variable (a name-value pairs) listed in the .Renviron file in your home directory.

Use the function usethis::edit_r_environ() to open this file and add this line (by replacing z999zzz... with your Personal WDPA API Token):

WDPA_KEY='z999zzz9zzz999999z9z99zz999zz999'

Save the file and relaunch R.

Now, let's check if your Personal WDPA API Token is correctly stored in your .Renviron file by using the function get_token():

## Check if User's Token is correctly stored ----
worldpa::get_token()

## [1] "z999zzz9zzz999999z9z99zz999zz999"


Getting Countries Information


The internal dataset wdpa_countries contains information on world countries (country and UNEP region names, ISO code and number of protected areas).

data("wdpa_countries", package = "worldpa")

##    region_name region_iso2             country_name country_iso3 pas_count
## 1       Africa          AF                  Algeria          DZA        78
## 2       Africa          AF                   Angola          AGO        14
## 3       Africa          AF                    Benin          BEN        64
## 4       Africa          AF                 Botswana          BWA        22
## 5       Africa          AF             Burkina Faso          BFA       112
## 6       Africa          AF                  Burundi          BDI        21
## 7       Africa          AF               Cabo Verde          CPV         7
## 8       Africa          AF                 Cameroon          CMR        49
## 9       Africa          AF Central African Republic          CAF        38
## 10      Africa          AF                     Chad          TCD        23


As the WDPA is updated every month, you can get an updated version of this dataset by using the function get_countries():

## Get UNEP-WCMC World Countries Information ----
worldpa::get_countries()


Downloading Protected Areas


Now, let's use the function get_wdpa() to download protected areas for Georgia.

## Get Georgia ISO-3 Code ----
wdpa_countries[grep("Georgia", wdpa_countries$"country_name"), 3:4]

##                                     country_name country_iso3
## 133                                      Georgia          GEO
## 235 South Georgia and the South Sandwich Islands          SGS

# Download Georgia PA ----
pa_sf <- worldpa::get_wdpa(isocode = "GEO")

The returned object is a sf object (GEOMETRY) of protected areas defined in the EPSG 4326. Type ?get_wdpa to get more information about the attributes. The function get_wdpa() has also exported the protected areas as a geopackage (.gpkg). User can import this layer with the function sf::st_read().


If you have any question, please open an issue at: https://github.com/frbcesab/worldpa/issues



FRBCesab/worldpa documentation built on Feb. 26, 2021, 2:38 a.m.