-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslides-making-interactive-maps-with-mapgl.qmd
174 lines (137 loc) · 2.76 KB
/
slides-making-interactive-maps-with-mapgl.qmd
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
---
title: Making Interactive Maps with {mapgl}
---
```{r}
library(leaflet)
library(tidyverse)
library(tidycensus)
library(janitor)
library(tigris)
library(scales)
library(sf)
library(mapgl)
```
### {mapgl} {.inverse}
::: {.notes}
Show mapbox website
:::
### Get Mapbox Access Token
::: {.notes}
Show creating account and access token
Add access token to Renviron
:::
### Basic Map {.inverse}
#### Styles {.inverse}
::: {.notes}
Mention how can't render Mapbox maps in Quarto at the moment (https://github.com/walkerke/mapgl/issues/3) but cant use maplibre
:::
---
```{r}
mapboxgl(style = mapbox_style("light"))
```
---
```{r}
mapboxgl(style = mapbox_style("dark"))
```
---
```{r}
mapboxgl(style = mapbox_style("outdoors"))
```
---
```{r}
maplibre()
```
---
```{r}
maplibre(style = carto_style("positron"))
```
---
```{r}
maplibre(style = carto_style("dark-matter"))
```
#### Adjust Center and Zoom
```{r}
mapboxgl(
mapbox_style("light"),
center = c(-43.23412, -22.91370)
)
```
---
```{r}
mapboxgl(
mapbox_style("light"),
center = c(-43.23412, -22.91370),
zoom = 5
)
```
#### Add Layers
```{r}
speak_language_other_than_english_wgs84_with_labels <-
read_sf("data/speak_language_other_than_english_wgs84_with_labels.geojson")
```
---
```{r}
mapboxgl(
mapbox_style("light"),
center = c(-100.29957845401096, 38.93484429077689),
zoom = 2
) |>
add_fill_layer(
id = "speak_language_other_than_english_wgs84_with_labels",
source = speak_language_other_than_english_wgs84_with_labels
)
```
---
```{r}
mapboxgl(
mapbox_style("light"),
center = c(-100.29957845401096, 38.93484429077689),
zoom = 2
) |>
add_fill_layer(
id = "speak_language_other_than_english_wgs84_with_labels",
source = speak_language_other_than_english_wgs84_with_labels,
fill_color = interpolate(
column = "pct",
values = c(0, 1),
stops = c("lightblue", "darkblue"),
na_color = "lightgrey"
),
fill_opacity = 1
)
```
```{r}
mapboxgl(
mapbox_style("light"),
center = c(-100.29957845401096, 38.93484429077689),
zoom = 2
) |>
add_fill_layer(
id = "speak_language_other_than_english_wgs84_with_labels",
source = speak_language_other_than_english_wgs84_with_labels,
fill_color = interpolate(
column = "pct",
values = c(0, 1),
stops = c("lightblue", "darkblue"),
na_color = "lightgrey"
),
popup = "text_label",
fill_opacity = 1
)
```
### Other Layers {.inverse}
::: {.notes}
Show layers on https://walker-data.com/mapgl/articles/layers-overview.html
:::
### Other Things You Can Do with {mapgl}
```{r}
mapboxgl() |>
fly_to(
center = c(2.1228412549747344, 41.3812461533571),
zoom = 16,
pitch = 25
)
```
### Your Turn {.your-turn}
### Learn More
- https://qfes.github.io/rdeck/