What is geocoding? Forward, reverse and autocomplete explained
Theo Mathieu ·
Geocoding turns an address or a place name into coordinates: “10 Downing Street, London” becomes latitude 51.5035, longitude -0.1275. Reverse geocoding does the opposite and turns coordinates into the nearest address. Address autocomplete is a third, related job: it suggests complete addresses while someone is still typing one.
Most software that handles addresses needs at least one of the three. A CRM puts customers on a map, a delivery app checks which depot is closest, a fleet log shows “Avenue Anatole France, Paris” instead of a pair of numbers, and a signup form helps people enter an address that the rest of the system can use.
This post explains each one with a real example, how a geocoder gets from text to a point, why two services can return different answers for the same input, and what to check when you choose one. The examples come from OpenGeocoding, the service I run, because those are the answers I can show and explain. The ideas apply to every geocoder.
Forward geocoding: from an address to a point
Forward geocoding, often just called geocoding, takes text and returns a location. Here is what OpenGeocoding returns for “10 Downing Street, London”, trimmed to the useful fields:
{
"displayName": "10, Downing Street, London, Westminster, England, United Kingdom",
"geoCoordinates": { "lat": 51.503506, "lon": -0.12754977 },
"addressDetails": {
"houseNumber": "10",
"road": "Downing Street",
"postcode": "SW1A 2AA",
"city": "London",
"countryCode": "gb"
},
"goodMatch": true
} Two things in that answer matter as much as the coordinates. The first is the structured address. The input had no postcode, and the answer adds one, so a geocoder is also a way to clean up and complete address data. The second is a signal of how sure the geocoder is. Send just “Downing Street” with no town or country, and the answer is the town of Downing in Missouri, without the goodMatch flag. There are many Downing Streets, and a bare street name doesn’t say which one you meant, so the geocoder makes a guess and says so. Your code should treat those two answers differently.
Reverse geocoding: from a point to an address
Reverse geocoding starts from a latitude and longitude, usually from a GPS device or a phone, and returns what is nearby. For the coordinates of the Eiffel Tower (48.85837, 2.294481), OpenGeocoding returns “3, Avenue Anatole France, 75007 Paris”, about 50 metres from the point, together with that distance.
That example shows a common surprise: a reverse geocoder answers with the nearest address, not necessarily the name of the place you are standing in. OpenGeocoding returns a house when there is one within range, then falls back to the street, and then to the nearest town, and it tells you which of the three it found. Naming the businesses or venues around a point is a different service, usually called place or POI search.
Reverse geocoding is what turns a trip log, a set of photos or a list of job sites into something a person can read.
Autocomplete: helping people type an address
Autocomplete returns a short list of suggestions for a partial address, updated as the person types. Type “10 Downing” with the country set to the United Kingdom, and the first suggestions are a Downing Road in Dagenham and Downing Streets in Farnham, Dudley and Cambridge. Type “10 Downing Street, Lon” and the only suggestion left is the one in London.
When the person picks a suggestion, the application asks for its full details and coordinates. Autocomplete therefore isn’t a faster forward geocoder. It is a way to let a person resolve the ambiguity themselves, so the address that reaches your database is one the geocoder already knows.
How a geocoder works
Under the hood, most geocoders do the same three things.
- Parse the input. The text is split into parts: house number, street, postcode, town, region, country. OpenGeocoding uses libpostal for this, a parser trained on addresses from around the world, and then repairs a few mistakes that would otherwise cost the whole lookup, such as a postcode with a country prefix (“SE-262 73”) or a postcode glued to the town name.
- Find candidates. The parts are looked up in an index of addresses, streets and places built from map and address data. This step has to forgive the way people write: one misspelt word (“West 54th Srteet”), abbreviations (“S 5th Street” for “South 5th Street”), and names in another language (“Sevilla” for Seville).
- Rank and decide. The candidates are compared with what the input said: does the postcode belong to this street, is the town the one stated, is this the right country? The best one wins. When nothing matches at house level, a good geocoder falls back to the street or the town and says that it did, as in the Downing Street example above.
Reverse geocoding skips the parsing: it searches the same index by distance from the point.
Why two geocoders give different answers
Send the same address to two providers and you will often get two different points. There are a few reasons, and they are useful to know when you compare services.
- Data sources. Some providers license commercial map data, and others build on open data such as OpenStreetMap, Overture Maps, OpenAddresses and national address registries. A provider can only find an address that is in its data.
- Precision. An answer can be a building, a point estimated along the street from its house-number range (interpolation), the middle of the street, or the centre of the town. Those can be hundreds of metres apart in a village and kilometres apart in the countryside, and services don’t always say which kind they returned.
- Coverage by country. Address data is dense in some countries and thin in others. OpenGeocoding is strongest in North America, most of Europe, Australia and New Zealand, and a few others such as Japan and Taiwan. House-level coverage across most of Asia and Africa is still poor, and the coverage measurement and the post about building the engine give the figures by country.
- Freshness. New streets and new buildings appear only after the provider rebuilds its data.
- Ranking choices. For an ambiguous input like “Downing Street”, each provider has its own rules for which candidate wins.
This is why a single accuracy number says little on its own. The useful question is how a service does on addresses like yours, in your countries. I wrote about how I measure that in What “accurate” means for a geocoder.
What you may do with the results
The terms of use matter as much as the price, and they differ a lot between providers. Under Google’s Maps service terms, geocoded coordinates may be cached for up to 30 days, so a database of geocoded customers has to be refreshed through the API. Results built on open data can usually be kept: OpenStreetMap’s ODbL licence asks for attribution, and for share-alike if you publish a database derived from it. OpenGeocoding’s results can be stored permanently, with those source licences still applying (attributions).
If you plan to geocode records once and keep the coordinates, read the storage terms before you compare prices.
How to choose a geocoding service
A short checklist that has served me well:
- Test with your own data. Take a hundred real addresses or GPS points from your system, including the messy ones, and look at the answers. Most services have a free tier for this; OpenGeocoding’s free plan has 50,000 requests a month and needs no credit card.
- Check coverage in your countries, at the precision you need: house, street or town.
- Read the storage terms, as above.
- Price your real volume. Per-request prices, monthly plans and daily limits look similar until you put your numbers in.
- Check the rate limits. The free public Nominatim server, for example, allows at most 1 request per second under its usage policy, which is fine for occasional lookups and not for a production import.
The comparison pages set OpenGeocoding next to Google Maps, Nominatim, OpenCage, Geoapify and Geocodio, with dated prices and terms, and pricing has the plans. To try forward and reverse geocoding on your own addresses, use the demo on the homepage or get a free API key.