Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save geofis/826b8c08cb462aa89cd6b0b9bec1ea52 to your computer and use it in GitHub Desktop.

Select an option

Save geofis/826b8c08cb462aa89cd6b0b9bec1ea52 to your computer and use it in GitHub Desktop.
gbif_protected_areas_DR
#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