Plus Codes
Have you ever wondered what that strange code is that sometimes appears when you search for a place on Google Maps?
This is the Plus code, which is the name Google has given to the Open Location Code (OLC) reference system created by Google Zurich in October 2014. Plus Codes are a new (and open-sourced) way of geolocation that will allow any person wherever they are living or any place no matter where it is, to have an address. According to Google, a “plus code is like a street address for people or places that don’t have one”. By giving addresses to everyone, everywhere, Google will allow them to receive deliveries, access emergency services, register to vote, etc which would be especially useful in places where there is no formal system to identify buildings, such as street names, house numbers, or post codes. With this project, Google is giving a solution to the most important geolocation challenge in the world which is that approximately half of the urban population on earth lives in unnamed streets (according to the World Bankm link)
How does it work?
Plus codes are based on the same idea as the coordinate system. The geographic coordinate system divides the earth using a grid with horizontal and vertical lines that allow you to define any point on the grid with its coordinates (x,y) or (latitude and longitude). Plus codes are based on the same idea of a grid, but now it is not a simple grid but a fractal grid, a grid in which each cell contains another grid and so on.
The following image shows the concept of the fractal grid. In the first picture, we can see the Earth map divided by a grid, as we move closer to the zero mile marker in Madrid the cells of the grid get smaller and more precise, and inside of each cell, we find another grid.
We can now understand easier a plus code like a set of 10 letters and numbers with a plus sign before the last two that identifies a cell in the grid. A plus code can be divided into two parts:
- Area Code: the first four characters that locate a place within a region of around 100 km x 100km (this is a cell of 20 by 20 degrees in polar coordinates, we can see it in the upper-right map of the first picture).
- Plus Code: the next six characters (in bold).
Those 10 characters give enough precision to identify a square that is 14x14 meters which is smaller than the center circle of a football pitch. But if you search for a certain location using Google Maps, you will be returned something slightly different consisting of 6 digits and the name of the city where it is located. This format is a more readable version of the Plus Code called Compound Code, the original 10-digit version is called Global Code.
Plus Codes in GeoDB
In GeoDb we have started to work with the Plus Codes technology since a large part of our new users come from India, a country famous for how challenging it can be to reach a given residential address. They are unique in format, and vary across regions, localities, and use cases. While some addresses are well-defined by street names and house numbers that are easy to find, others can be long-winded and hard to locate. In fact, Plus Codes was introduced for the first time in India in March 2018 as a new Google Maps feature to tackle this problem.
For this purpose, we use the Google Geocoding API that allows us to obtain the location of a certain place (in coordinates and plus code format) using the name of the place and we can also transform the coordinates into plus codes using the reverse geocoding function. In the following picture, you can see a simple case of the use of the Geocoding API to get the coordinates and plus code given the name of the place and the opposite transformation using Python 3.7.
# install the library
# pip install googlemaps# import the library
import googlemaps# initialize the client
gmaps = googlemaps.Client(key = 'google_geocoding_api_key')# geocode the place "kilometro cero madrid"
geocode_result = gmaps.geocode('kilometro cero madrid')# let's see the location (lat and long)
geocode_result[0]['geometry']['location']
>>> {'lat': 40.4166359, 'lng': -3.7038101}# let's see the location in plus code
geocode_result[0]['plus_code']
>>> {'compound_code': 'C78W+MF Madrid, Spain', 'global_code': '8CGRC78W+MF'}# reverse geocode (form lat,long to name of the place)
reverse_geocode_result = gmaps.reverse_geocode((40.4166359,-3.7038101))# location in zip code format
reverse_geocode_result[1]['formatted_address']
>>> 'Puerta del Sol, 7, 28013 Madrid, Spain'# plus code format
reverse_geocode_result[1]['plus_code']
>>> {'compound_code': 'C78W+MF Madrid, Spain', 'global_code': '8CGRC78W+MF'}
Conclusion
Plus codes are one of those simple and seemingly easy ideas that can solve a difficult and complex challenge: give directions to places without one. This is a problem that we can very much relate to. Locating users in India is one of our current challenges. Google has privileged cartography to tackle this issue and GeoDB recognizes its value and committed with the latest technology is implementing it in our processes.
And that’s all folks. Stay tuned, we’ll bring you a lot of exciting news soon ;)