Say you did a survey and asked participants for their postcode, or you obtain secondary data in which locations are specified by postcode. Now you want to create a point on a map for each of your postcodes – in GIS jargon: you geocode your data.
You have various options for geocoding:
- UK academics and students can use the excellent MIMAS GeoConvert tool: You upload your file and it returns National Grid Reference Eastings and Northings for each of your postcodes. You can then easily visualize these in GIS software.
- If you are happy building your own web application you can use Unlock Places, a geocoding API provided by EDINA, It can be used with postcodes, but also with placenames. It also returns Eastings and Northings.
- You can do geocoding in ArcGIS Desktop – see instructions below. This is a bit more difficult to set up, but advantages are that (a) if you have a typo in a postcode ArcGIS can suggest corrections (while the other two will simply reject that postcode), and (b) it is more customizable – for example you can build your own postcode reference data if you want.
In this post I only cover the third option, geocoding in ArcGIS.
- Your dataset with postcodes (obviously)
- The ArcGIS Desktop software. We use ArcGIS Desktop 10.2.1.
- An ArcGIS reference database containing all UK postcodes with their geographical locations. I built such a database based on the 2014-02 postcode directory from the UK data service, which itself is based on the ONS postcode directory. In addition to the postcode data my database contains an Address Locator – in ArcGIS jargon this is a set of rules to match your postcodes to the reference data. If you are a University of Manchester staff or student contact me for a copy of the database.
First you need to bring your postcodes in a format that is readable by ArcGIS. This can be an MS Excel table, but ArcGIS is quite strict in what it expects in table formatting: your data needs to be organized as one observation per row and the table must follow certain formatting rules. For example, this table is not well formatted and ArcGIS will not be able to read it:The same table well formatted and readable in ArcGIS:
Once your table is well formatted, load it into ArcMap and open it to verify that it is read correctly:
If you see only blank cells here, your table does not follow ArcGIS formatting rules.
Now to the actual geocoding:
In ArcGIS display the Geocoding Toolbar (Custiomize > Toolbars > Geocoding):
Click on the Postbox symbol. You are asked to choose an address locator. This is the reference database to compare your location data to. ArcGIS comes with two built-in locators, but we want to a different one, the one from my UK postcode database. Click Add…, navigate into the geodatabase that you got from me, and add the locator ‘ONSPD_2014_02_UK_PT_Locator’.
ArcGIS takes a while to now process the locator – don’t despair. When it is done you see that it added the ONSPD locator to the list of available locators and made it the default locator (indicated by the asterisk *). Click OK to close the Address Locator Window.
Again ArcGIS thinks for a while, then it opens a Geocode Addresses window. Here you specify your own data:
- Address table – this is your own Excel table. If your Excel table is already loaded into ArcGIS you can select it from the dropdown, otherwise load it.
- Address Input Fields: For postcode data select Single Field, and for Key the field that contains your postcodes.
- Output: The geocoding process creates a point feature class with one point for each row in your data. Specify a location and name to save this output, as a shapefile or geodatabase feature class.
Now ArcGIS goes through your table, looks up each postcode’s coordinates in the reference table, and creates a point feature at that coordinate in the output. Do NOT click Cancel, even if the progress bar arrived at the right – ArcGIS is still working. Only if you see the Rematch and Close buttons it has really finished:
If you are happy with the geocoding result click Close the and you see your data on the map:
In the example above all my postcodes were ‘matched’, meaning a corresponding postcode was found in the reference database. If you get Tied or Unmatched postcodes these are usually due to typos in your postcode data. Double-check your data or see here how to rematch manually.
- You get an error “Geocoding an address table with a definition query or selection set is not supported“. This happens if there is no table loaded into ArcMap. Workaround: Load any table into ArcMap before geocoding.