Step 4 - geocode using Nominatim

Click here to download the complete files for all steps in this tutorial.

The Nominatim geocoder uses OpenStreetMap’s free Nominatim webserver. It can geocode addresses without a postcode based on their street name, town, etc. The downside is that geocoding based on non-postcode address elements can often generate ambiguous results – i.e. it is not clear if we should match the record to one address or another in the address database. Because of this, ODL’s Nominatim geocoder component is interactive – you review and ‘OK’ each match it makes, amending where needed. This is still relatively quick to do as most of the time you just need to click on one button per record to confirm the top-matching result is correct.

Ensure the Customers table is selected and choose the Geocode addresses using Nominatim option using the component wizard. Set-up the adapter as per the following screenshot:

We’re using United Kingdom addresses so you should select this in Filter by country; Nominatim results will be more reliable if you tell it the correct country. Where the screenshot says john.smith@hotmail.com, you must instead enter your own email address. OpenStreetMap’s webserver uses the email address to monitor for heavy usage but will not use it for any other purpose. You advised to review the Nominatim terms of service to ensure you comply fully.

Now press play on this script and the following dialog should appear:

The dialog shows the Nominatim search results for the first ungeocoded row and allows you to select a matching address. In some cases, no result will be available as Nominatim could not find a match. If you don’t have any matches or can’t find a suitable match from those available then you should try removing parts of the address which might confuse Nominatim, until you get a suitable result. For example the input address 8 Wilmot Road, Carshalton Central, London, SM5 3 only gives the correct result once you trim it down to 8 Wilmot Road, London. To remove part of the address, edit the text in the address box at the top of the dialog and then press the refresh button to re-query Nominatim (see screenshot).

You can use the buttons at the bottom of the dialog to set the latitude and longitude to one of the following options:

  • The top result returned from Nominatim.
  • An average of all results returned from Nominatim.
  • An average of the results you've selected in the Nominatim search results list.

After choosing one of these options the dialog will go to the next record. For most addresses you should be able to just select the top result, giving one mouse click per address.

You can also enter the move object mode by clicking the button on the map toolbar and then manually place the customer point by clicking on the correct position in the map window. In this case you would instead press the Next record button to go to the next record after placing the point manually.

Now use the Nominatim component to fix all of the four remaining ungeocoded addresses in the Customers table and then press exit on the dialog when you’ve finished.

After this, try geocoding using your own data. The scripts you’ve developed will work with any Excel spreadsheet containing a Customers worksheet with an Address column and the latitude and longitude columns. Alternatively you can rename the columns and tables used in the scripts to match your own data.

Go to next tutorial