forked from libjohn/mapping-with-R
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path033_thematic_leaflet_example.Rmd
41 lines (30 loc) · 1.07 KB
/
033_thematic_leaflet_example.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
---
title: "Interactive Thematic Mapping"
output:
html_document:
toc: FALSE
---
> This page is **deprecated**. The `mapview` packages deliveres much of the same functionality, and with less effort. Please explore the introduction to the [plotting coordinates with mapview](01_georeference.html).
```{r}
library(leaflet)
```
## Leaflet View of Same Map
```{r greenpalette_leaflet_choropleth}
GreenPalette <- colorNumeric(palette = "Greens",
domain = contiguous_states$wages)
contiguous_states %>%
st_transform(crs = "+init=epsg:4326") %>%
leaflet(width = "100%") %>%
addProviderTiles(provider = "CartoDB.Positron") %>%
addPolygons(fillOpacity = 0.7,
smoothFactor = 0,
stroke = FALSE,
color = ~GreenPalette(wages)) %>%
addLegend("bottomleft",
pal = GreenPalette,
values = ~ wages,
bins = 5,
title = "Median Salary - Substance Abuse Social Workers",
labFormat = labelFormat(prefix = "$"),
opacity = 1)
```