Packages

  library("sf")
## Linking to GEOS 3.6.2, GDAL 2.2.3, PROJ 4.9.3
  library("sp")
  library("cartography")
  library("SpatialPosition")
## Loading required package: raster
  library("readxl")

Data Import

Data are avaiable online:

  com <- st_read("ign/COMMUNE.shp", quiet = T) 
  dpt <- st_read("ign/DEPARTEMENT.shp", quiet = T) 
  compop <- read.csv("insee/population2017.csv",header=TRUE,sep=",",dec=".",encoding="utf-8") 
  nd <- read_excel("data/NdB_April2016_France.xlsx", sheet = "data")
  nd <- as.data.frame(nd)  
  nd$INSEECode <- as.character(as.numeric(nd$INSEECode))

Dates & Weeks management

  prettydate <-function (x = NULL)
  {
    yyyy <- substr(x,1,4)
    mm <- substr(x,5,6)
    months <- c("January", "February","March","April","May","June","July","August","September","October","November","December")
    month <- months[as.numeric(mm)]
    dd <- substr(x,7,8)  
    str <- paste0 (month," ", dd, ", " ,yyyy)  
    return (str)
  }

  all <- c(min(nd$Date),max(nd$Date))
  week1 <- c(min(nd$Date),20160403)
  week2 <- c(20160404,20160410)
  week3 <- c(20160411,20160417)
  week4 <- c(20160418,20160424)
  week5 <- c(20160425,max(nd$Date))

PLOT 1 - Municipalities with more than 20,000 inhabitants

  par(mar = c(0,0,1.2,0))
  threshold <- 20000
  title <- paste("Municipalities with more than ",threshold," inhabitants, 2014", sep="")   
  com <- merge(x = com, y = compop, by.x = "INSEE_COM" , by.y = "id")
  cities <- st_centroid(x = com[com$pop >= threshold,], of_largest_polygon = FALSE)
## Warning in st_centroid.sf(x = com[com$pop >= threshold, ],
## of_largest_polygon = FALSE): st_centroid assumes attributes are constant
## over geometries of x
  plot(st_geometry(dpt),col="#afc3db", border="#eff4f9")
  plot(st_geometry(cities), pch=21, col="#00060f", bg="#0a2247", lwd=1, cex=0.8, add=T)
  layoutLayer(title = title, sources = "INSEE, 2018", 
              author = "Nicolas Lambert, 2018", theme = "blue.pal", scale = NULL)
  barscale(size = 100, lwd = 1.5, cex = 0.6, style = "pretty")