diff --git a/module3/Analyse syndrome grippal.Rmd b/module3/Analyse syndrome grippal.Rmd index 8e857015347f4cc2198979bc90774f8dc195335b..44f9032b4db049897c2e30be08ccb2d090adaadf 100644 --- a/module3/Analyse syndrome grippal.Rmd +++ b/module3/Analyse syndrome grippal.Rmd @@ -2,7 +2,9 @@ title: "Analyse de l'incidence du syndrome grippal" author: "Marc" date: "10/04/2020" -output: html_document +output: + pdf_document: default + html_document: default --- ```{r setup, include=FALSE} diff --git a/module3/Peer_Review_cholera.Rmd b/module3/Peer_Review_cholera.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..8555d9ebcc4426ef95f12ba00f8a88772cb17630 --- /dev/null +++ b/module3/Peer_Review_cholera.Rmd @@ -0,0 +1,225 @@ +--- +title: "Peer_Review_Cholera" +author: "Marc" +date: "15/04/2020" +output: + html_document: default + pdf_document: default +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +# Instructions + +1. From numerical data, draw map in John Snow's spirit. Show death places with markers whose size indicates number of deaths. Show water pumps on the same map with a different symbol. + +2. Try to find different ways to show that the Broad street pump is at the center of the outbreak. (Density of deaths in the neighbourhood ? Other approaches ?). + +3. Submit work on FUN. + +Use `ggmap` with OpenStreetMaps as map template with `source="osm"`. + +# Importing data + +There is already an version of John Snow's data sets and map in the package `HistData` in `Snow.deaths` and `Snow.pumps`. However, the coordinates fit John Snow's map and no other maps. + +First download and extract the zip file from data sets available at this adress : [http://rtwilson.com/downloads/SnowGIS_SHP.zip](http://rtwilson.com/downloads/SnowGIS_SHP.zip). It is the first link on [Robin's blog](http://blog.rtwilson.com/john-snows-cholera-data-in-more-formats/). +Two files of interest are the `Cholera_Deaths.shp` and the `Pumps.shp` files containing death people and water pumps coordinates. +The next code lines test if the file `Cholera_Deaths.shp`exists. If not, you have to download it manually as I do not know how to unzip documents in R ... +```{r} +if(file.exists("SnowGIS_SHP/Cholera_Deaths.shp") == FALSE){ + print("You must download the zip file as explained above") +} else{ + print("Files already downloaded") +} +``` + + +# Reading the data + +In order to read `.shp` files we need the `maptools` package. +The next code lines test if maptools is installed. If not, it does and load it : +```{r message=FALSE, warning=FALSE} +if(!require("maptools")){ + install.packages("maptools") + library("maptools") +} +``` +Therefore, we can read the data with the `readShapePoints` function : +```{r} +Deaths <- readShapePoints("SnowGIS_SHP/Cholera_Deaths") +head(Deaths) +``` +We have coordinates, Id (I do not know what it is but I think it is not important) and Count that are the number of deaths at this location. +To extract coordinates, we can use the `coords`function. +```{r} +head(Deaths@coords) +``` +The number of recensed deaths is : +```{r} +sum(Deaths$Count) +``` +It seems that this is less than recorded deaths (616) displayed on the FUN website but let's suppose that it Robin's fault... + +We can also read the file with the Pumps coordinates : +```{r} +Pumps <- readShapePoints("SnowGIS_SHP/Pumps") +head(Pumps) +``` +There are 6 pumps. + +# Extracting london map + +For this purpose we will need the `ggmap` package. +The next code lines test if ggmap is installed. If not, it does and load it : +```{r message=FALSE, warning=FALSE} +if(!require("ggmap")){ + install.packages("ggmap") + library("ggmap") +} +``` +I got the london coordinates centrered on Broad Street on [Stamen Maps website](maps.stamen.com/toner/#17/51.51413/-0.13650 +) : +```{r} +london <- c(left = -0.14454, bottom = 51.51139, right = -0.13119, top = 51.51630) +``` +We will ge the map based on the above coordinates with streets names with the `maptype = "toner"`. +```{r} +london_map = get_stamenmap(london, zoom = 17, maptype = "toner") +``` +We can display the map with ggmap. +```{r} +map <- ggmap(london_map) +``` + +# Displaying the Cholera deaths and pumps on the map +We will first extract the points and their coordinates from the `.shp` file. +Remember that we put the Deaths points in the `Deaths` variable and the Pumps points in the `Pumps` variable. +```{r} +Deaths_coord <- data.frame(Deaths@coords) +Pumps_coord <- data.frame(Pumps@coords) +``` +Unfortunetely, both coordinates are in _OSGB36 National Grid_ reference while our map is in classic _decimal degrees_ reference. +Fortunetely, I found on the internet this following code that works but I do not know exactly how it works ... +It seems that it specifies the _Coordinate Reference System (CRS)_ first to the Deaths and Pumps coordinates with the `CRS` function. +And then, it transforms the system to a more classic longitude and lattitude system with the `sptransform` function. +```{r} +coordinates(Deaths_coord)=~coords.x1+coords.x2 +coordinates(Pumps_coord)=~coords.x1+coords.x2 +proj4string(Deaths_coord)=CRS("+init=epsg:27700") +proj4string(Pumps_coord)=CRS("+init=epsg:27700") +Deaths_coord = spTransform(Deaths_coord,CRS("+proj=longlat +datum=WGS84")) +Pumps_coord = spTransform(Pumps_coord,CRS("+proj=longlat +datum=WGS84")) +df_Deaths=data.frame(Deaths_coord@coords) +df_Pumps=data.frame(Pumps_coord@coords) +``` +Let's see the results : +```{r} +head(df_Deaths) +``` +```{r} +head(df_Pumps) +``` +Looks fine for both points :)! + +Let's project the Deaths points on our map with the `geom_point`function in red and with a size depending on the number of deaths recorded at the particular coordinates : +```{r} +map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) +``` +Let's add the pumps in another color and symbol : +```{r} +map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) + + geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") +``` +Highlighting the Broad street pump (number 1 in the coordinates list : +```{r} +map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) + + geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") + + geom_point(df_Pumps, mapping = aes(coords.x1[1], coords.x2[1]), color = "green", shape = 24, size = 3, fill = "green") +``` + +# Analysis to show that the Broad street pump is at the center of the outbreak + +We can try to plot a density of Deaths with the `stat_density_2d` function : +```{r} +map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) + + stat_density_2d(data = df_Deaths, aes(coords.x1, coords.x2, fill = after_stat(level)), geom = "polygon", alpha = 0.3) + + geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") + + geom_point(df_Pumps, mapping = aes(coords.x1[1], coords.x2[1]), color = "green", shape = 24, size = 3, fill = "green") +``` +We can clearly see here that the green pump on broadwick street seems to be at the center of the outbreak. + +We can try to get the coordinates of the maximum density points with function in `MASS` and `raster` libraries : +```{r} +if(!require("MASS")){ + install.packages("MASS") + library("MASS") +} +if(!require("raster")){ + install.packages("raster") + library("raster") +} +``` +As I am no mathematician I copy pasted a code from the internet. +I think that it computes and retrieve the coordiantes of the local maxima from the Deaths data frame. +```{r} +w = matrix(1,3,3) +x = kde2d(x = df_Deaths$coords.x1, y = df_Deaths$coords.x2) +r = raster(x) +f <- function(X) max(X, na.rm=TRUE) +localmax <- focal(r, w, fun = f, pad=TRUE, padValue=NA) +r2 <- r==localmax +maxXY <- xyFromCell(r2, Which(r2==1, cells=TRUE)) +maxXY <- as.data.frame(maxXY) +maxXY +``` +In maxXY there are the coordinates of the 5 local maxima. +We can plot them on the map in yellow. +```{r} +map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) + + stat_density_2d(data = df_Deaths, aes(coords.x1, coords.x2, fill = after_stat(level)), geom = "polygon", alpha = 0.3) + + geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") + + geom_point(df_Pumps, mapping = aes(coords.x1[1], coords.x2[1]), color = "green", shape = 24, size = 3, fill = "green") + + geom_point(maxXY, mapping = aes(x, y), color = "yellow", size = 3, fill = "yellow") +``` +It really seems that the closest pump to the maxima is the one on Broad street. + +Let's see if we can compute the distance between these maxima and the pumps to show what pump is the closest to what maximum. +If I remember well, the distance between 2 points on a graph can be calculated with the following equation : $$\frac{y2 - y1}{x2 - x1}$$. +```{r} +dist_pump1 <- c() +dist_pump2 <- c() +dist_pump3 <- c() +dist_pump4 <- c() +dist_pump5 <- c() +for (i in c(1:length(maxXY$x))){ + dist_pump1[i] <- abs(maxXY$y[i]-df_Pumps$coords.x2[1])/(maxXY$x[i]-df_Pumps$coords.x1[1]) +} +for (i in c(1:length(maxXY$x))){ + dist_pump2[i] <- abs(maxXY$y[i]-df_Pumps$coords.x2[2])/(maxXY$x[i]-df_Pumps$coords.x1[2]) +} +for (i in c(1:length(maxXY$x))){ + dist_pump3[i] <- abs(maxXY$y[i]-df_Pumps$coords.x2[3])/(maxXY$x[i]-df_Pumps$coords.x1[3]) +} +for (i in c(1:length(maxXY$x))){ + dist_pump4[i] <- abs(maxXY$y[i]-df_Pumps$coords.x2[4])/(maxXY$x[i]-df_Pumps$coords.x1[4]) +} +for (i in c(1:length(maxXY$x))){ + dist_pump5[i] <- abs(maxXY$y[i]-df_Pumps$coords.x2[5])/(maxXY$x[i]-df_Pumps$coords.x1[5]) +} +dist_pump1 +dist_pump2 +dist_pump3 +dist_pump4 +dist_pump5 +``` + + + + + + + + diff --git a/module3/Peer_Review_cholera.html b/module3/Peer_Review_cholera.html new file mode 100644 index 0000000000000000000000000000000000000000..c597f6290ddc9fbc5160e055fb2dec27c6ac7481 --- /dev/null +++ b/module3/Peer_Review_cholera.html @@ -0,0 +1,619 @@ + + + + + + + + + + + + + + +Peer_Review_Cholera + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+

Instructions

+
    +
  1. From numerical data, draw map in John Snow’s spirit. Show death places with markers whose size indicates number of deaths. Show water pumps on the same map with a different symbol.

  2. +
  3. Try to find different ways to show that the Broad street pump is at the center of the outbreak. (Density of deaths in the neighbourhood ? Other approaches ?).

  4. +
  5. Submit work on FUN.

  6. +
+

Use ggmap with OpenStreetMaps as map template with source="osm".

+
+
+

Importing data

+

There is already an version of John Snow’s data sets and map in the package HistData in Snow.deaths and Snow.pumps. However, the coordinates fit John Snow’s map and no other maps.

+

First download and extract the zip file from data sets available at this adress : http://rtwilson.com/downloads/SnowGIS_SHP.zip. It is the first link on Robin’s blog.
+Two files of interest are the Cholera_Deaths.shp and the Pumps.shp files containing death people and water pumps coordinates.
+The next code lines test if the file Cholera_Deaths.shpexists. If not, you have to download it manually as I do not know how to unzip documents in R …

+
if(file.exists("SnowGIS_SHP/Cholera_Deaths.shp") == FALSE){
+  print("You must download the zip file as explained above")
+} else{
+  print("Files already downloaded")
+}
+
## [1] "Files already downloaded"
+
+
+

Reading the data

+

In order to read .shp files we need the maptools package.
+The next code lines test if maptools is installed. If not, it does and load it :

+
if(!require("maptools")){
+  install.packages("maptools")
+  library("maptools")
+}
+

Therefore, we can read the data with the readShapePoints function :

+
Deaths <- readShapePoints("SnowGIS_SHP/Cholera_Deaths")
+
## Warning: readShapePoints is deprecated; use rgdal::readOGR or sf::st_read
+
head(Deaths)
+
##            coordinates Id Count
+## 0 (529308.7, 181031.4)  0     3
+## 1 (529312.2, 181025.2)  0     2
+## 2 (529314.4, 181020.3)  0     1
+## 3 (529317.4, 181014.3)  0     1
+## 4 (529320.7, 181007.9)  0     4
+## 5   (529336.7, 181006)  0     2
+

We have coordinates, Id (I do not know what it is but I think it is not important) and Count that are the number of deaths at this location.
+To extract coordinates, we can use the coordsfunction.

+
head(Deaths@coords)
+
##   coords.x1 coords.x2
+## 0  529308.7  181031.4
+## 1  529312.2  181025.2
+## 2  529314.4  181020.3
+## 3  529317.4  181014.3
+## 4  529320.7  181007.9
+## 5  529336.7  181006.0
+

The number of recensed deaths is :

+
sum(Deaths$Count)
+
## [1] 489
+

It seems that this is less than recorded deaths (616) displayed on the FUN website but let’s suppose that it Robin’s fault…

+

We can also read the file with the Pumps coordinates :

+
Pumps <- readShapePoints("SnowGIS_SHP/Pumps")
+
## Warning: readShapePoints is deprecated; use rgdal::readOGR or sf::st_read
+
head(Pumps)
+
##            coordinates Id
+## 0 (529396.5, 181025.1)  0
+## 1 (529192.5, 181079.4)  0
+## 2 (529183.7, 181193.7)  0
+## 3 (529748.9, 180924.2)  0
+## 4 (529613.2, 180896.8)  0
+## 5 (529453.6, 180826.4)  0
+

There are 6 pumps.

+
+
+

Extracting london map

+

For this purpose we will need the ggmap package.
+The next code lines test if ggmap is installed. If not, it does and load it :

+
if(!require("ggmap")){
+  install.packages("ggmap")
+  library("ggmap")
+}
+

I got the london coordinates centrered on Broad Street on Stamen Maps website :

+
london <- c(left = -0.14454, bottom = 51.51139, right = -0.13119, top = 51.51630)
+

We will ge the map based on the above coordinates with streets names with the maptype = "toner".

+
london_map = get_stamenmap(london, zoom = 17, maptype = "toner")
+
## Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
+

We can display the map with ggmap.

+
map <- ggmap(london_map)
+
+
+

Displaying the Cholera deaths and pumps on the map

+

We will first extract the points and their coordinates from the .shp file.
+Remember that we put the Deaths points in the Deaths variable and the Pumps points in the Pumps variable.

+
Deaths_coord <- data.frame(Deaths@coords)
+Pumps_coord <- data.frame(Pumps@coords)
+

Unfortunetely, both coordinates are in OSGB36 National Grid reference while our map is in classic decimal degrees reference.
+Fortunetely, I found on the internet this following code that works but I do not know exactly how it works …
+It seems that it specifies the Coordinate Reference System (CRS) first to the Deaths and Pumps coordinates with the CRS function.
+And then, it transforms the system to a more classic longitude and lattitude system with the sptransform function.

+
coordinates(Deaths_coord)=~coords.x1+coords.x2
+coordinates(Pumps_coord)=~coords.x1+coords.x2
+proj4string(Deaths_coord)=CRS("+init=epsg:27700") 
+proj4string(Pumps_coord)=CRS("+init=epsg:27700") 
+Deaths_coord = spTransform(Deaths_coord,CRS("+proj=longlat +datum=WGS84"))
+Pumps_coord = spTransform(Pumps_coord,CRS("+proj=longlat +datum=WGS84"))
+df_Deaths=data.frame(Deaths_coord@coords)
+df_Pumps=data.frame(Pumps_coord@coords)
+

Let’s see the results :

+
head(df_Deaths)
+
##    coords.x1 coords.x2
+## 0 -0.1379301  51.51342
+## 1 -0.1378831  51.51336
+## 2 -0.1378529  51.51332
+## 3 -0.1378120  51.51326
+## 4 -0.1377668  51.51320
+## 5 -0.1375369  51.51318
+
head(df_Pumps)
+
##    coords.x1 coords.x2
+## 0 -0.1366679  51.51334
+## 1 -0.1395862  51.51388
+## 2 -0.1396710  51.51491
+## 3 -0.1316299  51.51235
+## 4 -0.1335944  51.51214
+## 5 -0.1359191  51.51154
+

Looks fine for both points :)!

+

Let’s project the Deaths points on our map with the geom_pointfunction in red and with a size depending on the number of deaths recorded at the particular coordinates :

+
map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5)
+

Let’s add the pumps in another color and symbol :

+
map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) +
+  geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue")
+
## Warning: Removed 2 rows containing missing values (geom_point).
+

Highlighting the Broad street pump (number 1 in the coordinates list :

+
map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) +
+  geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") +
+  geom_point(df_Pumps, mapping = aes(coords.x1[1], coords.x2[1]), color = "green", shape = 24, size = 3, fill = "green")
+
## Warning: Removed 2 rows containing missing values (geom_point).
+

+
+
+

Analysis to show that the Broad street pump is at the center of the outbreak

+

We can try to plot a density of Deaths with the stat_density_2d function :

+
map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) + 
+  stat_density_2d(data = df_Deaths, aes(coords.x1, coords.x2, fill = after_stat(level)), geom = "polygon", alpha = 0.3) +
+  geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") +
+  geom_point(df_Pumps, mapping = aes(coords.x1[1], coords.x2[1]), color = "green", shape = 24, size = 3, fill = "green")
+
## Warning: Removed 2 rows containing missing values (geom_point).
+

We can clearly see here that the green pump on broadwick street seems to be at the center of the outbreak.

+

We can try to get the coordinates of the maximum density points with function in MASS and raster libraries :

+
if(!require("MASS")){
+  install.packages("MASS")
+  library("MASS")
+}
+
## Loading required package: MASS
+
if(!require("raster")){
+  install.packages("raster")
+  library("raster")
+}
+
## Loading required package: raster
+
## 
+## Attaching package: 'raster'
+
## The following objects are masked from 'package:MASS':
+## 
+##     area, select
+

As I am no mathematician I copy pasted a code from the internet.
+I think that it computes and retrieve the coordiantes of the local maxima from the Deaths data frame.

+
w = matrix(1,3,3)
+x = kde2d(x = df_Deaths$coords.x1, y = df_Deaths$coords.x2)
+r = raster(x)
+f <- function(X) max(X, na.rm=TRUE)
+localmax <- focal(r, w, fun = f, pad=TRUE, padValue=NA)
+r2 <- r==localmax
+maxXY <- xyFromCell(r2, Which(r2==1, cells=TRUE))
+maxXY <- as.data.frame(maxXY)
+maxXY
+
##            x        y
+## 1 -0.1344211 51.51583
+## 2 -0.1341236 51.51434
+## 3 -0.1359086 51.51401
+## 4 -0.1379912 51.51335
+## 5 -0.1365037 51.51285
+

In maxXY there are the coordinates of the 5 local maxima.
+We can plot them on the map in yellow.

+
map + geom_point(df_Deaths, mapping = aes(coords.x1, coords.x2), color = "red", size = Deaths$Count, alpha = 0.5) + 
+  stat_density_2d(data = df_Deaths, aes(coords.x1, coords.x2, fill = after_stat(level)), geom = "polygon", alpha = 0.3) +
+  geom_point(df_Pumps, mapping = aes(coords.x1, coords.x2), color = "blue", shape = 24, size = 3, fill = "blue") +
+  geom_point(df_Pumps, mapping = aes(coords.x1[1], coords.x2[1]), color = "green", shape = 24, size = 3, fill = "green") +
+  geom_point(maxXY, mapping = aes(x, y), color = "yellow", size = 3, fill = "yellow")
+
## Warning: Removed 2 rows containing missing values (geom_point).
+

It really seems that the closest pump to the maxima is the one on Broad street.

+

Let’s see if we can compute the distance between these maxima and the pumps to show what pump is the closest to what maximum.
+If I remember well, the distance between 2 points on a graph can be calculated with the following equation : \[\frac{y2 - y1}{x2 - x1}\].

+
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/module3/Peer_Review_cholera.pdf b/module3/Peer_Review_cholera.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f0142339c2b175716098341c3a721bace48de6ad Binary files /dev/null and b/module3/Peer_Review_cholera.pdf differ diff --git a/module3/SnowGIS_SHP/Cholera_Deaths.dbf b/module3/SnowGIS_SHP/Cholera_Deaths.dbf new file mode 100644 index 0000000000000000000000000000000000000000..fa87c71bd68314ed337415fb01daa179adeaf5d9 Binary files /dev/null and b/module3/SnowGIS_SHP/Cholera_Deaths.dbf differ diff --git a/module3/SnowGIS_SHP/Cholera_Deaths.prj b/module3/SnowGIS_SHP/Cholera_Deaths.prj new file mode 100644 index 0000000000000000000000000000000000000000..9c24ee3b83411a6b7b3824844482477578ed1d96 --- /dev/null +++ b/module3/SnowGIS_SHP/Cholera_Deaths.prj @@ -0,0 +1 @@ +PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646]],PRIMEM["Greenwich",0.0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],PARAMETER["central_meridian",-2.0],PARAMETER["scale_factor",0.9996012717],PARAMETER["latitude_of_origin",49.0],UNIT["m",1.0]] \ No newline at end of file diff --git a/module3/SnowGIS_SHP/Cholera_Deaths.sbn b/module3/SnowGIS_SHP/Cholera_Deaths.sbn new file mode 100644 index 0000000000000000000000000000000000000000..78b67b87f59ebc0eaaff28cc8aef777f625fa7f4 Binary files /dev/null and b/module3/SnowGIS_SHP/Cholera_Deaths.sbn differ diff --git a/module3/SnowGIS_SHP/Cholera_Deaths.sbx b/module3/SnowGIS_SHP/Cholera_Deaths.sbx new file mode 100644 index 0000000000000000000000000000000000000000..2e583478e3601c51335e776bf238aa69dc00d2b3 Binary files /dev/null and b/module3/SnowGIS_SHP/Cholera_Deaths.sbx differ diff --git a/module3/SnowGIS_SHP/Cholera_Deaths.shp b/module3/SnowGIS_SHP/Cholera_Deaths.shp new file mode 100644 index 0000000000000000000000000000000000000000..36257407885624121ec93ac267072b797c6f9ac9 Binary files /dev/null and b/module3/SnowGIS_SHP/Cholera_Deaths.shp differ diff --git a/module3/SnowGIS_SHP/Cholera_Deaths.shx b/module3/SnowGIS_SHP/Cholera_Deaths.shx new file mode 100644 index 0000000000000000000000000000000000000000..1871dbee2783331929f391f91928cd33e3c12e99 Binary files /dev/null and b/module3/SnowGIS_SHP/Cholera_Deaths.shx differ diff --git a/module3/SnowGIS_SHP/OSMap.tfw b/module3/SnowGIS_SHP/OSMap.tfw new file mode 100644 index 0000000000000000000000000000000000000000..0c98219dff65c33cbff2a34e40ba576281c53a76 --- /dev/null +++ b/module3/SnowGIS_SHP/OSMap.tfw @@ -0,0 +1,6 @@ +1.0000000000 +0.0000000000 +0.0000000000 +-1.0000000000 +528765.5000000000 +181518.5000000000 diff --git a/module3/SnowGIS_SHP/OSMap.tif b/module3/SnowGIS_SHP/OSMap.tif new file mode 100644 index 0000000000000000000000000000000000000000..543449fca3bca09d3dca661a517aa286b5d05675 Binary files /dev/null and b/module3/SnowGIS_SHP/OSMap.tif differ diff --git a/module3/SnowGIS_SHP/OSMap_Grayscale.tfw b/module3/SnowGIS_SHP/OSMap_Grayscale.tfw new file mode 100644 index 0000000000000000000000000000000000000000..cec30fb38b277a4ac9786595102b4934713d41ae --- /dev/null +++ b/module3/SnowGIS_SHP/OSMap_Grayscale.tfw @@ -0,0 +1,6 @@ +1.0000000000 +0.0000000000 +0.0000000000 +-0.9841121495 +528765.5000000000 +181518.5079439252 diff --git a/module3/SnowGIS_SHP/OSMap_Grayscale.tif b/module3/SnowGIS_SHP/OSMap_Grayscale.tif new file mode 100644 index 0000000000000000000000000000000000000000..b34cfb5c22ddcfb781d834953d0e359f5ab9208a Binary files /dev/null and b/module3/SnowGIS_SHP/OSMap_Grayscale.tif differ diff --git a/module3/SnowGIS_SHP/OSMap_Grayscale.tif.aux.xml b/module3/SnowGIS_SHP/OSMap_Grayscale.tif.aux.xml new file mode 100644 index 0000000000000000000000000000000000000000..1219c2595f62f66ae1e6b2ccfcd156ea838c0d80 --- /dev/null +++ b/module3/SnowGIS_SHP/OSMap_Grayscale.tif.aux.xml @@ -0,0 +1,11 @@ + + + + NEAREST + + + + THEMATIC + + + diff --git a/module3/SnowGIS_SHP/OSMap_Grayscale.tif.ovr b/module3/SnowGIS_SHP/OSMap_Grayscale.tif.ovr new file mode 100644 index 0000000000000000000000000000000000000000..d9ec763f2927c90acf04fdaecddd3aedb1fc0f61 Binary files /dev/null and b/module3/SnowGIS_SHP/OSMap_Grayscale.tif.ovr differ diff --git a/module3/SnowGIS_SHP/Pumps.dbf b/module3/SnowGIS_SHP/Pumps.dbf new file mode 100644 index 0000000000000000000000000000000000000000..e6d3a34a64f072d0443c885e1b26ef2a7900cdc0 Binary files /dev/null and b/module3/SnowGIS_SHP/Pumps.dbf differ diff --git a/module3/SnowGIS_SHP/Pumps.prj b/module3/SnowGIS_SHP/Pumps.prj new file mode 100644 index 0000000000000000000000000000000000000000..9c24ee3b83411a6b7b3824844482477578ed1d96 --- /dev/null +++ b/module3/SnowGIS_SHP/Pumps.prj @@ -0,0 +1 @@ +PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646]],PRIMEM["Greenwich",0.0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],PARAMETER["central_meridian",-2.0],PARAMETER["scale_factor",0.9996012717],PARAMETER["latitude_of_origin",49.0],UNIT["m",1.0]] \ No newline at end of file diff --git a/module3/SnowGIS_SHP/Pumps.sbx b/module3/SnowGIS_SHP/Pumps.sbx new file mode 100644 index 0000000000000000000000000000000000000000..c54ddbe4c91094139d3000182f772ef87d4dcbaf Binary files /dev/null and b/module3/SnowGIS_SHP/Pumps.sbx differ diff --git a/module3/SnowGIS_SHP/Pumps.shp b/module3/SnowGIS_SHP/Pumps.shp new file mode 100644 index 0000000000000000000000000000000000000000..eb76199858d5ff403d8b2512a78cb512f1c2fc47 Binary files /dev/null and b/module3/SnowGIS_SHP/Pumps.shp differ diff --git a/module3/SnowGIS_SHP/Pumps.shx b/module3/SnowGIS_SHP/Pumps.shx new file mode 100644 index 0000000000000000000000000000000000000000..4cc4dce7a38b6134528db8643ce7a4e6fe70b25d Binary files /dev/null and b/module3/SnowGIS_SHP/Pumps.shx differ diff --git a/module3/SnowGIS_SHP/README.txt b/module3/SnowGIS_SHP/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..e72abeecf2cc73fac1431c55044d217aae131b20 --- /dev/null +++ b/module3/SnowGIS_SHP/README.txt @@ -0,0 +1,23 @@ +README file for Snow GIS data +----------------------------- + +This zip file contains a number of GIS layers relating to John Snow's 1854 investigation of a +Cholera outbreak in London - considered by many to be the first use of geographical analysis +in an epidemiological study. More details on the history are available at +http://en.wikipedia.org/wiki/1854_Broad_Street_cholera_outbreak + +This file contains a number of GIS layers created from Snow's original map which allow analyses to be +conducted on the data in modern GIS systems. For example, clustering of cases can be analysed and the +effect of spatial aggregation in modern anonymised health data releases. Of course, it's also just +interesting to look at the area, and how little it has changed since 1854. + +Files included: +(Many of the items in the list consist of many actual files (for example .shp, .dbf etc) + +* OSMap Raster Modern OS map of the area of the outbreak (from OS Open Data - contains Ordnance Survey data © Crown copyright and database right 2013) +* OSMap_Greyscale Raster Same as above, but in greyscale for easier visualisation (altered by conversion to greyscale, from OS Open Data - contains Ordnance Survey data © Crown copyright and database right 2013) +* SnowMap Raster Snow's original map, georeferenced and warped so that it accurately overlays the OS map +* CholeraDeaths Vector Points for each location of one or more deaths. Attribute value gives number of deaths at that location +* Pumps Vector Points for each location of a pump + +Created and compiled by Robin Wilson (robin@rtwilson.com, www.rtwilson.com/academic) - Jan 2011. \ No newline at end of file diff --git a/module3/SnowGIS_SHP/SnowMap.tfw b/module3/SnowGIS_SHP/SnowMap.tfw new file mode 100644 index 0000000000000000000000000000000000000000..29214e9db275d3436b1355a3acef39c56884ccbf --- /dev/null +++ b/module3/SnowGIS_SHP/SnowMap.tfw @@ -0,0 +1,6 @@ +0.3159420000 +0.0000000000 +0.0000000000 +-0.3159420000 +528865.7464993792 +181433.8952167343 diff --git a/module3/SnowGIS_SHP/SnowMap.tif b/module3/SnowGIS_SHP/SnowMap.tif new file mode 100644 index 0000000000000000000000000000000000000000..6c93480f7e00066e896cd1f2e1fccaa800b1fd22 Binary files /dev/null and b/module3/SnowGIS_SHP/SnowMap.tif differ diff --git a/module3/SnowGIS_SHP/SnowMap.tif.aux.xml b/module3/SnowGIS_SHP/SnowMap.tif.aux.xml new file mode 100644 index 0000000000000000000000000000000000000000..0acdf5fd960dc437c243e54b42c93f1216db1cbc --- /dev/null +++ b/module3/SnowGIS_SHP/SnowMap.tif.aux.xml @@ -0,0 +1,60 @@ + + + + NEAREST + + + + + -0.5 + 255.5 + 256 + 1 + 0 + 1056558|38085|35030|30635|26721|23196|19973|17614|15202|13621|12110|10633|9602|8622|7615|6827|6160|5785|5263|4850|4471|4102|3821|3520|3396|3346|3106|3054|2953|2870|2747|2735|2682|2717|2536|2555|2465|2514|2461|2489|2566|2390|2491|2486|2418|2385|2321|2323|2264|2291|2389|2392|2227|2301|2275|2187|2254|2250|2202|2205|2187|2217|2155|2220|2105|2123|2165|2206|2149|2031|2108|2141|2066|2100|2080|2025|2107|2075|2068|2019|2023|2010|2026|2005|1995|2090|1978|2045|1994|1989|1999|2039|1942|1972|1946|1990|2006|1964|1962|1893|1939|1906|1888|1908|1968|1846|1918|1979|2044|1925|1884|1859|1862|1947|1930|1825|1934|1891|1975|1830|1898|1895|1926|1973|1924|1986|1920|1797|1912|1986|1890|1924|1944|1915|1996|1900|1925|1945|2011|1882|1953|1952|1974|1929|1997|2053|1981|1993|1959|1880|1925|1946|2015|1947|1917|2052|2062|2071|2017|2089|1949|2030|2007|2083|2080|1949|2085|2111|2091|2151|2135|2137|2019|2129|2076|2149|2084|2188|2108|2188|2105|2178|2159|2197|2146|2174|2360|2281|2260|2259|2254|2297|2279|2338|2337|2365|2450|2368|2407|2407|2435|2379|2488|2492|2497|2525|2490|2566|2577|2565|2676|2712|2726|2674|2688|2799|2707|2738|2831|2956|2800|2961|2904|3059|2994|3157|3254|3316|3508|3710|3905|4319|4664|5116|5937|6536|7435|8678|9923|11935|13906|16928|19919|23808|28421|34066|40774|48059|57324|67501|80304|94264|109903|125204|137869|5850359 + + + + 0 + 255 + 207.40977040919 + 94.77357404896 + + + + + + -0.5 + 255.5 + 256 + 1 + 0 + 1056558|38085|35030|30635|26721|23196|19973|17614|15202|13621|12110|10633|9602|8622|7615|6827|6160|5785|5263|4850|4471|4102|3821|3520|3396|3346|3106|3054|2953|2870|2747|2735|2682|2717|2536|2555|2465|2514|2461|2489|2566|2390|2491|2486|2418|2385|2321|2323|2264|2291|2389|2392|2227|2301|2275|2187|2254|2250|2202|2205|2187|2217|2155|2220|2105|2123|2165|2206|2149|2031|2108|2141|2066|2100|2080|2025|2107|2075|2068|2019|2023|2010|2026|2005|1995|2090|1978|2045|1994|1989|1999|2039|1942|1972|1946|1990|2006|1964|1962|1893|1939|1906|1888|1908|1968|1846|1918|1979|2044|1925|1884|1859|1862|1947|1930|1825|1934|1891|1975|1830|1898|1895|1926|1973|1924|1986|1920|1797|1912|1986|1890|1924|1944|1915|1996|1900|1925|1945|2011|1882|1953|1952|1974|1929|1997|2053|1981|1993|1959|1880|1925|1946|2015|1947|1917|2052|2062|2071|2017|2089|1949|2030|2007|2083|2080|1949|2085|2111|2091|2151|2135|2137|2019|2129|2076|2149|2084|2188|2108|2188|2105|2178|2159|2197|2146|2174|2360|2281|2260|2259|2254|2297|2279|2338|2337|2365|2450|2368|2407|2407|2435|2379|2488|2492|2497|2525|2490|2566|2577|2565|2676|2712|2726|2674|2688|2799|2707|2738|2831|2956|2800|2961|2904|3059|2994|3157|3254|3316|3508|3710|3905|4319|4664|5116|5937|6536|7435|8678|9923|11935|13906|16928|19919|23808|28421|34066|40774|48059|57324|67501|80304|94264|109903|125204|137869|5850359 + + + + 0 + 255 + 207.40977040919 + 94.77357404896 + + + + + + -0.5 + 255.5 + 256 + 1 + 0 + 1056558|38085|35030|30635|26721|23196|19973|17614|15202|13621|12110|10633|9602|8622|7615|6827|6160|5785|5263|4850|4471|4102|3821|3520|3396|3346|3106|3054|2953|2870|2747|2735|2682|2717|2536|2555|2465|2514|2461|2489|2566|2390|2491|2486|2418|2385|2321|2323|2264|2291|2389|2392|2227|2301|2275|2187|2254|2250|2202|2205|2187|2217|2155|2220|2105|2123|2165|2206|2149|2031|2108|2141|2066|2100|2080|2025|2107|2075|2068|2019|2023|2010|2026|2005|1995|2090|1978|2045|1994|1989|1999|2039|1942|1972|1946|1990|2006|1964|1962|1893|1939|1906|1888|1908|1968|1846|1918|1979|2044|1925|1884|1859|1862|1947|1930|1825|1934|1891|1975|1830|1898|1895|1926|1973|1924|1986|1920|1797|1912|1986|1890|1924|1944|1915|1996|1900|1925|1945|2011|1882|1953|1952|1974|1929|1997|2053|1981|1993|1959|1880|1925|1946|2015|1947|1917|2052|2062|2071|2017|2089|1949|2030|2007|2083|2080|1949|2085|2111|2091|2151|2135|2137|2019|2129|2076|2149|2084|2188|2108|2188|2105|2178|2159|2197|2146|2174|2360|2281|2260|2259|2254|2297|2279|2338|2337|2365|2450|2368|2407|2407|2435|2379|2488|2492|2497|2525|2490|2566|2577|2565|2676|2712|2726|2674|2688|2799|2707|2738|2831|2956|2800|2961|2904|3059|2994|3157|3254|3316|3508|3710|3905|4319|4664|5116|5937|6536|7435|8678|9923|11935|13906|16928|19919|23808|28421|34066|40774|48059|57324|67501|80304|94264|109903|125204|137869|5850359 + + + + 0 + 255 + 207.40977040919 + 94.77357404896 + + + diff --git a/module3/SnowGIS_SHP/SnowMap.tif.ovr b/module3/SnowGIS_SHP/SnowMap.tif.ovr new file mode 100644 index 0000000000000000000000000000000000000000..7b5ea01f132c0be8255d51618a2bc4f8f834be05 Binary files /dev/null and b/module3/SnowGIS_SHP/SnowMap.tif.ovr differ diff --git a/module3/exo2/exercice_fr.Rmd b/module3/exo2/exercice_fr.Rmd index 797fe3f8402defddb68a894a5c3982612b5159ff..275354db2255a77e984e1ab6f6993ae950f3dc9b 100644 --- a/module3/exo2/exercice_fr.Rmd +++ b/module3/exo2/exercice_fr.Rmd @@ -2,7 +2,9 @@ title: "Analyse varicelle" author: "Marc Oudart" date: "11/04/2020" -output: html_document +output: + pdf_document: default + html_document: default --- @@ -55,7 +57,7 @@ Tous les deux sont des entiers donc pas de transformation à faire. Il faut que R comprenne que la 1ère colonne sont des dates. Il nous faut donc la librairie `parsedate`. ```{r message=FALSE, warning=FALSE} -install.packages("parsedate") + library("parsedate") ``` diff --git a/module3/exo2/exercice_fr.pdf b/module3/exo2/exercice_fr.pdf new file mode 100644 index 0000000000000000000000000000000000000000..dc55871039c1fc7f0c08066e9a4f64bad60cb7ba Binary files /dev/null and b/module3/exo2/exercice_fr.pdf differ