Geocoding

If you need to convert an address (for example: “243 S Wabash Ave, Chicago, IL, USA”) into geographical coordinates (latitude and longitude), web2py provides a function to do so.

  1. from gluon.tools import geocode
  2. address = '243 S Wabash Ave, Chicago, IL, USA'
  3. (latitude, longitude) = geocode(address)

The function geocode requires a network connection and it connects to the Google geocoding service for the geocoding. The function returns (0,0) in case of failure. Notice that the Google geocoding service caps the number of requests, so you should check their service agreement. The geocode function is built on top of the fetch function and thus it works on GAE.