-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeocodingMPI.R
More file actions
39 lines (29 loc) · 930 Bytes
/
geocodingMPI.R
File metadata and controls
39 lines (29 loc) · 930 Bytes
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
library(leaflet)
locations <- unique(short$municipality)%>%
word(1, sep=",")%>%
word(1, sep="/")%>%
word(1, sep="-")%>%
word(1, sep="And")%>%
word(1, sep="To")%>%
word(1, sep="Area")%>%
word(1, sep="area")%>%
word(1, sep= "region")%>%
word(1, sep= "south of")%>%
trimws()%>%
unique()%>%
na.omit()%>%
stringi::stri_remove_empty()%>%
str_replace_all("Tri","Coquitlam")%>%
paste0(", British Columbia, Canada")
locations <- data.frame(place= locations)
locations_df <- mutate_geocode(locations, place)
write_csv(locations_df, here::here("processed_data","mpi_locations"))
center_on <- locations_df%>%
summarize(lat=mean(lat),
lon=mean(lon))
leafMap <- leaflet(locations_df) %>%
setView(lat = center_on$lat, lng = center_on$lon, zoom = 4) %>%
addTiles() %>%
addMarkers(~lon, ~lat, popup = ~place, label = ~place) %>%
addProviderTiles(providers$Esri.WorldStreetMap)
leafMap