Last active
July 1, 2018 16:16
-
-
Save aoles/52a5d0d9eb262a8fd5c286e3bfe9d354 to your computer and use it in GitHub Desktop.
Source files for http://rpubs.com/aoles/bombs_google
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 Google Maps you need to set up the API key first, see | |
`?googleway::set_key`. | |
```{r geocode, eval=FALSE} | |
library("googleway") | |
coordinates <- lapply(data$Location, function(loc) { | |
x <- google_geocode(loc) | |
x$results$geometry$location | |
}) | |
df <- do.call(rbind, coordinates) | |
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