Created
January 14, 2019 16:20
-
-
Save geofis/826b8c08cb462aa89cd6b0b9bec1ea52 to your computer and use it in GitHub Desktop.
gbif_protected_areas_DR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Packages | |
| library(wdpar) | |
| library(tidyverse) | |
| library(ggmap) | |
| library(rgbif) | |
| #Protected areas. Source: https://protectedplanet.net/ | |
| padr <- wdpa_fetch( | |
| 'Dominican Republic', | |
| wait = T, | |
| force_download = T) | |
| drbg <- get_stamenmap( | |
| unname(st_bbox(padr)), | |
| zoom = 8, | |
| maptype = "watercolor", | |
| force = TRUE) | |
| dev.new() | |
| ggmap(drbg) + | |
| geom_sf( | |
| data = padr, | |
| fill = "#31A35480", | |
| inherit.aes = FALSE | |
| ) + | |
| theme(axis.title = element_blank()) | |
| #Species occurrence records. Source: https://www.gbif.org/ | |
| drcode <- isocodes[grep("Dominican", isocodes$name), "code"] | |
| occ_count(country = drcode) | |
| occdr <- occ_search( | |
| return = 'data', | |
| hasCoordinate = T, | |
| country = drcode, | |
| kingdomKey = 6, | |
| limit = 300000) | |
| #sf object | |
| occdr.sf <- st_as_sf( | |
| occdr, | |
| coords = c("decimalLongitude", "decimalLatitude"), | |
| crs = 4326 | |
| ) | |
| #Intersection | |
| inter.pa.sp <- st_intersection( | |
| occdr.sf, | |
| padr | |
| ) | |
| #Plot | |
| ggmap(drbg) + | |
| geom_sf( | |
| data = padr, | |
| fill = "#31A35480", | |
| inherit.aes = FALSE | |
| ) + | |
| theme(axis.title = element_blank()) + | |
| geom_sf( | |
| data = inter.pa.sp, | |
| inherit.aes = FALSE | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment