Last updated: 2021-03-05

Checks: 6 1

Knit directory: mapme.protectedareas/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210305) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 28fb9d5. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/
    Ignored:    mapme.protectedareas.Rproj
    Ignored:    renv/library/
    Ignored:    renv/local/

Untracked files:
    Untracked:  analysis/shiny-test.Rmd

Unstaged changes:
    Modified:   analysis/dopa-rest.rmd
    Modified:   analysis/index.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/dopa-rest.rmd) and HTML (docs/dopa-rest.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 516d799 Johannes Schielein 2021-03-05 create workflow r website
html 516d799 Johannes Schielein 2021-03-05 create workflow r website
Rmd e410b62 Johannes Schielein 2021-03-05 new init commit with new datastructure for improved reproduciblity

Introduction

The Digital Observatory for Protected Areas (DOPA) is an initiative from the Joint Research Centre (JRC) of the European Commission. It is database and a web-based information system on Protected Areas (PAs) providing information on the global level. DOPA processes maintains several datasets that characterize PAs according to e.g. biodiversity and land use wich can be accessed through REST API. The script dopa-rest.R provides different functions to access the datasets and download them temporary in CSV format to then create a dataframe for further uste in R. Please not that all the functions work with the Unique Identifier of Protected Areas according to the IUCN/WDPA, where you can also identify the WDPA ID of your area of interest.

The functions listed in the dopa-rest.R are: get_redlist_status, redlist_list, wdpalevel_centroid, water_stats, all_indicators, landcover_change, landcover_esa, lcc_percent, landcover_copernicus, normalizedind_country, normalizedind_ecoregion and get_dopa.

At first you might want to load the source functions for this routine.

source("code/dopa-rest.R")

Get IUCN Redlist Status

get_redlist_status takes the WDPA Identifier (wdpaid) as an argument. The function returns statistics (counts species, by class and by IUCN categories) for species (Corals, Sharks & Rays, Amphibians, Birds, Mammals) in the given PA as well as their status according to the redlist at the moment in time, when the data was processed by DOPA (for more information visit the DOPA website). The data is calculated as an intersection of species habitats with WDPA.

Some information on this dataset:

  • Data source: IUCN Redlist
  • Spatial Coverage: Global
  • Spatial Resolution: 5 km
  • Temporal Coverage: 1964-2020
  • Temporal Resolution: Biannual updates
  • Metadata Link

How to use the function? - Pass the wdpaid of the protected area to download on species enlisted in IUCN redlist within a given protected area. - Example usage:

#This code generates species status' statistics for the PA with wdpaid 146 and shows it in a paged table for the markdown.
df_redlist_status<-
    get_redlist_status(wdpaid = 146)

With the results table looking like this:

You can also process several areas at once using the plyr package

library(plyr)
# get data
df_redlist_status<-
    ldply(.data = c(146,147),.fun = get_redlist_status)

With the results table looking like this:

If you want to combine this data with georeferenced information from WDPA to create maps you might consider using the wdpar package from CRAN that creates an interface to WDPA or you might want to download the data manually and join it in R. In the following we show an example on how to use the wdpar package. You will first need to download the data for the country where your PA is located, then preprocess/clean the data, and then merge it.

Get Species in PA

  1. get_species_list takes wdpaid as argument. It returns a list of species (Corals, Sharks & Rays, Amphibians, Birds, Mammals) which habitat areas intersect with the Protected Area according to data from IUCN.

Some information on this dataset:

  • Data source: IUCN
  • Spatial Coverage: Global
  • Spatial Resolution: 5 km
  • Temporal Coverage: 1964-2020
  • Temporal Resolution: Biannual updates
  • Metadata Link

How to use the function? - Pass the wdpaid of the protected area to generate list of available species enlisted in IUCN redlist within it - Example usage:

#This code generates species lists for the PA with wdpaid 63645
source("code/dopa-rest.R")
df_species<-get_species_list(63645)

With the results table looking like this:

Get Centroid of the PA

  1. wdpalevel_centroid takes wdpaid as argument and returns the centroid of the WDPA poylgon (x,y) in EPSG 4326 (Lat Long WGS84). For polygon PAs centroids are calculated with the function ST_PointOnSurface, which returns a point guaranteed to lie on the surface.

How to use the function? - Pass the wdpaid of the protected area to generate it’s point coordinates; for polygon to generate centroid coordinates - Example usage:

#This code generates the point coordinates for the PA with wdpaid 555528898
df_wdpa_level_centroid<-
  get_wdpa_level_centroid(555528898)

With the results table looking like this:

  1. water_stats takes wdpaid as argument. Returns information on the current surface area of permanent and seasonal water, and the net change over the period 1984-2015.

    Data source: Global Surface Water Explorer Spatial Coverage: Global Spatial Resolution: 30 m Temporal Coverage: 1984-2019 Temporal Resolution: Perioic updates
    Metadata Link

    How to use the function?

    • Pass the wdpaid of the protected area to generate the water statistics within it
    • Example usage:
#This code generates the water statistics for the PA with wdpaid 671
paged_table(get_water_stats(671))
  1. all_indicators takes wdpaid as argument. Returns all indicators for Protected Areas.

    How to use the function?

    • Pass the wdpaid of the area to generate all the possible indicators’ values available within the PA
    • Example usage:
#This code generates all the indicators available for the PA with wdpaid 142
paged_table(get_all_indicators(142))
  1. landcover_change takes wdpaid as argument. Returns absolute cover of ESA LC CCI classes (aggregated by level 1: 4 classes) which changed within first and last epoch i.e. 1995 & 2015 for a given WDPA.

    Data source: ESA CCI Land Cover Spatial Coverage: Global Spatial Resolution: 300 m Temporal Coverage: 1992-2015 Temporal Resolution: Annual updates
    Metadata Link

    How to use the function?

    • Pass the wdpaid of the area to generate landcover change statistics between 1995 & 2015 for that PA
    • Example usage:
#This code generates the absolute landcover change of ESA Land Cover classes for the PA with wdpaid 32671 between 1995 & 2015
paged_table(get_landcover_esa(32671,year = 2000,agg=0))
  1. landcover_esa takes wdpaid, year (1995,2000,2005,2010,2015), and aggregation level (0,1,2,3) as arguments. Returns percentage and absolute cover of different ESA CCI LC classes for a given WDPA Aggregation levels 0 (original ESA LC classes), 1, 2 and 3 are available.

    Data source: ESA CCI Land Cover Spatial Coverage: Global Spatial Resolution: 300 m Temporal Coverage: 1992-2015 Temporal Resolution: Annual updates
    Metadata Link

    How to use the function?

    • Pass the wdpaid of the area to generate ESA landcover statistics for that PA
    • Pass the desired year
    • Pass the desired aggregation level
    • Example usage:
#This code generates percentage and absolute cover of ESA Land Cover classes for the PA with wdpaid 32671 for the year 2015 and at 0 aggregation level
paged_table(get_landcover_esa(32671, 2015, 0))
  1. lcc_percent takes wdpaid as argument. Returns percentage and absolute cover of ESA LC CCI classes which changed within first and last epoch for a given WDPA.

    Data source: ESA CCI Land Cover Spatial Coverage: Global Spatial Resolution: 300 m Temporal Coverage: 1992-2015 Temporal Resolution: Annual updates
    Metadata Link

    How to use the function?

    • Pass the wdpaid of the area to generate ESA landcover change percentage for that PA
    • Example usage:
#This code generates percentage and absolute cover of ESA Land Cover classes which changed between 1995 & 2015 for the PA with wdpaid 32671
paged_table(get_lcc_esa_percent(32671))
  1. landcover_copernicus takes wdpaid and aggregation level (0,2) as arguments. Returns percentage and absolute cover of Copernicus Land Cover classes for a given WDPA aggregation levels 0 (original Copernicus LC classes) and 2 (DOPA) are available.

    Data source: Copernicus Global Land Cover Spatial Coverage: Global Spatial Resolution: 100 m Temporal Coverage: 2015-2019 Temporal Resolution: Annual updates
    Metadata Link

    How to use the function?

    • Pass the wdpaid of the area to generate Copernicus landcover statistics for that PA
    • Example usage:
#This code generates percentage and absolute cover of Copernicus Land Cover classes for the PA with wdpaid 32671 and 2 aggregation level
paged_table(get_landcover_copernicus(32671, 2))
  1. normalizedind_country takes an indicator as argument, one among the listed many in all_indicators. Returns, for protected area in country, absolute, normalized and average value of the selected indicator, and ranking within the country.

    How to use the function?

    • Pass the indicator’s name to generate the associated normalized values at the country level
    • Example usage:
#This code generates normalized agriculture indicators at the country level
paged_table(get_country_pa_normalized_ind("agri_ind_pa"))
  1. normalizedind_ecoregion takes an indicator as argument, one among the listed many in all_indicators and ecoregion id as arguments. Returns, for protected area in ecoregion, absolute, normalized and average value of the selected indicator, and ranking within the ecoregion.

    How to use the function?

    • Pass the indicator’s name to generate the associated normalized values at the ecoregion level
    • Pass the desired ecoregion id
    • Example usage:
#This code generates normalized agriculture indicators at the ecoregion level for the ecoregion with ecoregionid 16
paged_table(get_ecoregion_pa_normalized_ind("agri_ind_pa", 16))
  1. get_dopa is a global function and takes topic, getQuery and wdpaid as arguments. Topics include: “protected_sites”, “species”, “water”, “landcover”
    getQuery include “get_wdpa_level_centroid”, “get_pa_water_stats”, “get_pa_redlist_status”, “get_pa_redlist_list”, “get_wdpa_all_inds”, “get_wdpa_lcc_esa”, “get_wdpa_lcc_esa_percent”

    Returns the desired variables in CSV format.

    How to use the function?

    • Pass the topic’s name associated with getQuery parameter
    • Pass the desired getQuery parameter
    • Pass the wdpaid to generate variables within the desired PA
    • Example usage:
#This code generates redlist status of species for the PA with wdpaid 146
paged_table(get_dopa("species", "get_pa_redlist_status", 146))

Methods

References


sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plyr_1.8.6    rmarkdown_2.5 knitr_1.30   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6      rstudioapi_0.13 whisker_0.4     magrittr_2.0.1 
 [5] workflowr_1.6.2 R6_2.5.0        rlang_0.4.9     stringr_1.4.0  
 [9] tools_4.0.3     xfun_0.19       git2r_0.27.1    htmltools_0.5.0
[13] ellipsis_0.3.1  yaml_2.2.1      digest_0.6.27   rprojroot_2.0.2
[17] tibble_3.0.4    lifecycle_0.2.0 crayon_1.3.4    later_1.1.0.1  
[21] vctrs_0.3.5     promises_1.1.1  fs_1.5.0        glue_1.4.2     
[25] evaluate_0.14   stringi_1.5.3   compiler_4.0.3  pillar_1.4.7   
[29] jsonlite_1.7.1  httpuv_1.5.4    pkgconfig_2.0.3