library(patchwork)
library(sf)
library(tidyverse)
Species data visualisation
- R Libraries
- Basemaps
<- '+proj=laea +lon_0=-73.125 +lat_0=0 +datum=WGS84 +units=m +no_defs'
equalareaCRS
<- st_read('data/latam.gpkg', layer = 'latam', quiet = T)
latam <- st_read('data/latam.gpkg', layer = 'countries', quiet = T) countries
Data
Load the IUCN range, the PO grid-cells with counts and the PA blobs with presences and absences
<- st_read('big_data/hyagouaroundi_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
hyagouaroundi_IUCN <- readRDS('data/species_POPA_data/data_hyagouaroundi_PA.rds')
data_hyagouaroundi_PA <- readRDS('data/species_POPA_data/data_hyagouaroundi_PO.rds')
data_hyagouaroundi_PO
<- st_read('big_data/lpardalis_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
lpardalis_IUCN <- readRDS('data/species_POPA_data/data_lpardalis_PA.rds')
data_lpardalis_PA <- readRDS('data/species_POPA_data/data_lpardalis_PO.rds')
data_lpardalis_PO
<- st_read('big_data/lwiedii_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
lwiedii_IUCN <- readRDS('data/species_POPA_data/data_lwiedii_PA.rds')
data_lwiedii_PA <- readRDS('data/species_POPA_data/data_lwiedii_PO.rds')
data_lwiedii_PO
<- st_read('big_data/nnasua_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
nnasua_IUCN <- readRDS('data/species_POPA_data/data_nnasua_PA.rds')
data_nnasua_PA <- readRDS('data/species_POPA_data/data_nnasua_PO.rds')
data_nnasua_PO
<- st_read('big_data/cthous_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
cthous_IUCN <- readRDS('data/species_POPA_data/data_cthous_PA.rds')
data_cthous_PA <- readRDS('data/species_POPA_data/data_cthous_PO.rds')
data_cthous_PO
<- st_read('big_data/cbrachyurus_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
cbrachyurus_IUCN <- readRDS('data/species_POPA_data/data_cbrachyurus_PA.rds')
data_cbrachyurus_PA <- readRDS('data/species_POPA_data/data_cbrachyurus_PO.rds')
data_cbrachyurus_PO
<- st_read('big_data/ebarbara_IUCN.shp', quiet = T) %>% st_transform(crs=equalareaCRS)
ebarbara_IUCN <- readRDS('data/species_POPA_data/data_ebarbara_PA.rds')
data_ebarbara_PA <- readRDS('data/species_POPA_data/data_ebarbara_PO.rds')
data_ebarbara_PO
<- sf::st_read('big_data/pbrasiliensis_IUCN.shp', quiet = T) %>% sf::st_transform(crs=equalareaCRS)
pbrasiliensis_IUCN <- readRDS('data/species_POPA_data/data_pbrasiliensis_PA.rds')
data_pbrasiliensis_PA <- readRDS('data/species_POPA_data/data_pbrasiliensis_PO.rds') data_pbrasiliensis_PO
Plots per species
Herpailurus yagouaroundi (jaguarundi)
Code
<- ggplot() +
plot_hyagouaroundi_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=hyagouaroundi_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_hyagouaroundi_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Herpailurus yagouaroundi', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_hyagouaroundi_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=hyagouaroundi_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_hyagouaroundi_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Herpailurus yagouaroundi', subtitle='presence-only', col='') +
theme_bw()
| plot_hyagouaroundi_PA plot_hyagouaroundi_PO
Leopardus pardalis (ocelot)
Code
<- ggplot() +
plot_lpardalis_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=lpardalis_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_lpardalis_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Leopardus pardalis', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_lpardalis_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=lpardalis_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_lpardalis_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Leopardus pardalis', subtitle='presence-only', col='') +
theme_bw()
| plot_lpardalis_PA plot_lpardalis_PO
Leopardus wiedii (margay)
Code
<- ggplot() +
plot_lwiedii_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=lwiedii_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_lwiedii_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Leopardus wiedii', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_lwiedii_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=lwiedii_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_lwiedii_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Leopardus wiedii', subtitle='presence-only', col='') +
theme_bw()
| plot_lwiedii_PA plot_lwiedii_PO
Nasua nasua (coati)
Code
<- ggplot() +
plot_nnasua_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=nnasua_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_nnasua_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Nasua nasua', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_nnasua_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=nnasua_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_nnasua_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Nasua nasua', subtitle='presence-only', col='') +
theme_bw()
| plot_nnasua_PA plot_nnasua_PO
Cerdocyon thous (crab-eating fox)
Code
<- ggplot() +
plot_cthous_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=cthous_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_cthous_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) + # st_bbox(cthous_IUCN)
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Cerdocyon thous', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_cthous_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=cthous_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_cthous_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) + # st_bbox(cthous_IUCN)
labs(title='Cerdocyon thous', subtitle='presence-only', col='') +
theme_bw()
| plot_cthous_PA plot_cthous_PO
Chrysocyon brachyurus (maned wolf)
Code
<- ggplot() +
plot_cbrachyurus_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=cbrachyurus_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_cbrachyurus_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Chrysocyon brachyurus', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_cbrachyurus_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=cbrachyurus_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_cbrachyurus_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Chrysocyon brachyurus', subtitle='presence-only', col='') +
theme_bw()
| plot_cbrachyurus_PA plot_cbrachyurus_PO
Eira barbara (tayra)
Code
<- ggplot() +
plot_ebarbara_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=ebarbara_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_ebarbara_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Eira barbara', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_ebarbara_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=ebarbara_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_ebarbara_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Eira barbara', subtitle='presence-only', col='') +
theme_bw()
| plot_ebarbara_PA plot_ebarbara_PO
Pteronura brasiliensis (giant otter)
Code
<- ggplot() +
plot_pbrasiliensis_PA geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=pbrasiliensis_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_pbrasiliensis_PA %>% st_buffer(20000),
aes(fill=factor(presence)), col=NA, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
scale_fill_manual(values = c("#434445","#4dac26"))+
scale_color_manual(values = c("#434445","#4dac26")) +
labs(title='Pteronura brasiliensis', subtitle='presence-absence', col='') +
theme_bw()
<- ggplot() +
plot_pbrasiliensis_PO geom_sf(data=countries, fill='#fafaf8', col='#bfc5c7', size=0.2) +
geom_sf(data=pbrasiliensis_IUCN, fill='grey60', alpha=0.5, col='grey90', size=0.1) +
geom_sf(data=data_pbrasiliensis_PO, col="#d01c8b", size=0.5, show.legend = F) +
coord_sf(xlim = c(-3500000, 4100000), ylim = c(-4400000, 3000000)) +
labs(title='Pteronura brasiliensis', subtitle='presence-only', col='') +
theme_bw()
| plot_pbrasiliensis_PA plot_pbrasiliensis_PO
Save plots
Code
<- (plot_hyagouaroundi_PO | plot_lpardalis_PO | plot_lwiedii_PO | plot_nnasua_PO ) /
PO_plot | plot_cbrachyurus_PO | plot_ebarbara_PO | plot_pbrasiliensis_PO)
(plot_cthous_PO
ggsave(PO_plot, filename='docs/figs/PO_plot.svg', device = 'svg', width=18, height=10, dpi=300)
<- (plot_hyagouaroundi_PA | plot_lpardalis_PA | plot_lwiedii_PA | plot_nnasua_PA ) /
PA_plot | plot_cbrachyurus_PA | plot_ebarbara_PA | plot_pbrasiliensis_PA)
(plot_cthous_PA
ggsave(PA_plot, filename='docs/figs/PA_plot.svg', device = 'svg', width=18, height=10, dpi=300)