|
| 1 | +--- |
| 2 | +title: Cleaning the basic libraries dataset |
| 3 | +excerpt: Enhancing data on library locations |
| 4 | +categories: |
| 5 | + - Data |
| 6 | +tags: |
| 7 | + - Data |
| 8 | +published: false |
| 9 | +--- |
| 10 | + |
| 11 | +A public library dataset that has been getting some recent attention is the [basic dataset for libraries](https://www.artscouncil.org.uk/supporting-arts-museums-and-libraries/supporting-libraries) published by the Arts Council. This is _'intended to capture permanent instances of libraries, local history libraries, and archives from 1 April 2010 to 31 December 2023'_. |
| 12 | + |
| 13 | +- The BBC published a report on [public libraries in crisis](https://www.bbc.co.uk/news/articles/cn9lexplel5o), highlighting the number of closures and saying that closures were far more likely to happen in deprived areas. |
| 14 | +- The Office for National Statistics published [number of libraries in local areas, England and Wales](https://www.ons.gov.uk/peoplepopulationandcommunity/wellbeing/datasets/numberoflibrariesinlocalareasenglandandwales) - this used the data alongside other sources to look access to library services in different areas. |
| 15 | +- The data is also used in updating the library listings found on [LibraryOn](https://libraryon.com/), the British Library's single digital presence project. |
| 16 | + |
| 17 | +> More than 180 council-run libraries have either closed or been handed over to volunteer groups in the UK since 2016, BBC analysis has found. |
| 18 | +> |
| 19 | +> More deprived communities were four times more likely to have lost a publicly-funded library in that time, while 2,000 jobs have also been lost. |
| 20 | +> |
| 21 | +> **Public libraries in 'crisis' as councils cut services - BBC News** |
| 22 | +
|
| 23 | +It really is the most basic of data - the locations of our libraries - but getting it right has been a challenge for over a decade. How do we collect this data and keep it up to date? An annual survey (like the Arts Council dataset) is useful but time consuming, always out of date, and doesn't serve real-time tools like [LibraryOn](https://www.libraryon.org). Constantly updating the data is more efficient and less effort, but more of a challenge to coordinate and maintain. |
| 24 | + |
| 25 | +However, it's a credit to the quality of the data, and the Arts Council, that it is being used. Proving the need for quality open data has always been difficult, without examples. The fact that a dataset is published and seeing clear usage in important reports is a good message for the sector. |
| 26 | + |
| 27 | +## Cleaning and enhancing the data |
| 28 | + |
| 29 | +There were some issues with the data. That's not to throw any shade on the Arts Council - their job is to coordinate over 150 library services, and they still also need to do a lot of work to get the data tidied up before publishing. |
| 30 | + |
| 31 | +A good example of data that often needs cleaning is postcodes. These are often manually typed, so there were around 100 changes to these, and likely more required. |
| 32 | + |
| 33 | +I've done that, plus the following cleaning on the data to make it more useful for processing and linking to other datasets. Some of this is opinionated, but in trying to keep the spirit of the original data. |
| 34 | + |
| 35 | +- Trimmed extra whitespace at either end of all data entries |
| 36 | +- Corrected mismatches between the 'Reporting Service' and 'Upper Tier Local Authority'. On a few occasions these are legitimately different, but generally not. |
| 37 | +- Suffolk reported that the Prison Library HMP Bure was in Norwich upper tier local authority. The upper tier authority should be Norfolk, but it's correct that Suffolk libraries operate the prison library, and are the reporting service. |
| 38 | +- Standardised 10 of the names used in the 'Reporting service' column to easier match them to unique identifiers |
| 39 | +- Standardised 10 of the names used in the 'Upper tier local authority' column to easier match these to unique identifiers. |
| 40 | +- Cleared non-postcode text from the postcode column e.g. 'No registered public address' |
| 41 | +- Ensured the closed field has an entry for libraries that have otherwise been set to closed |
| 42 | +- Updated postcode entries to be uppercase |
| 43 | +- Updated invalid postcodes from closed libraries |
| 44 | +- Updated invalid postcodes from open libraries |
| 45 | +- Updated valid but incorrect postcodes |
| 46 | +- Removed the leading zeros from unique property reference numbers. |
| 47 | +- Removed UPRNs that are not numbers |
| 48 | +- Removed UPRNs that are over 5 miles away from the postcode location (and likely wrong) |
| 49 | +- Standardised the Type column to go from 10 to 5 distinct variations |
| 50 | +- Removed entries that were too unclear e.g. old book drops where the current status is unknown |
| 51 | +- Ensured statutory fields are Yes or No |
| 52 | +- Ensured closed year is set for entries that have closed in the operation field |
| 53 | +- Ensured operation fields are one of 'LA', 'LAU', 'C', 'CR', 'ICL' or not set |
| 54 | +- Ensured that if the closed year was completed it was a 4-digit year |
| 55 | +- Cleared some entries from the operating organisation column (e.g. 'N/A') |
| 56 | +- Standardised the 'No' entry for the new build question |
| 57 | +- Standardised the 'No' entry for the co-located question |
| 58 | +- Ensured that the indicator under each co-located column is only ever set to 'X' |
| 59 | +- Standardised the opening times fields to only the 19 possible entries as documented in the ACE guidance |
| 60 | +- Ensured the hours and staffed hours fields are numeric only |
| 61 | +- Standardised the 'No' entry for the automated system question |
| 62 | + |
| 63 | +### Adding coordinates |
| 64 | + |
| 65 | +There are no coordinates in the data. This is a good thing for data collection - there's no need to collect what can be added later. |
| 66 | + |
| 67 | +There are two open data sources that can help here: |
| 68 | + |
| 69 | +- [ONS Postcode Directory](https://geoportal.statistics.gov.uk/datasets/265778cd85754b7e97f404a1c63aea04/about) - Coordinates and other various lookups for around 2.7 million postcodes (both current and historic) |
| 70 | +- [OS Open UPRN](https://www.ordnancesurvey.co.uk/products/os-open-uprn) - Coordinates for approximately 40 million addressable locations (unique property reference numbers) in Great Britain |
| 71 | + |
| 72 | +Using these, I have added 4 columns. First trying to take the coordinates from the UPRN, which will give the exact location in the centre of the library building. However, as many UPRNs arent in the data, the next step is to use the postcode. This will be less accurate, being only the centre of the postcode. However, in the cases of libraries, they will be fairly small postcodes, or even having their own dedicated postcode. |
| 73 | + |
| 74 | +| Column name | Description | |
| 75 | +| ----------- | --------------------------------------- | |
| 76 | +| Easting | The easting coordinate of the library | |
| 77 | +| Northing | The northing coordinate of the library | |
| 78 | +| Longitude | The longitude coordinate of the library | |
| 79 | +| Latitude | The latitude coordinate of the library | |
| 80 | + |
| 81 | +This additional data does change attribution requirements. The licence can remain the [Open Government Licence](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/), but requires a few additional statements: |
| 82 | + |
| 83 | +- Contains OS data © Crown copyright and database right 2024 |
| 84 | +- Contains Royal Mail data © Royal Mail copyright and database right 2024 |
| 85 | +- Source: Office for National Statistics licensed under the Open Government Licence v.3.0 |
| 86 | + |
| 87 | +### Additional location data |
| 88 | + |
| 89 | +Having a properly defined location for things gives us so much additional information: the population of the area, how rural/urban it is, deprivation levels, etc. There is too much to include in one dataset but a few key ones would be useful. I've added the following: |
| 90 | + |
| 91 | +| Column | Description | |
| 92 | +| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | |
| 93 | +| Reporting authority code | A unique identifier for the reporting library service (an upper tier local authority). This uses the Government Statistical Service (GSS) code | |
| 94 | +| Rural/urban classification code | A set of codes, from 2011, to classify areas by how urban/rural they are. | |
| 95 | +| Rural/urban classification description | A description for the rural/urban classification e.g. Urban Major Conurbation | |
| 96 | + |
| 97 | +These are directly taken from the [ONS Postcode Directory](https://geoportal.statistics.gov.uk/datasets/265778cd85754b7e97f404a1c63aea04/about) by simple postcode lookup. Because they are postcodes and inexact locations, they are 'best-fit' lookups. Using the UPRN coordinates would be more accurate but I couldn't really be bothered. Plus we don't have half the UPRNs anyway. |
| 98 | + |
| 99 | +Enjoy! |
| 100 | + |
| 101 | +Download [the basic libraries dataset - enhanced](/data/2024-11-04-basic-libraries-cleaning.csv) (CSV, 1.5MB) |
0 commit comments