
Automatically Geocode U.S. Addresses #80
Chapter 7, Names and Places
|
403
HACK
HACK
#80
Automatically Geocode U.S. Addresses Hack #80
Use the geocoder.us web services to geocode batches of address
In “Geocode a U.S. Street Address” [Hack #79], you saw how easy it is to geo-
code an individual address. But what about a whole database of addresses?
What about geocoding addresses as people enter them into a web form? You
don’t need to webscrape http://geocoder.us/! There are three different web-
service interfaces. geocoder.us supports XML-RPC and a lightweight REST-
ful interface. There is also an embryonic SOAP interface (for more informa-
tion and a code sample, consult the geocoder.us web site).
A web service is a way for a program to communicate with another program
over the Web. In this case, it is as though you had a magical assistant enter-
ing addresses into the geocoder.us site and returning the resulting coordi-
nates in your program.
Except this assistant is itself a program, and it is optimized to get just the
information that you need and return that information to your program. An
example is “Caffeinated and Unstrung: A Guide to Seattle’s Free Wireless
Coffee Shops” (http://seattle.wifimug.org), created by Kellan Elliot-McCrea.
You can go to the site, select the “Search Nearby” option, enter your
address, and find a spot that provides both coffee and a wireless connec-
tion. At first glance, ...