The only thing I remember from geography lessons at school was Oxbow lakes, that thing where a river makes a sharp u bend back on itself and the loop eventually gets cut off.
However since starting at the ONS the term geography is used A LOT, probably because nearly all the data that is collected and published relates to a place. This may seem simple to you but the various different organisations within the UK often operate at slightly different levels and boundaries, some types of area exist for any point in the UK whereas others only cover certain spaces. Add to this the complexity that the UK is made up of a number of separate ‘countries’ (best explained in this video) so for some of our datasets we may not collect data on the whole of the UK.
In order to avoid confusion between names the ONS uses a system of nine digit codes to refer to a single geographic area, these Area codes then make up part of a specific hierarchy. The hierarchies are the various different organisational structures that the datasets are fitted to, for example the 2 main ones we use on the api census data are the Parliamentary Hierarchy where the boundary of an area is aligned to the parliamentary constituencies, and the Administrative Hierarchy which follows the local authority boundaries.
The parliamentary hierarchy is one of the easiest to follow, everywhere in the UK has an MP to represent it, and those areas are also grouped together for the european parliament, there is a final lower level which follows the electoral ward boundaries, this is a nice clean hierarchy which gives you 3 levels and is consistent across the whole of the UK. The administrative hierarchy is probably easier for people to relate to their local area however the UK has different levels of local government in different places therefore it can be more complex to navigate if you are looking at an area other than your own.
This graphic does an excellent job of showing the different geographies and the hierarchies within each one.
These geographies are great ways to understand the statistical data, but when we are building a tool for end consumers to find local information we need to get their location in a format they can easily provide, then convert that to the ONS code for the most appropriate geography. ONS produces large amounts of data to convert between these codes. The 2 most useful for us are the National Statistics Postcode Lookup (NSPL) and the boundary files. The boundary data is quite complex to work with but it will allow to to go direct from a lat/long point to the relevant code without any issues of ‘best fit’ If you are getting the location data from a user either via GPS in their device or by them clicking a point on a map this is the most accurate approach. The NSPL is the other method of translating a location from a user into an ONS code, asking users for the postcode on a web form is generally a good user experience, most people will know or be able to determine a postcode for the area of interest and Postcodes are short concise and most importantly unique, no worrying about getting the wrong town where there are several with the same name.
The ONS publishes a NSPL file each month with full postcodes mapped across to the various geography codes, you can download this as a CSV to use within your own application. One thing that should be considered when translating between different areas and their coding schemes is the issue of ‘best fit’ there will be cases where an area covered by a postcode will span across the boundary of 2 different ONS area codes, in this case the ONS Geography has assigned the code which covers the centroid of the postcode area. In practice for most applications this is unlikely to cause any issues however as a developer it is something to be aware of should you get anomalies in your application.
There is a lot more to read on this subject along with the various data files mentioned which can all be downloaded from the ONS Open Geography Pages