Ordnance Survey Linked Data and the Reconciliation API
The new Ordnance Survey Linked Data has a reconciliation API that allows users to turn text into URIs by matching against the Ordnance Survey linked data using a tool called open refine.
I’m not an expert on open refine but had a quick try of the tool today using some open data about libraries (available here). Instructions on installing Open Refine can be found here.
To use the Open Refine load your data into the tool and create your new project. On loading the library data into Open Refine you should see something like this:
We can use Open Refine to turn the labels in both the ‘county’ column and postcode column into URIs. For the county column click the down arrow next the column name and select reconcile -> start reconciling. Now click ‘Add Standard Service’ and add the following URL http://data.ordnancesurvey.co.uk/datasets/boundary-line/apis/reconciliation.
As the ‘county’ column will contain a mixture of types select the ‘reconcile against no particular type’ option and click ‘start reconciling’. You should now see that most of the text labels have turned to hyperlinks (note OS linked data does not included Northern Ireland data…this accounts for the missing values).
You can do the same for the postcode column, but this time use the API at: http://data.ordnancesurvey.co.uk/datasets/code-point-open/apis/reconciliation
Your data should now look something like:
You have now successfully replaced the text in these columns with links to the OS linked data.
Another useful thing to try is a simple bit of geocoding based on postcodes. Again go to the postcode column and select “Edit Column -> Add Column by fetching URLs’. Where asked type in a column name (e.g. PC JSON) and in the Expression box type:
‘http://data.ordnancesurvey.co.uk/datasets/code-point-open/apis/search?output=json&query=’ + escape(value,’url’)
You should now see a column appear full of JSON results:
On the PC JSON column select “Edit Column -> Add Column Based on this column”. Again add a column name of your choice. I wanted to extract the value of the easting and northing and add it as a column so I called my new column ‘easting,northing’. In the expression box enter the following to get the value of the easting and northing:
with(value.parseJson(), pair, pair.results[0].easting + ‘,’ + pair.results[0].northing)
and you should now see something like:
Congratulations…you have now geo-coded your libary spreadsheet via a postcode and the OS linked data.
For more info on how to use Open Refine for reconciliation watch this youtube video.
Your URL in the geocoding example has been “improved” by WordPress – I think it should be:
‘http://beta.data.ordnancesurvey.co.uk/datasets/code-point-open/apis/search?output=json&query=’ + escape(value,’url’)
(assuming WordPress doesn’t fix my apostrophes too)
Excellent post! The reconciliation api support is really exciting – I hadn’t realized that OpenRefine could be used like that, and the OS backend for it is great.
Oh yes – you are right WordPress did ‘correct’ my apostrophe. Thanks for the feedback – glad you found this useful.