Last updated: 2021-07-01
Checks: 7 0
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.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
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 364ae4b. 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: .RData
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data-raw/addons/docs/rest/
Ignored: data-raw/addons/etc/
Ignored: data-raw/addons/scripts/
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 (public/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 |
---|---|---|---|---|
html | dd5c325 | Johannes Schielein | 2021-06-30 | Build site. |
html | 8bd1321 | Johannes Schielein | 2021-06-30 | Host with GitLab. |
html | 3a39ee3 | Johannes Schielein | 2021-06-30 | Host with GitHub. |
html | ae67dca | Johannes Schielein | 2021-06-30 | Host with GitLab. |
Rmd | 8fbb91d | Om Bandhari | 2021-06-29 | update rmd analysis |
Rmd | d78274c | Johannes Schielein | 2021-03-15 | minor changes to the DOPA API workflows |
Rmd | f4b731d | Johannes Schielein | 2021-03-05 | upate readme and some minor changes to dopa rest |
Rmd | 84652b1 | Johannes Schielein | 2021-03-05 | shiny test |
Rmd | 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 |
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 script dopa-rest.R
are: get_redlist_status
, get_species_list
, get_wdpa_level_centroid
, get_water_stats
, get_multiple_indicators
, get_lcc_esa
, get_landcover_esa
, get_lcc_esa_percent
, get_landcover_copernicus
, get_country_pa_normalized_ind
, get_ecoregion_pa_normalized_ind
and get_dopa
.
At first you might want to load the source functions for this routine.
source("code/dopa-rest.R")
Now, we will go through every functions on how to use them to access DOPA variables.
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:
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:
# the script generates species status' statistics for the PA with wdpaid 146
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 dplyr
package.
df_redlist_status<-
lapply(c(146,147),
FUN = get_redlist_status)%>%
bind_rows()
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,if necessary.
Lets have a look on how wdpar
package works.
# get PA polygon for country Brazil
brazil <-
wdpar::wdpa_fetch("BRA")
Since there are more than 3000 enlisted protected areas in Brazil, we want to compute zonal statistics only for the polygon data of: - Reserva Biologica Do Rio Trombetas - wdpaid 43
For this, we have to subset the country level polygon data to the pa level.
# subset wdpa polygon by its wdpa id
brazil_subset <-
brazil%>%
filter(WDPAID %in% 43)
Now, using the polygon, we can also access the DOPA variables like this:
# the script generates species status' statistics for the PA with wdpaid 43
df_redlist_status<-
get_redlist_status(brazil_subset$WDPAID[1])
# the result table
paged_table(df_redlist_status)
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:
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:
# the script generates species lists for the PA with wdpaid 63645
df_species<-
get_species_list(63645)
# With the results table looking like this:
paged_table(df_species)
The function get_wdpa_level_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:
# the script 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:
The function get_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.
You can use the function in the same way as the functions before by providing a WDPA ID to download the data for a specific area.
# the script generates the water statistics for the PA with wdpaid 671
df_water_stats<-
get_water_stats(671)
with the results table looking like this:
The function get_multiple_indicators
takes wdpaid as argument and returns several indicators for the PAs. As always you just have to provide the WDPA ID.
#This code generates all the indicators available for the PA with wdpaid 142
df_multiple_indicators<-
get_multiple_indicators(142)
with the results table looking like this:
The function get_lcc_esa
takes wdpaid as argument and 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 PA.
Aggregation level defines the level of classification details. For eg. aggregation level 0 will have more detailed classes (forests divided into open, closed, etc.) whereas aggregation level 2 will have only the class forest without further detailed classification. Thus, number of classes decreases with the increase in aggregation level.
How to use the function? - Pass the wdpaid of the area to generate landcover change statistics between 1995 & 2015 - Example usage:
# the script generates the absolute landcover change of ESA Land Cover classes for the PA with wdpaid 32671 between 1995 & 2015
df_landcover_esa<-
get_lcc_esa(32671)
with the resulting table looking like this:
get_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.
How to use the function? - Pass the wdpaid of the area to generate ESA landcover statistics for the particular PA - Pass the desired year - Pass the desired aggregation level - Example usage:
# the script 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))
get_lcc_esa_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]("http://maps.elie.ucl.ac.be/CCI/viewer/download/ESACCI-LC-Ph2-PUGv2_2.0.pdf")
How to use the function?
- Pass the wdpaid of the area to generate ESA landcover change percentage for that PA
- Example usage:
# the script 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))
get_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:
# the script generates percentage and absolute cover of Copernicus Land Cover classes for the PA with wdpaid 32671 and 0 aggregation level
paged_table(get_landcover_copernicus(32671,
0))
get_country_pa_normalized_ind
takes an indicator as one argument, one among the listed many in get_multiple_indicators
and country ISO code as another. 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 - Pass the ISO code of country - Example usage:
# the script generates normalized agriculture indicators at the country level
df_norm <-
get_country_pa_normalized_ind("agri_ind_pa", "VEN")
# with results table
paged_table(df_norm)
get_ecoregion_pa_normalized_ind
takes an indicator as argument, one among the listed many in get_multiple_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:
# the script 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))
With get_dopa
we can get the results for the seven different getQueries for which there are seven different functions created above. Since, topic and getQuery should come in sequence. Here I have listed the getQueries and their respective topic to use. (a) species - get_pa_redlist_status - get_pa_redlist_list
water - get_pa_water_stats
protected_sites - get_wdpa_level_centroid - get_wdpa_all_inds
landcover - 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:
# the script generates redlist status of species for the PA with wdpaid 146
paged_table(get_dopa("species",
"get_pa_redlist_status",
146))
DOPA Explorer. (2021). DOPA Explorer. https://dopa-explorer.jrc.ec.europa.eu/dopa_explorer
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rmarkdown_2.6 dplyr_1.0.6 knitr_1.30 wdpar_1.0.6 sf_0.9-8
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 pillar_1.6.0 compiler_3.6.3 later_1.2.0
[5] git2r_0.28.0 workflowr_1.6.2 class_7.3-19 tools_3.6.3
[9] digest_0.6.27 jsonlite_1.7.2 evaluate_0.14 lifecycle_1.0.0
[13] tibble_3.1.1 pkgconfig_2.0.3 rlang_0.4.11 DBI_1.1.1
[17] curl_4.3.1 yaml_2.2.1 xfun_0.20 e1071_1.7-7
[21] httr_1.4.2 stringr_1.4.0 rappdirs_0.3.3 generics_0.1.0
[25] fs_1.5.0 vctrs_0.3.8 tidyselect_1.1.1 classInt_0.4-3
[29] rprojroot_2.0.2 grid_3.6.3 glue_1.4.2 R6_2.5.0
[33] fansi_0.5.0 purrr_0.3.4 magrittr_2.0.1 whisker_0.4
[37] units_0.7-1 promises_1.2.0.1 ellipsis_0.3.2 htmltools_0.5.1.1
[41] assertthat_0.2.1 countrycode_1.2.0 httpuv_1.6.1 utf8_1.2.1
[45] KernSmooth_2.23-20 stringi_1.6.2 proxy_0.4-26 crayon_1.4.1