With the help of a few visiting students, I am trying to work out how to do some geomapping for Wales in R.
Find some maps of Wales
First I have to find a source of some maps.These are usually in a digital vector format.
The Office for National Statistics has some available here:
https://geoportal.statistics.gov.uk/geoportal/catalog/search/browse/browse.page
Browse the catalogue and look at "digital boundaries".
There are local boundaries of various levels.
A useful one is the map of boundaries of Local Health Boards in Wales. This was last updated in 2014. It's available here: https://geoportal.statistics.gov.uk/Docs/Boundaries/Local_health_boards_(Wal)_2014_Boundaries_(Generalised_Clipped).zip
The zip file need to be downloaded and placed in a sensible folder. The format of these files is a ESRI shapefile. This can be imported into R.
Lots of health data is gathered and delivered according to Local Health Board. This only divides Wales into 7 regions and they vary by population and many other ways.
Getting the data in to R
I have found two ways so far:
- using the readOGR() function from the library(rgdal)
- using the readShapeSpatial() function from the library(maptools)
Plotting the data
Boundaries in the UK
The boundaries in the UK are divided into various levels:
- Output areas - these are the smallest regions and over 181,000 cover the UK
- Lower Layer Super Output Areas (LSOAs) - approx 35,000 cover the UK
- Middle Super Output Areas (MSOAs) - approx 7,000 cover the UK.
- Upper Super Output Areas (USOAs) - these are used in Wales but not widely in the UK.
To draw these (except it seems the USOAs), it's possible to download the maps from the geoportal mentioned above.
There is still LOTS to learn about this.
How do I really add data to this?
Here are some resources:
- http://blog.revolutionanalytics.com/2009/11/choropleth-map-r-challenge.html
- http://www.r-bloggers.com/mucking-around-with-maps-schools-and-ethnicity-in-nz/
- http://www.r-bloggers.com/maps-with-r-and-polygon-boundaries/
- http://zevross.com/blog/2014/07/16/mapping-in-r-using-the-ggplot2-package/
- http://prabhasp.com/wp/how-to-make-choropleths-in-r/
- http://stackoverflow.com/questions/24136868/plot-map-with-values-for-countries-as-color-in-r
- http://stackoverflow.com/questions/21093399/how-to-turn-gpclibpermit-to-true
- http://stackoverflow.com/questions/20309883/filling-polygons-of-a-map-using-ggplot-in-r
- http://stackoverflow.com/questions/24284356/convert-spatialpointsdataframe-to-spatiallinesdataframe-in-r
- http://cran.r-project.org/web/packages/gdata/vignettes/mapLevels.pdf
- http://www.inside-r.org/packages/cran/rgdal/docs/ogrInfo
- http://cran.r-project.org/web/packages/rgdal/rgdal.pdf
- https://www.nceas.ucsb.edu/scicomp/usecases/ReadWriteESRIShapeFiles
- http://www.r-bloggers.com/using-r-to-produce-scalable-vector-graphics-for-the-web/
- http://cran.r-project.org/web/packages/GEOmap/vignettes/GEOmap.pdf
Data sources:
- http://www.neighbourhood.statistics.gov.uk/HTMLDocs/dvc130/index.html
- https://www.healthmapswales.wales.nhs.uk/IAS/
- http://census.ukdataservice.ac.uk/get-data/related/deprivation