-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday9.R
39 lines (28 loc) · 1.31 KB
/
day9.R
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
# 9: Monochrome
## finding the main streets of a city:
# do random 500 x 500 routes and plot thickness of overlapping lines
library(sf)
library(dplyr)
library(osrm)
library(stplanr)
library(leaflet)
library(htmltools)
# get 500 random routings
berlin <- st_read("data/berlin_bz.geojson")
start_points <- st_sample(berlin,size=500) %>% st_as_sf
end_points <- st_sample(berlin,size=500) %>% st_as_sf
# the routing takes a few minutes
routes <- route(from = start_points,
to = end_points,
route_fun = osrmRoute,
returnclass = "sf")
routes["count"] <- 1
overlapping_segments <- overline(routes, attrib = "count")
leaflet(overlapping_segments) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
addPolylines(weight = overlapping_segments$count / 4, color = "white") %>%
addControl(html = paste(tags$div(HTML("<a href = '../index.html'>< Back to overview</a>")),
tags$h2(HTML("The life lines of Berlin")),
tags$div(HTML("What are the major streets in Berlin? Routing of 500 random points to 500 random points reveals the most commonly used streets.")),
tags$div(HTML("Thanks to the <a href= 'https://github.com/ropensci/stplanr'>stplanr Package</a>!"))),
position = "bottomleft")