diff --git a/DESCRIPTION b/DESCRIPTION
index 1ba6f1f..8e75cb1 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,14 +1,14 @@
Package: wdpar
Type: Package
-Version: 1.3.7.2
+Version: 1.3.7.3
Title: Interface to the World Database on Protected Areas
Description: Fetch and clean data from the World Database on Protected
Areas (WDPA) and the World Database on Other Effective Area-Based
Conservation Measures (WDOECM). Data is obtained from Protected Planet
wdpar: Interface to the World Database on Protected Areas
Jeffrey O. Hanson
- 2024-04-25
+ 2024-05-11
Source: vignettes/wdpar.Rmd
wdpar.Rmd
TutorialAfter cleaning the data set, we will perform an additional step that involves clipping the terrestrial protected areas to Malta’s coastline. Ideally, we would also clip the marine protected areas to Malta’s Exclusive Economic Zone (EEZ) but such data are not as easy to obtain on a per country basis (but see https://www.marineregions.org/eez.php)).
# download Malta boundary from Global Administrative Areas dataset
-file_path <- tempfile(fileext = "rds")
+file_path <- tempfile(fileext = ".gpkg")
download.file(
- "https://biogeo.ucdavis.edu/data/gadm3.6/Rsf/gadm36_MLT_0_sf.rds",
+ "https://geodata.ucdavis.edu/gadm/gadm4.1/gpkg/gadm41_MLT.gpkg",
file_path
)
# import Malta's boundary
-mlt_boundary_data <- readRDS(file_path)
+mlt_boundary_data <- sf::read_sf(file_path, "ADM_ADM_0")
# repair any geometry issues, dissolve the border, reproject to same
# coordinate system as the protected area data, and repair the geometry again
@@ -131,12 +131,9 @@ Tutorial st_set_precision(1000) %>%
sf::st_make_valid() %>%
st_transform(st_crs(mlt_pa_data)) %>%
- sf::st_make_valid()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
-## old-style crs object detected; please recreate object with a recent sf::st_crs()
-## old-style crs object detected; please recreate object with a recent sf::st_crs()
-
-# clip Malta's protected areas to the coastline
+ sf::st_make_valid()
+
+# clip Malta's protected areas to the coastline
mlt_pa_data <-
mlt_pa_data %>%
filter(MARINE == "terrestrial") %>%
@@ -150,13 +147,13 @@ Tutorial
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
-+# recalculate the area of each protected area mlt_pa_data <- mlt_pa_data %>% mutate(AREA_KM2 = as.numeric(st_area(.)) * 1e-6)
Now that we have finished cleaning the data, let’s preview the data. For more information on what these columns mean, please refer to the official manual (available in English, French, Spanish, and Russian).
-+# print first six rows of the data head(mlt_pa_data)
## Simple feature collection with 6 features and 32 fields @@ -181,11 +178,11 @@
Tutorial## # SUPP_INFO <chr>, CONS_OBJ <chr>, GEOMETRY_TYPE <chr>, AREA_KM2 <dbl>, ## # geometry <GEOMETRY [m]>
We will now reproject the data to longitude/latitude coordinates (EPSG:4326) for visualization purposes.
-+# reproject data mlt_pa_data <- st_transform(mlt_pa_data, 4326)
Next, we can plot a map showing the boundaries of Malta’s protected area system.
-+# download basemap for making the map bg <- get_stadiamap( unname(st_bbox(mlt_pa_data)), zoom = 8, @@ -198,7 +195,7 @@
Tutorialtheme(axis.title = element_blank())
We can also create a histogram showing the year when each protected area was established.
-+Now let’s calculate some statistics. We can calculate the total amount of land and ocean inside Malta’s protected area system (km2).
-+# calculate total amount of area inside protected areas (km^2) statistic <- mlt_pa_data %>% @@ -226,7 +223,7 @@
Tutorial## 2 terrestrial 84.9 ## 3 partial 13.1
We can also calculate the percentage of land inside its protected area system that are managed under different categories (i.e. using the protected area management categories defined by The International Union for Conservation of Nature).
-+# calculate percentage of land inside protected areas (km^2) statistic <- mlt_pa_data %>% @@ -250,7 +247,7 @@
Tutorial## 5 III 0.191 0.00451 ## 6 Ia 0.145 0.00343
We can also plot a map showing Malta’s protected areas and color each area according to it’s management category.
-+@@ -260,7 +257,7 @@ggmap(bg) + geom_sf(aes(fill = IUCN_CAT), data = mlt_pa_data, inherit.aes = FALSE) + theme(axis.title = element_blank(), legend.position = "bottom")
TutorialRecommended practices for large datasets
The wdpar R package can be used to clean large datasets assuming that sufficient computational resources and time are available. Indeed, it can clean data spanning large countries, multiple countries, and even the full global dataset. When processing the full global dataset, it is recommended to use a computer system with at least 32 GB RAM available and to allow for at least one full day for the data cleaning procedures to complete. It is also recommended to avoid using the computer system for any other tasks while the data cleaning procedures are being completed, because they are very computationally intensive. Additionally, when processing large datasets – and especially for the global dataset – it is strongly recommended to disable the procedure for erasing overlapping areas. This is because the built-in procedure for erasing overlaps is very time consuming when processing many protected areas, so that information on each protected area can be output (e.g. IUCN category, year established). Instead, when cleaning large datasets, it is recommended to run the data cleaning procedures with the procedure for erasing overlapping areas disabled (i.e. with
-erase_overlaps = FALSE
). After the data cleaning procedures have completed, the protected area data can be manually dissolved to remove overlapping areas (e.g. usingwdpa_dissolve()
). For an example of these procedures, please see below.+-# download protected area data for multiple of countries ## (i.e. Portugal, Spain, France) raw_pa_data <- @@ -268,7 +265,7 @@
Recommended practices for larg lapply(wdpa_fetch, wait = TRUE, download_dir = rappdirs::user_data_dir("wdpar")) %>% bind_rows()
+-# clean protected area data (with procedure for erasing overlaps disabled) full_pa_data <- wdpa_clean(raw_pa_data, erase_overlaps = FALSE) @@ -292,7 +289,7 @@
Recommended practices for larg ## Precision: 1500 ## id geometry ## 1 1 MULTIPOLYGON (((-1747945 34...
+@@ -302,7 +299,7 @@## 8040807030 [m^2]
Recommended practices fo
The default parameters for the data cleaning procedures are well suited for national-scale analyses. Although these parameters reduce memory requirements and the time needed to complete the data cleaning procedures, they can produce protected area boundaries that appear overly “blocky” – lacking smooth edges – when viewed at finer scales. As such, it is strongly recommended to increase the level of spatial precision when cleaning data for local scale analyses (via the
geometry_precision
parameter of thewdpa_clean()
function).Here we will explore the consequences of using the default parameters for the data cleaning procedures when working at a local scale. This will help illustrate why it can be important to adjust the spatial precision of the data cleaning procedures. To begin with, we will obtain data for a small protected area. Specifically, we will extract a protected area from the Malta dataset we downloaded earlier.
-+-# find id for smallest reserve in cleaned dataset mlt_reserve_id <- mlt_pa_data$WDPAID[which.min(mlt_pa_data$AREA_KM2)] @@ -328,12 +325,12 @@
Recommended practices fo ## # OWN_TYPE <chr>, MANG_AUTH <chr>, MANG_PLAN <chr>, VERIF <chr>, ## # METADATAID <int>, SUB_LOC <chr>, PARENT_ISO <chr>, ISO3 <chr>, ## # SUPP_INFO <chr>, CONS_OBJ <chr>, geometry <MULTIPOLYGON [°]>
+# visualize data plot(mlt_raw_reserve_data[, 1])
We can see that the boundary for this protected area has a high level of detail. This suggests that the protected area data is available at a resolution that is sufficient to permit local scale analyses. To help understand the consequences of cleaning data with the default parameters, we will clean this dataset using the default parameters.
-+-# clean the data with default parameters mlt_default_cleaned_reserve_data <- wdpa_clean(mlt_raw_reserve_data) @@ -355,12 +352,12 @@
Recommended practices fo ## # METADATAID <int>, SUB_LOC <chr>, PARENT_ISO <chr>, ISO3 <chr>, ## # SUPP_INFO <chr>, CONS_OBJ <chr>, GEOMETRY_TYPE <chr>, AREA_KM2 <dbl>, ## # geometry <POLYGON [m]>
+# visualize data plot(mlt_default_cleaned_reserve_data[, 1])
After cleaning the data with the default parameters, we can see that the boundary of the protected area is no longer highly detailed. For example, the smooth edges of the raw protected area data have been replaced with sharp, blocky edges. As such, subsequent analysis performed at the local scale – such as calculating the spatial extent of land cover types within this single protected area – might not be sufficiently precise. Now, let’s clean the data using parameters that are well suited for local scale analysis.
-+diff --git a/docs/index.html b/docs/index.html index 2ec029e..cbd355e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -17,8 +17,8 @@ Conservation Measures (WDOECM). Data is obtained from Protected Planet <https://www.protectedplanet.net/en>. To augment data cleaning procedures, users can install the prepr R package (available at - <https://github.com/dickoa/prepr>). For more information on this package, - see Hanson (2022) <doi:10.21105/joss.04594>."> + <https://github.com/prioritizr/prepr>). For more information on this + package, see Hanson (2022) <doi:10.21105/joss.04594>.">- diff --git a/docs/authors.html b/docs/authors.html index efbb56b..680faaf 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@# clean the data with default parameters mlt_fixed_cleaned_reserve_data <- wdpa_clean( mlt_raw_reserve_data, geometry_precision = 10000 @@ -384,7 +381,7 @@
Recommended practices fo ## # METADATAID <int>, SUB_LOC <chr>, PARENT_ISO <chr>, ISO3 <chr>, ## # SUPP_INFO <chr>, CONS_OBJ <chr>, GEOMETRY_TYPE <chr>, AREA_KM2 <dbl>, ## # geometry <POLYGON [m]>