SSPA course2018-04-16. Code: https://github.com/ITSLeeds/SSPA

Recap: why R?

  • Reproducibility requires operations to be encoded in computer code
  • That is why a command line interface (CLI) is so powerful
  • Solutions are more sustainable if they can be reproduced

Requirements: students are recommended to have the latest versions of R, RStudio and QGIS installed on their computers.

Recap: accessing data in R

Data can be accessed from a number of places including

  • OpenStreetMap via the osmdata package and the overpass website: http://overpass-turbo.eu/ - see here for parks stops in Leeds for example: http://overpass-turbo.eu/s/xWZ (global)

  • The Propensity to Cycle Tool (Lovelace et al. 2017) (Lovelace et al. 2107), which allows you to download census data on desire lines and routes in the "Region data tab", e.g for West Yorkshire (national): http://www.pct.bike/m/?r=west-yorkshire

  • Search online and read-in data with functions such as read.csv() and read_csv() using the tidyverse package (worldwide)

Reading data

We'll use the sf package to read the data.

To install the package, use the following command:

install.packages("sf")

See (Lovelace, Nowosad, and Muenchow 2018) for more info

Reading data II

To make the functions available from the package we've just installed, use the library function, as follows:

library(sf)
## Linking to GEOS 3.5.1, GDAL 2.2.2, proj.4 4.9.2

Now we can use the new powers enabled by this package, like reading in a shapefile:

stns = st_read("~/ITSLeeds/SSPA/data/stations UK/station_point.shp")
## Reading layer `station_point' from data source `/home/robin/ITSLeeds/SSPA/data/stations UK/station_point.shp' using driver `ESRI Shapefile'
## Simple feature collection with 2525 features and 3 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 147601 ymin: 30610.99 xmax: 654743 ymax: 967898.9
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +a=6377563 +b=6356256.161 +units=m +no_defs

Further resources

References

Lovelace, Robin, Anna Goodman, Rachel Aldred, Nikolai Berkoff, Ali Abbas, and James Woodcock. 2017. “The Propensity to Cycle Tool: An Open Source Online System for Sustainable Transport Planning.” Journal of Transport and Land Use 10 (1). doi:10.5198/jtlu.2016.862.

Lovelace, Robin, Jakub Nowosad, and Jannes Muenchow. 2018. Geocomputation with R.