Let's close out the week with a geo thread. This time #geoeducation rather than #geoweirdness
Today's topic is one that doesn't get as much respect as it should.
Ask most people about geocoding, they automatically think forward geocoding - turning text (an address or placename) into coordinates.
Today though we'll cover the opposite: reverse geocoding
1/n
2/ Reverse geocoding is turning coordinates (latitude, longitude) into location info.
So 52.3877830, 9.7334394 becomes "Philipsbornstraße 2, 30165 Hanover, Germany" as you can see on our demo page.
Those are the coordinates of OpenCage HQ, BTW
So far, so simple, right?
3/ The first question people usually ask is "why would I ever need that?"
Well, the main reason is tracking devices (GPS, etc) capture locations very precisely as coordinates.
But there is one big problem - coordinates make no sense to humans ...
4/ Humans think in terms of countries, cities, neighbourhoods, addresses, etc. NOT coordinates.
Here's a basic example: a rental car company might want to know if their car left the country.
Reverse geocoding converts vehicle coords into country.
We work with many vehicle
tracking companies
5/ Reverse geocoding may seems simple, but there are lots of things to consider.
First up, different parts of world are structured very differently, with different admin hierarchies and ways to show addresses.
We format the address as expected locally.
BTW - the templates we use to do it are open sourced: https://github.com/OpenCageData/address-formatting Pull requests gladly received!
6/ Of course most of the world has no hierarchy as all, it's water. We handle that as well.
See our thread on geocoding the oceans: https://en.osm.town/@opencage/110207789147450417
7/ One small reverse geocoding pet peeve - people often send our geocoding API ultra precise coordinates. Like nanometer level.
There is no real need for more than 6 places past the decimal, see:
8/ Next issue - privacy
Geocoding super precisely is technically cool, but can at times be a real privacy issue.
For example a website might want to show a user's neighbourhood, not their specific home address.
Here's our guide to geocoding "coarsely"
https://opencagedata.com/guides/how-to-preserve-privacy-by-showing-only-an-imprecise-location
9/ But by far the hardest part about reverse geocoding is that the world changes all day, every day.
There is continual new construction, demolition, address changes, changes of all kinds.
#OpenStreetMap alone has 5+ MILLION edits per day (keep up the good work everyone!)
10/ If you want to play around with the ideas from this thread, we have a tutorial on writing your own reverse geocoder
https://opencagedata.com/guides/how-to-preserve-privacy-by-showing-only-an-imprecise-location
or of course you can just try out our API
11/ You'll find the tutorial and much more in our reverse geocoding guide:
https://opencagedata.com/reverse-geocoding
Please share with anyone who might find it interesting.
Have a good weekend, and happy geocoding!
Final toot - if you enjoyed this thread (or if you hate #geoeducation and want an immediate fix of #geoweirdness) you can find the full list of our threads over on our blog:
https://blog.opencagedata.com/geothreads
enjoy!
@opencage what are your sources for the 'as expected locally'?
because for the example in Italy I honestly disagree this is the expected format...
@opencage as you can see from this example search on the Italian white pages (phone book) there's usually no comma between the street name and the house number, and the province code is usually written between (round) brackets:
https://www.paginebianche.it/persone?qs=bono&dv=Roma%20(RM)
so for ex:
Via Garibaldi 123, Torino (TO)
in some cases there's no house number so it's 'snc' "senza numero civico"
so for ex: Strada Cantonale snc, Rozzano (MI)
@sverx happy to hear case. Please submit an issue on the GitHub repo
@opencage Regarding reverse geocoding with OpenStreetMap, there are some other complications one should be aware of. Like polygons and interpolations. I'd recommend my own FOSDEM talk, "Reverse Geocoding Is Not Easy":
@zverik nothing is easy. Ever