Publications by mikerspencer

Hydrological uncertainty – Manning’s equation

23.07.2016

John Yagecic put out a great little blog post with accompanying app this week. He looked at the uncertainty from using vague parameters in Manning’s equation to estimate river flow. He made the great step of making the source code available. I forked this to the Open Hydrology repository and converted the project to metric units! Amazing! This ...

1702 sym 6 img

EARL 2016 talk

15.09.2016

I spoke on 14th September at the EARL (Effective Applications of the R Language) conference in London. This is event is concerned exclusively with the R programming language and it was the first time I’ve attended an event like this (user group meetings excluded). It was excellent, with a diverse range of interesting talks, I certainly plan to ...

3629 sym 4 img

Converting (British) National Grid references

13.10.2016

I was supplied spatial point data this summer where the locations were detailed in Ordnance Survey’s National Grid (NGR) format. If you’re not familiar with it, rather than using eastings and northings (in metres) to define location – it splits the Great Britain into lettered grid squares and then defines locations within each lettered grid...

2113 sym R (652 sym/1 pcs) 4 img

R – Change columns names in a spatial dataframe

24.03.2017

Ordnance Survey have a great OpenRoads dataset, but unfortunately it contains a column called ‘primary’, which is a keyword in SQL. This makes it challenging/impossible to import the OpenRoads dataset into a SQL database (e.g. GRASS), without changing the offending column name. Enter R! Or any other capable programming language. The following...

943 sym R (312 sym/1 pcs) 4 img

R – iteratively changing column classes

04.04.2017

When you write an ESRI Shapefile from R, writeOGR assumes your numeric fields are real numbers and so you get a lot of redundant zeros appended. This is misleading and distracting when you present data to third parties. You can fix this by changing column class from numeric to integer: class(df$col) = "integer" However, this only changes one col...

1104 sym R (114 sym/2 pcs) 4 img

R with GRASS GIS – easiest Munros

04.04.2017

I’ve been having a more sustained play with R and GRASS together. I’ve previously used them, in tandem, for processing satellite images, but haven’t been much further. In this post I’ll look at finding the nearest roads to mountain summits, querying their elevations and presenting summary statistics. First off, you can run R in GRASS or G...

2418 sym R (3610 sym/4 pcs) 18 img 2 tbl

RPostgreSQL and schemas

01.05.2017

The database PostgreSQL can have different schemas. These work like a window for users, where they get to see specific things within a database, e.g. tables. In this post we’ll look at how we can access a database with a specific schema. You’ll know you need this page if you get errors like: `Error in `[.data.frame`(dbGetQuery(conn, paste("se...

1076 sym R (983 sym/4 pcs) 4 img

Spatial networks – case study St James centre, Edinburgh (1/3)

08.10.2017

Last year I spent a bit of time learning about routing and network analysis. I created a map of distance from each GB postcode to the nearest railway station. At the time my local council were also looking at changing school catchments and building new schools. This also seemed like an excellent project for routing analysis. I made some progress ...

4450 sym R (1913 sym/2 pcs) 10 img

Celebrating 20 years of CRAN

09.10.2017

In April I spoke for the Royal Statistical Society (Glasgow branch) at their event celebrating 20 years of CRAN. The other speakers were Charis Chanialidis and Colin Gillespie. Like most people I find watching myself speak really cringe worthy, but perhaps it’s not so bad! The three talks are here: Related To leave a comment for the author, p...

701 sym 4 img

Spatial networks – case study St James centre, Edinburgh (2/3)

13.11.2017

This is part two in a series I’m writing on network analysis. The first part is here. In this section I’m going to cover allocating resources, again using the St James’ development in Edinburgh as an example. Most excitingly (for me), the end of this post covers the impact of changes in resource allocation. Edinburgh (and surrounds) has mor...

5047 sym R (3916 sym/4 pcs) 14 img 1 tbl