-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_Species_Richness_Maps.R
More file actions
222 lines (185 loc) · 8.97 KB
/
03_Species_Richness_Maps.R
File metadata and controls
222 lines (185 loc) · 8.97 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# The following script describe how to create the maps of the paper
###########################################
## LOAD LIBRARIES ##
###########################################
library(ggplot2) # version: 3.5.0
library(sf) # version: 1.0.16
library(viridis) # version: 0.6.5
library(patchwork) # version: 0.6.5
###########################################
## LOAD DATA ##
###########################################
grid <- st_read("Data/shp/Grid_Richness.shp")
#colnames(grid)
# ETRS89-LAEA coordinate system (EPSG:3035)
grid <- st_transform(grid, crs = 3035)
###################################################
## SPECIES RICHNESS MAP ##
###################################################
# Figure 2. Species richness map.
# Create a map for Odonata
map_od <- ggplot(data = grid) +
geom_sf(aes(fill = R_Odonata), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Odonata", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 30),
axis.title = element_text(size = 24),
axis.text = element_text(size = 18),
legend.title = element_text(size = 20),
legend.text = element_text(size = 18)
)
# Create a map for Lentic
map_lentic <- ggplot(data = grid) +
geom_sf(aes(fill = R_Lentic), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Lentic", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 30),
axis.title = element_text(size = 24),
axis.text = element_text(size = 18),
legend.title = element_text(size = 20),
legend.text = element_text(size = 18)
)
# Create a map for Lotic
map_lotic <- ggplot(data = grid) +
geom_sf(aes(fill = R_Lotic), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Lotic", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 30),
axis.title = element_text(size = 24),
axis.text = element_text(size = 18),
legend.title = element_text(size = 20),
legend.text = element_text(size = 18)
)
# Combine the three maps into a single figure
combined_map <- (map_od | map_lentic | map_lotic)
# Show the combined figure
print(combined_map)
# Save the figure as a PNG file with a resolution of 600 ppi.
ggsave("Figure_2_600ppi.png", plot = combined_map, width = 20, height = 25, units = "in", dpi = 600)
###################################################
## MAP OF THE STUDY AREA ##
###################################################
# Figure 1. Map of the study area.
labels <- c("Southern ", "Northern ")
grid$Zone = as.factor(grid$Zone)
map_zone <- ggplot(data = grid) +
geom_sf(aes(fill = Zone)) +
scale_fill_manual(values = c("#E0EEEE", "#49A4B9"), labels = labels) +
labs(title = "Study area", x = "Longitud", y = "Latitud") +
theme_bw() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"),
axis.title = element_text(size = 18),
axis.text = element_text(size = 16),
legend.title = element_text(size = 14),
legend.text = element_text(size = 12)
)
# Show
map_zone
# Save the figure as a PNG file with a resolution of 600 ppi.
ggsave("Figure_1.png", plot = map_zone, width = 10, height = 15, units = "in", dpi = 600)
###################################################
## SUPPLEMENTARY FIGURE S2.2 ##
###################################################
# Create a map for Anisoptera
map_ani <- ggplot(data = grid) +
geom_sf(aes(fill = R_Ani), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Anisoptera", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"), # Tamaño del título del mapa
axis.title = element_text(size = 18), # Tamaño de los nombres de los ejes
axis.text = element_text(size = 16), # Tamaño de las etiquetas de los ejes
legend.title = element_text(size = 14), # Tamaño del título de la leyenda
legend.text = element_text(size = 12) # Tamaño del texto de la leyenda
)
# Create a map for Zygoptera
map_zyg <- ggplot(data = grid) +
geom_sf(aes(fill = R_Zyg), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Zygoptera", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"), # Tamaño del título del mapa
axis.title = element_text(size = 18), # Tamaño de los nombres de los ejes
axis.text = element_text(size = 16), # Tamaño de las etiquetas de los ejes
legend.title = element_text(size = 14), # Tamaño del título de la leyenda
legend.text = element_text(size = 12) # Tamaño del texto de la leyenda
)
# Create a map for Anisoptera - Lentic
map_ani_len <- ggplot(data = grid) +
geom_sf(aes(fill = R_Ani_Len), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Anisoptera Lentic", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"), # Tamaño del título del mapa
axis.title = element_text(size = 18), # Tamaño de los nombres de los ejes
axis.text = element_text(size = 16), # Tamaño de las etiquetas de los ejes
legend.title = element_text(size = 14), # Tamaño del título de la leyenda
legend.text = element_text(size = 12) # Tamaño del texto de la leyenda
)
# Create a map for Anisoptera - Lotic
map_ani_lot <- ggplot(data = grid) +
geom_sf(aes(fill = R_Ani_Lot), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Anisoptera Lotic", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"), # Tamaño del título del mapa
axis.title = element_text(size = 18), # Tamaño de los nombres de los ejes
axis.text = element_text(size = 16), # Tamaño de las etiquetas de los ejes
legend.title = element_text(size = 14), # Tamaño del título de la leyenda
legend.text = element_text(size = 12) # Tamaño del texto de la leyenda
)
# Create a map for Zygoptera - Lentic
map_zyg_len <- ggplot(data = grid) +
geom_sf(aes(fill = R_Zyg_Len), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Zygoptera Lentic", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"), # Tamaño del título del mapa
axis.title = element_text(size = 18), # Tamaño de los nombres de los ejes
axis.text = element_text(size = 16), # Tamaño de las etiquetas de los ejes
legend.title = element_text(size = 14), # Tamaño del título de la leyenda
legend.text = element_text(size = 12) # Tamaño del texto de la leyenda
)
# Create a map for Zygoptera - Lotic
map_zyg_lot <- ggplot(data = grid) +
geom_sf(aes(fill = R_Zyg_Lot), color = NA) +
scale_fill_viridis(name = "Richness", option = "viridis") +
labs(title = "Zygoptera Lotic", x = "Longitud", y = "Latitud") +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 20, face = "bold"), # Tamaño del título del mapa
axis.title = element_text(size = 18), # Tamaño de los nombres de los ejes
axis.text = element_text(size = 16), # Tamaño de las etiquetas de los ejes
legend.title = element_text(size = 14), # Tamaño del título de la leyenda
legend.text = element_text(size = 12) # Tamaño del texto de la leyenda
)
# Combine the three maps into a single figure
combined_map <- (map_ani | map_zyg) /
(map_ani_len | map_ani_lot) /
(map_zyg_len | map_zyg_lot)
# Show the combined figure
print(combined_map)
# Save the figure as a PNG file with a resolution of 600 ppi.
ggsave("Figure_S2_2.png", plot = combined_map, width = 10, height = 15, units = "in", dpi = 600)