Skip to content

Instantly share code, notes, and snippets.

@aoles
Last active June 6, 2018 14:49
Show Gist options
  • Save aoles/3e72341749098fb5abae4a991645f4d7 to your computer and use it in GitHub Desktop.
Save aoles/3e72341749098fb5abae4a991645f4d7 to your computer and use it in GitHub Desktop.
---
title: "London Blitz Bombs"
author: "Andrzej K. Oleś"
output: html_document
---
```{r config, include=FALSE}
## set up knitr defaults
knitr::opts_chunk$set(eval=TRUE, out.width='100%', out.height='560px')
```
Visualization of the location of the bombs that were dropped on London in the
night of September, 7th, 1940 based on data provided by the Guardian Data Store
& London Fire Brigade Records referenced by the website of the British National
Archives http://bombsight.org.
```{r data_source, message=FALSE, warning=FALSE}
library(googlesheets)
data_url <- "https://docs.google.com/spreadsheets/d/1rL68hnF9bHHg3p72ti_reSvwK12VEdABN5Q7YADXm3I"
data <- gs_read(gs_url(data_url))
```
In order to query openrouteservice you need to set up the API key first, see
`?ors_api_key`. The geocoding takes About 20 minutes because of the API rate
limit of 40 requests per minute.
```{r geocode, eval=FALSE}
library(openrouteservice)
## Takes about 20 min to complete, needs API key set
coordinates <- sapply(data$Location, function(loc) {
x <- ors_geocode(loc, size = 1)
x$features[[1L]]$geometry$coordinates
}, USE.NAMES = FALSE)
df <- as.data.frame(t(coordinates))
colnames(df) <- c("lng", "lat")
save(df, file = "df.rda")
```
```{r load_data, include=FALSE}
load("df.rda")
```
```{r leaflet, }
library(leaflet)
leaflet(df) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addCircleMarkers(color = "red",
radius = 5,
stroke = FALSE,
fillOpacity = 0.3) %>%
setView(-0.1278, 51.5074, 12)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment