Code
<- st_as_sf(cities, coords = c("lng", "lat"), crs = 4326) cities
For this follow-up exercise, create an R markdown file that, when knitted, includes the code and output for the following, ideally as a pdf document:
cities
. The data were sourced from here.cities
into spatial points:RAvgScor
, which is the rank of the average 2019 multiple deprivation score for the authorities. Aim for the map to be of a publishable quality – suitable for a journal publication. Include cities above a chosen population threshold on your map to provide some geographical context for the reader.Then add a very brief textual comment beneath your code and map(s) to provide a brief description of the geography of deprivation shown – do you see any geographical pattern(s)?
All that you need is in the session ‘Thematic maps in R’. However, you do need to decide whether to produce your map in ggplot2
or tmap
. You could always impress me and use both!
---
title: "Follow-up exercise"
execute:
warning: false
message: false
---
## To do
For this follow-up exercise, **create an R markdown file** that, when *knit*ted, includes the code and output for the following, ideally as a **pdf document**:
- **To read the following file into R**: [https://github.com/profrichharris/profrichharris.github.io/raw/main/MandM/boundary%20files/Local_Authority.geojson](https://github.com/profrichharris/profrichharris.github.io/raw/main/MandM/boundary%20files/Local_Authority.geojson){target="_blank"}. The file is in .geojson format. The data are sourced from [here](https://data-communities.opendata.arcgis.com/search?q=IMD){target="_blank"} and give Index of Multiple Deprivation (IMD) data for English local authorities.
- **To read the following file into R**: [https://github.com/profrichharris/profrichharris.github.io/raw/main/MandM/data/gb.csv](https://github.com/profrichharris/profrichharris.github.io/raw/main/MandM/data/gb.csv){target="_blank"}. This gives the names, population size and a centroid location for 2,680 prominent cities in United Kingdom. The file is in .csv format (with a header). Read it into an object called `cities`. The data were sourced from [here](https://simplemaps.com/data/gb-cities){target="_blank"}.
- **To run the following code**, which will convert the `cities` into spatial points:
```{r}
#| eval: false
cities <- st_as_sf(cities, coords = c("lng", "lat"), crs = 4326)
```
- **To run the following code**, which will 'clip out' the cities that are not in England:
```{r}
#| eval: false
cities <- st_filter(cities, imd)
```
- **To draw a map** of the variable `RAvgScor`, which is the rank of the average 2019 multiple deprivation score for the authorities. Aim for the map to be of a publishable quality -- suitable for a journal publication. Include cities above a chosen population threshold on your map to provide some geographical context for the reader.
Then add a very brief textual comment beneath your code and map(s) to provide a brief description of the geography of deprivation shown -- do you see any geographical pattern(s)?
## To help
All that you need is in the session 'Thematic maps in R'. However, you do need to decide whether to produce your map in `ggplot2` or `tmap`. You could always impress me and use both!