Download data from the World Database on Protected Areas (WDPA) (available at https://www.protectedplanet.net/en) and import it. Note that data are downloaded assuming non-commercial use.

wdpa_fetch(
  x,
  wait = FALSE,
  download_dir = rappdirs::user_data_dir("wdpar"),
  force_download = FALSE,
  verbose = interactive()
)

Arguments

x

character country for which to download data. This argument can be the name of the country (e.g. "Liechtenstein") or the ISO-3 code for the country (e.g. "LIE"). This argument can also be set to "global" to download all of the protected areas available in the database (approximately 1.1 GB).

wait

logical if data is not immediately available for download should the session be paused until it is ready for download? If argument to wait is FALSE and the data is not ready then NA will be returned. Defaults to FALSE.

download_dir

character folder path to download the data. Defaults to a persistent data directory (rappdirs::user_data_dir("wdpar")).

force_download

logical if the data has previously been downloaded and is available at argument to download_dir, should a fresh copy be downloaded? Defaults to FALSE.

verbose

logical should a progress on downloading data be reported? Defaults to TRUE in an interactive session, otherwise FALSE.

Value

sf::sf() object.

Details

This function will download the specified protected area data and return it. It is strongly recommended that the data be cleaned prior to analysis. Check out the wdpa_clean() function to clean the data according to standard practices. For information on this database, prefer refer to the official manual (https://www.protectedplanet.net/en/resources/wdpa-manual).

Please note that this function will sometimes return the error PhantomJS signals port = 4567 is already in use. This can occur when you have previously run the function and terminated it early. To address this issue, you will need to restart your computer.

See also

Examples

# \dontrun{ # fetch data for Liechtenstein lie_raw_data <- wdpa_fetch("Liechtenstein", wait = TRUE) # fetch data for Liechtenstein using the ISO3 code lie_raw_data <- wdpa_fetch("LIE") # print data print(lie_raw_data)
#> Simple feature collection with 45 features and 30 fields #> geometry type: MULTIPOLYGON #> dimension: XY #> bbox: xmin: 9.475186 ymin: 47.04974 xmax: 9.636976 ymax: 47.26538 #> CRS: 4326 #> # A tibble: 45 x 31 #> WDPAID WDPA_PID PA_DEF NAME ORIG_NAME DESIG DESIG_ENG DESIG_TYPE IUCN_CAT #> * <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 18107 18107 1 Rugg… Ruggelle… Natu… Nature R… National Ia #> 2 18109 18109 1 Schw… Schwabbr… Natu… Nature R… National Ia #> 3 30747 30747 1 Gamp… Gamprine… Natu… Nature R… National Ia #> 4 30750 30750 1 Äule… Äulehäg Natu… Nature R… National Ia #> 5 30752 30752 1 Trie… Triesner… Natu… Nature R… National Ia #> 6 30753 30753 1 Wisa… Wisanels Natu… Nature R… National Ia #> 7 30754 30754 1 Birka Birka Natu… Nature R… National Ia #> 8 30755 30755 1 Schn… Schnecke… Natu… Nature R… National Ia #> 9 30756 30756 1 Au Au Natu… Nature R… National Ia #> 10 30757 30757 1 Pfla… Pflanzen… Gesc… Protecte… National V #> # … with 35 more rows, and 22 more variables: INT_CRIT <chr>, MARINE <chr>, #> # REP_M_AREA <dbl>, GIS_M_AREA <dbl>, REP_AREA <dbl>, GIS_AREA <dbl>, #> # NO_TAKE <chr>, NO_TK_AREA <dbl>, STATUS <chr>, STATUS_YR <int>, #> # GOV_TYPE <chr>, 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 [°]>
# plot data plot(lie_raw_data)
#> Warning: plotting the first 10 out of 30 attributes; use max.plot = 30 to plot all
# 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)
#> #> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
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)
#> Simple feature collection with 61 features and 30 fields #> geometry type: GEOMETRY #> dimension: XY #> bbox: xmin: 9.475186 ymin: 5.586051 xmax: 171.9985 ymax: 47.26538 #> CRS: 4326 #> # A tibble: 61 x 31 #> WDPAID WDPA_PID PA_DEF NAME ORIG_NAME DESIG DESIG_ENG DESIG_TYPE IUCN_CAT #> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 18107 18107 1 Rugg… Ruggelle… Natu… Nature R… National Ia #> 2 18109 18109 1 Schw… Schwabbr… Natu… Nature R… National Ia #> 3 30747 30747 1 Gamp… Gamprine… Natu… Nature R… National Ia #> 4 30750 30750 1 Äule… Äulehäg Natu… Nature R… National Ia #> 5 30752 30752 1 Trie… Triesner… Natu… Nature R… National Ia #> 6 30753 30753 1 Wisa… Wisanels Natu… Nature R… National Ia #> 7 30754 30754 1 Birka Birka Natu… Nature R… National Ia #> 8 30755 30755 1 Schn… Schnecke… Natu… Nature R… National Ia #> 9 30756 30756 1 Au Au Natu… Nature R… National Ia #> 10 30757 30757 1 Pfla… Pflanzen… Gesc… Protecte… National V #> # … with 51 more rows, and 22 more variables: INT_CRIT <chr>, MARINE <chr>, #> # REP_M_AREA <dbl>, GIS_M_AREA <dbl>, REP_AREA <dbl>, GIS_AREA <dbl>, #> # NO_TAKE <chr>, NO_TK_AREA <dbl>, STATUS <chr>, STATUS_YR <int>, #> # GOV_TYPE <chr>, 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 [°]>
# }