Geocoding

Geocoding is the process of converting a street address to a latitude and longitude. This operation is critical to in-vehicle navigation systems and online driving direction websites. Python has two excellent geocoder libraries available named geocoder and geopy. Both take advantage of online geocoding services to allow you to geocode addresses programmatically. The geopy library even lets you reverse geocode to match a latitude and longitude to the nearest address.

First, let's go through a quick example with the geocoder library, which defaults to using Google Maps as its engine:

>>> import geocoder >>> g = geocoder.google("1403 Washington Ave, New Orleans, LA 70130") >>> print(g.geojson) {'type': 'Feature', 'geometry': {'type': 'Point', ...

Get Learning Geospatial Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.