---
title: "Care homes map"
author: "Duncan Golicher"
date: "23/02/2021"
output: html_document
---

# Shared resource

Downloaded data file from https://nhsenglandfilestore.s3.amazonaws.com/ods/ecarehomehq.zip
Georeferenced using tmaptools::geocode_OSM and cross referenced with MSOAs

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,message = FALSE,warning = FALSE,echo=FALSE)
library(mapview)
library(giscourse)
con<-sconnect11()
care_homes<-st_read(con,"carehomes")
mm<-st_read(con,"msoasshape")
disconnect(con)
library(usdata)
data(ukdata)
msoa_wave %>% filter(wave=="wave1") ->w
w %>% group_by(msoa11cd) %>% summarise(covid=sum(covid)) ->w
mm %>% right_join(w)->w
w<-st_simplify(w,dT=0.002)
w$log10_covid_deaths<-log10(w$covid+0.1)
```

```{r}
library(RColorBrewer)
colors <- brewer.pal(7, "RdYlGn")[7:1]

mapviewOptions(basemaps =c("CartoDB.Positron",
                            "OpenStreetMap",
                            "Esri.WorldImagery",
                             "Esri.WorldStreetMap",
                             "Esri.WorldShadedRelief",
                             "Stamen.Terrain"))

w %>%
mapview(zcol="log10_covid_deaths", col.regions = colors) ->mp




```

```{r}

mp+mapview(care_homes) ->mp
mp@map %>% addFullscreenControl() 
```

```{r}
d<-data.frame(care_homes$name,care_homes$msoa11cd,care_homes$postcode,st_coordinates(care_homes))
aqm::dt(d)
```

