Instantly share code, notes, and snippets.

@tts /kulosaari.R
Last active Aug 29, 2015

Embed
What would you like to do?
Helsinki roadmap and 3D buildings on a georeferenced map of Kulosaari
##########################################################
#
# Helsinki roadmap and 3D buildings rendered
# on a georeferenced map of Kulosaari from 1917
# as an intearctive leaflet map.
#
# See http://tuijasonkkila.fi/blog/2015/03/2015-on-1917/
#
# Map of Kulosaari
# Helsingin kaupungin tietokeskus;
# Helsingin kaupunginarkisto / Kaupunkisuunnitteluvirasto,
# asemakaavaosaston arkisto.
# http://creativecommons.org/licenses/by/4.0/deed.fi
#
# Roadmap © Kaupunkimittausosasto, Helsinki 2015
# http://creativecommons.org/licenses/by/4.0/deed.fi
#
# 3D buildings, Helsingin kaupungin kiinteistövirasto
# http://creativecommons.org/licenses/by/4.0/deed.fi
#
# Tuija Sonkkila 25.3.2015
#
#########################################################
library(leaflet)
library(rgdal)
streets <- readOGR("vaylat",
"kulosaarionly",
stringsAsFactors = F,
verbose = T,
encoding = "ISO-8859-1")
motorways <- streets[grep("Moottori", streets$Vaylatyypp), ]
motorways_xy <- spTransform(motorways, CRS("+proj=longlat +datum=WGS84"))
bridges <- streets[grep("Silta", streets$Vaylatyypp), ]
bridges_xy <- spTransform(bridges, CRS("+proj=longlat +datum=WGS84"))
paths <- streets[streets$Vaylatyypp == 'Polku',]
paths_xy <- spTransform(paths, CRS("+proj=longlat +datum=WGS84"))
steps <- streets[streets$Vaylatyypp == 'Porras',]
steps_xy <- spTransform(steps, CRS("+proj=longlat +datum=WGS84"))
parkways <- streets[streets$Vaylatyypp == 'Puistotie (hiekka)',]
parkways_xy <- spTransform(parkways, CRS("+proj=longlat +datum=WGS84"))
serviceallowed <- streets[streets$Vaylatyypp == 'Huoltoajo sallittu',]
serviceallowed_xy <- spTransform(serviceallowed, CRS("+proj=longlat +datum=WGS84"))
underpasses <- streets[streets$Vaylatyypp == 'Alikulku (jalkakäytävä, pyörätie)', ]
underpasses_xy <- spTransform(underpasses, CRS("+proj=longlat +datum=WGS84"))
k674499 <- RJSONIO::fromJSON("674499.geojson")
k674499$style <- list(weight = 1, color = "darkslategray", fillColor = "gray10", stroke = "true", fill = "true", opacity = 1, fillOpacity = 0.6)
k674500 <- RJSONIO::fromJSON("674500.geojson")
k674500$style <- list(weight = 1, color = "darkslategray", fillColor = "gray20", stroke = "true", fill = "true", opacity = 1, fillOpacity = 0.6)
k675499 <- RJSONIO::fromJSON("675499.geojson")
k675499$style <- list(weight = 1, color = "darkslategray", fillColor = "gray30", stroke = "true", fill = "true", opacity = 1, fillOpacity = 0.6)
k675500 <- RJSONIO::fromJSON("675500.geojson")
k675500$style <- list(weight = 1, color = "darkslategray", fillColor = "gray40", stroke = "true", fill = "true", opacity = 1, fillOpacity = 0.6)
leaflet() %>%
setView(24.999187, 60.188158, zoom = 16) %>%
addTiles(
urlTemplate = "http://tuijasonkkila.fi/tiles/kulo/{z}/{x}/{y}.png",
attribution = 'Data source: <a href="http://www.hri.fi/fi/dataset/kartta-kulosaaren-huvilakaupungista-vuodelta-1917">Helsingin kaupungin tietokeskus</a>',
options = tileOptions(minZoom = 15, maxZoom = 18, tms = TRUE)) %>%
addPolylines(data = motorways_xy, color = "red", weight = 4) %>%
addPolylines(data = paths_xy, color = "brown", weight = 4) %>%
addPolylines(data = underpasses_xy, color = "yellow", weight = 4) %>%
addPolylines(data = steps_xy, color = "black", weight = 5) %>%
addPolylines(data = serviceallowed_xy, color = "white", weight = 5) %>%
addPolylines(data = bridges_xy, color = "slateblue", weight = 4) %>%
addPolylines(data = parkways_xy, color = "darkgreen", weight = 5)
addGeoJSON(k674499) %>%
addGeoJSON(k674500) %>%
addGeoJSON(k675499) %>%
addGeoJSON(k675500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment