Skip to content

Commit 792f66b

Browse files
author
Sara Altman
committed
add basemaps chapter and references
1 parent 6043d8d commit 792f66b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1052
-2
lines changed

_bookdown.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ new_session: true
22
delete_merged_file: true
33

44
rmd_files: [
5-
"index.Rmd"
5+
"index.Rmd",
6+
"basemaps.Rmd",
7+
"references.Rmd"
68
]
79

810
before_chapter_script: "_common.R"

basemaps.Rmd

+616
Large diffs are not rendered by default.

data/cholera/cholera_deaths.geojson

+256

data/cholera/cholera_pumps.geojson

+14

data/cholera/data.R

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Downloads and unzips Snow's cholera data
2+
# Creates two geojson files: one for pumps and one for deaths
3+
4+
# Author: Sara Altman, Bill Behrman
5+
# Version: 2019-02-27
6+
7+
# Libraries
8+
library(tidyverse)
9+
library(sf)
10+
11+
# Parameters
12+
url_data <- "http://rtwilson.com/downloads/SnowGIS_KML.zip"
13+
# Output files
14+
file_out_deaths <- "cholera_deaths.geojson"
15+
file_out_pumps <- "cholera_pumps.geojson"
16+
#===============================================================================
17+
18+
# Create temporary directory
19+
dir_tmp <- str_glue("/tmp/{Sys.time() %>% as.integer()}")
20+
if (!file.exists(dir_tmp)) {
21+
dir.create(dir_tmp, recursive = TRUE)
22+
}
23+
24+
file_zip <- str_glue("{dir_tmp}/SnowGIS_KML.zip")
25+
26+
if (download.file(url = url_data, destfile = file_zip, quiet = TRUE)) {
27+
stop("Error: Download failed")
28+
}
29+
30+
unzip(zipfile = file_zip, exdir = dir_tmp)
31+
32+
str_glue("{dir_tmp}/SnowGIS_KML/cholera_deaths.kml") %>%
33+
read_sf() %>%
34+
transmute(
35+
deaths = str_extract(Description, "\\d+") %>% as.integer(),
36+
geometry = geometry
37+
) %>%
38+
arrange(desc(deaths)) %>%
39+
st_write(file_out_deaths, delete_dsn = TRUE)
40+
41+
str_glue("{dir_tmp}/SnowGIS_KML/pumps.kml") %>%
42+
read_sf() %>%
43+
select(geometry) %>%
44+
st_write(file_out_pumps, delete_dsn = TRUE)
45+
46+
# Remove temporary directory
47+
if (unlink(dir_tmp, recursive = TRUE, force = TRUE)) {
48+
print("Error: Remove temporary directory failed")
49+
}
50+
51+
52+

data/countries/africa.geojson

+60

data/countries/data.R

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
3+
# Author: Sara Altman, Bill Behrman
4+
# Version: 2019-02-27
5+
6+
# Libraries
7+
library(tidyverse)
8+
library(sf)
9+
10+
# Parameters
11+
url_data <- "https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_0_countries.zip"
12+
# Output files
13+
file_out_africa <- "africa.geojson"
14+
#===============================================================================
15+
16+
# Create temporary directory
17+
dir_tmp <- str_glue("/tmp/{Sys.time() %>% as.integer()}")
18+
19+
if (!file.exists(dir_tmp)) {
20+
dir.create(dir_tmp, recursive = TRUE)
21+
}
22+
23+
file_zip <- str_glue("{dir_tmp}/ne_50m_admin_0_countries.zip")
24+
25+
if (download.file(url = url_data, destfile = file_zip, quiet = TRUE)) {
26+
stop("Error: Download failed")
27+
}
28+
29+
unzip(zipfile = file_zip, exdir = dir_tmp)
30+
31+
str_glue("{dir_tmp}/ne_50m_admin_0_countries.shp") %>%
32+
read_sf() %>%
33+
rename_all(str_to_lower) %>%
34+
filter(continent == "Africa") %>%
35+
select(name, population = pop_est, geometry) %>%
36+
st_write(file_out_africa)
37+
38+
# Remove temporary directory
39+
if (unlink(dir_tmp, recursive = TRUE, force = TRUE)) {
40+
print("Error: Remove temporary directory failed")
41+
}

images/Untitled.png

298 KB

images/africa.png

20.4 KB

images/cholera_circles_map.png

51 KB

images/dakar.png

12.2 KB
2.66 MB
2.67 MB

images/screenshots/circles-final.png

1.17 MB
1.61 MB
1.23 MB

images/screenshots/circles-london.png

1.23 MB

images/screenshots/circles-name.png

1.23 MB
1.13 MB
2.76 MB
2.72 MB
2.73 MB
1.02 MB
2.26 MB
1.89 MB
1.18 MB
2.66 MB

images/screenshots/heatmap-final.png

1.41 MB
1.34 MB
1.24 MB

images/screenshots/heatmap-name.png

1.23 MB
1.17 MB
1.09 MB
1.08 MB

images/screenshots/heatmap-type.png

2.89 MB
1.41 MB
461 KB
1.13 MB
248 KB
303 KB

images/screenshots/tilesets.png

301 KB

images/senegal.png

23.3 KB

index.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ url: 'https\://datalab.stanford.edu/dcl-docs/geo-vis'
88
github-repo: dcl-docs/geo-vis
99
site: bookdown::bookdown_site
1010
documentclass: book
11-
#bibliography: references.bib
11+
bibliography: references.bib
1212
link-citations: true
1313
---
1414

references.Rmd

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`r if (knitr:::is_html_output()) "# References {-}"`

references.bib

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@book{snow-1855,
2+
author = {John Snow},
3+
title = {On the Mode of Communication of Cholera},
4+
publisher = {John Churchill},
5+
year = 1855,
6+
address = {London},
7+
edition = 2
8+
}

0 commit comments

Comments
 (0)