-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSD1-Interactive Map.Rmd
175 lines (141 loc) · 6.27 KB
/
SD1-Interactive Map.Rmd
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
---
title: "Supplementary Data SD1"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = FALSE,
message = FALSE,
warning = FALSE
)
library(leaflet)
library(sf)
library(tidyverse)
```
```{r loading data , message=FALSE, warning=FALSE, include=FALSE, echo=FALSE}
all_layers <- sf::st_read("data/all_layers_simplified_interactive_map.shp")
# simplified in mapshaper (https://mapshaper.org) at 10%
# Fixing Iberá
all_layers[68,1] <- 'Iberá'
```
```{r}
title_var <- "Supplementary Data SD1"
# https://stackoverflow.com/questions/58188845/rmarkdown-tab-name-in-browser
```
---
title: `r title_var`
---
<style>
.title{
display: none;
}
</style>
```{r inicializo_mapa, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
interactive_map <- leaflet() %>%
# addControl(title, position = "topleft", className="map-title") %>%
addProviderTiles("Esri.WorldGrayCanvas", options = tileOptions(minZoom=3, maxZoom=7)) %>%
addMapPane("int", zIndex = 450) %>%
addMapPane("ar", zIndex = 410) %>%
addMapPane("ctenomys", zIndex = 400) %>%
addMapPane("ctenomys_lista", zIndex = 420)
```
```{r ctenomys, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
ctenomys <- all_layers %>%
filter(capa == 'DA') %>%
mutate(BINOMIA = paste0('<i>',BINOMIA,'</i>'))
ctenomys[68,1] <- 'Iberá'
ctenomys.lista <- split(ctenomys, ctenomys$BINOMIA)
names(ctenomys.lista) %>%
purrr::walk( function(df) {
interactive_map <<- interactive_map %>%
addPolygons(color = '#1034A6',
data = ctenomys.lista[[df]],
options = pathOptions(pane = "ctenomys_lista"),
weight = 1,
smoothFactor = 0.5,
opacity = 0.8,
fillOpacity = 0.2,
fillColor = '#1034A6',
group = ctenomys.lista[[df]]$BINOMIA,
popup = paste0(ctenomys.lista[[df]]$BINOMIA,' - DA: ', ctenomys.lista[[df]]$ar_sn_g," km<sup>2</sup>"),
highlightOptions = highlightOptions(color = '#1034A6',
weight = 2,
bringToFront = TRUE))})
```
```{r ctenomys_todos, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
interactive_map <- interactive_map %>%
addPolygons(color = '#1034A6',
data = ctenomys,
options = pathOptions(pane = "ctenomys"),
weight = 1,
smoothFactor = 0.5,
opacity = 0.8,
fillOpacity = 0.1,
fillColor = '#1034A6',
popup = paste0(ctenomys$BINOMIA),
group = paste0('<i> Ctenomys</i> Distribution areas'),
highlightOptions = highlightOptions(color = '#1034A6',
weight = 2,
bringToFront = TRUE))
```
```{r PAs, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
areas <- all_layers %>%
filter(capa == 'PA')
interactive_map <- interactive_map %>%
addPolygons(color = '#eec900', #gold2
data = areas,
options = pathOptions(pane = "ar"),
weight = 1,
smoothFactor = 0.5,
opacity = 0.8,
fillOpacity = 0.1,
fillColor = '#eec900',
popup = areas$orig_name,
group = 'Protected areas',
highlightOptions = highlightOptions(color = '#eec900',
weight = 2,
bringToFront = TRUE))
```
```{r Intersections, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
intersections <- all_layers %>%
filter(capa == 'I') %>%
mutate(BINOMIA = paste0('<i>',BINOMIA,'</i>'))
intersections[42,1] <- 'Iberá'
interactive_map <- interactive_map %>%
addPolygons(color = '#d26da3', #purple#551a8b
data = intersections,
options = pathOptions(pane = "int"),
weight = 1,
smoothFactor = 0.5,
opacity = 0.8,
fillOpacity = 0.5,
fillColor = '#d26da3',
popup = paste0(intersections$BINOMIA," - PA"),
group = 'Intersections',
highlightOptions = highlightOptions(color = '#d26da3',
weight = 2,
bringToFront = TRUE))
```
```{r legend, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
interactive_map <- interactive_map %>%
addLegend("bottomleft",
colors=c('#1034A6', '#eec900','#d26da3'),
values = c('Distribution areas', 'Protected areas', 'Intersections'),
labels= c('Distribution areas', 'Protected areas', 'Intersections'),
# title = "Polygons",
opacity = 1)
```
```{r Selector, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
interactive_map <- interactive_map %>%
addLayersControl(overlayGroups = c('Protected areas', 'Intersections',paste0('<i> Ctenomys</i> Distribution areas'),names(ctenomys.lista)),
options = layersControlOptions(collapsed = T)
) %>%
hideGroup(c('Protected areas','Intersections',paste0('<i> Ctenomys</i> Distribution areas'),names(ctenomys.lista)))
```
## "Filling the gap in distribution ranges and conservation status in *Ctenomys* (Rodentia: Ctenomyidae)."
### *Caraballo, D. A., López, S. L., Botero-Cañola, S., and Gardner S. L.*
#### **Supplementary Data SD1**. Interactive map showing _Ctenomys_ geographic distribution areas (DAs), protected areas (PAs), and their intersection.
The icon located at the upper right corner is an dropdown menu that allows to select/deselect layers of interest. By selecting a species layer, the name of the species and its total area of distribution are displayed after clicking. By clicking on a PA, the name is shown, according to the World Database of Protected Areas. By clicking on an intersection shape, the name of the species is shown.
```{r}
interactive_map
```