-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.Rmd
66 lines (48 loc) · 2.58 KB
/
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
---
title: 'Madison Area Bike Shops and Repair Stations'
output:
html_fragment
---
Madison and Dane County have a lot of bike shops (including mobile bike repair services), as well as a lot of repair stations in public places. Here is a map of all(?) of them. If you have new information or found an error, please email [harald@madisonbikes.org](mailto:harald@madisonbikes.org).
```{r echo=FALSE, results=FALSE, message=FALSE, warning=FALSE}
library(leaflet)
library(googlesheets4)
library(tidyverse)
library(sf)
gs4_deauth()
#read sheet with shop info
df <- read_sheet("https://docs.google.com/spreadsheets/d/1qkA4_rs_VMDfjsd42Da_JP_2pchGulRiq_yR2tgXJhM/",
col_types = "c-nncci__cccT_")#loading only relevant variables to improve performance
# read repair stations file from City of Madison Open Data portal; URL eventually expires and needs to be updated
# from https://data-cityofmadison.opendata.arcgis.com/datasets/bike-repair-station/
# URL can't be extracted directly anymore, and so you have to download the file and then "copy download link"
# in the Firefox download manager
download.file("https://opendata.arcgis.com/api/v3/datasets/76d43c3b570246bb98d6f44f0400c000_34/downloads/data?format=shp&spatialRefId=4326&where=1%3D1", "data/repair_stations.zip")
unzip("data/repair_stations.zip", exdir = "./data")
file.remove("data/repair_stations.zip")
repair_stations <- st_read("data/Bike_Repair_Station.shp")
repair_stations <- repair_stations %>%
mutate(pop = paste0("<b>Repair station</b><br>",Descriptio)) %>%
select(pop)
shops <- df %>%
rename(name = `Shop Name`) %>%
mutate(Status = replace_na(Status, "unknown")) %>%
mutate(pop = paste0("<b>",name, "</b><br>",
"Address: ", Address, ", ", City, "<br>",
"Phone: ", Phone, "<br>",
"Website: <a href=\"", Website, "\">", Website, "</a><br>"))
```
```{r echo=FALSE, warning=FALSE}
shop_icon <- makeAwesomeIcon(icon = "bicycle",
library = "fa")
repair_icon <- makeAwesomeIcon(icon = "wrench",
library = "fa",
markerColor = "lightgray")
shops %>%
leaflet(width = "90%") %>%
addProviderTiles(provider = "OpenStreetMap.Mapnik") %>%
addAwesomeMarkers(lng = ~Long, lat = ~Lat, popup = ~pop, icon = shop_icon) %>%
addAwesomeMarkers(data = repair_stations, popup = ~pop, icon = repair_icon, clusterOptions = TRUE)
```
Last update: `r Sys.time()`
Data: [City of Madison OpenData Portal (repair stations)](https://data-cityofmadison.opendata.arcgis.com/), Madison Bikes