-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path06_congruence_with_protected_areas.R
121 lines (86 loc) · 4.08 KB
/
06_congruence_with_protected_areas.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# -----------------------------------
# Author: Florencia Grattarola
# Date: 7 December 2020
# Contact: flograttarola@gmail.com
# -----------------------------------
# Congruence with protected areas
### Description
# This is a script that calculates the congruence of 2.5 and 5% of the biodiverstiy hotspots richest grid-cells with the current areas under protection in Uruguay.
# ------------------------------------------------------------------------------
#############
# LIBRARIES #
#############
library(sf)
library(tidyverse)
# ------------------------------------------------------------------------------
########
# DATA #
########
AP_UTM <- st_read('data/areas_snap_ingresadas_29042020_utm.shp')
AP_Grid_UY25 <- st_read('data/AP_Grid_UY25.shp')
AP_Grid_UY125 <- st_read('data/AP_Grid_UY125.shp')
Grid_UY25_Amphibia
# ------------------------------------------------------------------------------
#############
# FUNCTIONS #
#############
get_overlappingArea <- function(dataset, protectedArea, percentage){
dataset <- dataset %>% filter(N!=0)
overlapAreaDefinition <- nrow(dataset)*percentage/100
GridID_PA <- protectedArea %>%
filter(N==1) %>%
select(GridId)
GridID_SR <- dataset %>%
arrange(desc(SR)) %>%
head(overlapAreaDefinition) %>%
select(Id)
GridID_E <- dataset %>%
arrange(desc(rswSR)) %>%
head(overlapAreaDefinition) %>%
select(Id)
GridID_TSN <- dataset %>%
arrange(desc(threatenedNumber)) %>%
head(overlapAreaDefinition) %>%
select(Id)
GridID_TSP <- dataset %>%
arrange(desc(threatenedProportion)) %>%
head(overlapAreaDefinition) %>%
select(Id)
overlappingArea <- data.frame(overlap_SR=nrow(intersect(GridID_SR,
GridID_PA %>%
rename(Id=GridId)))*100/nrow(GridID_SR),
overlap_E=nrow(intersect(GridID_E,
GridID_PA %>%
rename(Id=GridId)))*100/nrow(GridID_E),
overlap_TSN=nrow(intersect(GridID_TSN,
GridID_PA %>%
rename(Id=GridId)))*100/nrow(GridID_TSN),
overlap_TSP =nrow(intersect(GridID_TSP,
GridID_PA %>%
rename(Id=GridId)))*100/nrow(GridID_TSP),
stringsAsFactors=FALSE)
return(overlappingArea)
}
# ------------------------------------------------------------------------------
#######
# RUN #
#######
# 1) Amphibia (Tetrapods)
Amphibia_overlapping_PA_UY25_2.5 <- cbind(data.frame(group='Amphibia UY25 2.5%'), get_overlappingArea(Grid_UY25_Amphibia, AP_Grid_UY25, 2.5))
Amphibia_overlapping_PA_UY25_5 <- cbind(data.frame(group='Amphibia UY25 5%'), get_overlappingArea(Grid_UY25_Amphibia, AP_Grid_UY25, 5))
Amphibia_overlapping_PA_UY125_2.5 <- cbind(data.frame(group='Amphibia UY125 2.5%'), get_overlappingArea(Grid_UY125_Amphibia, AP_Grid_UY125, 2.5))
Amphibia_overlapping_PA_UY125_5 <- cbind(data.frame(group='Amphibia UY125 5%'), get_overlappingArea(Grid_UY125_Amphibia, AP_Grid_UY125, 5))
bind_rows(Amphibia_overlapping_PA_UY25_2.5, Amphibia_overlapping_PA_UY25_5,
Amphibia_overlapping_PA_UY125_2.5, Amphibia_overlapping_PA_UY125_5)
# ------------------------------------------------------------------------------
#########
# PLOTS #
#########
plot_congruence_Amphibia_SR_and_PA <- ggplot() +
geom_sf(data = Grid_UY25_Amphibia, aes(fill=SR)) +
scale_fill_distiller(palette = "Spectral")+
geom_sf(data = Uruguay, color='black', fill=NA) +
geom_sf(data = AP_UTM, fill='green', alpha=0.5) +
theme_bw() +
labs(fill='Amphibia\nSpecies Richness')
ggsave('figures/plot_congruence_Amphibia_SR_and_PA.png', plot_congruence_Amphibia_SR_and_PA, width = 6, height = 6, units = "in", dpi = 150)