Geocoding in Ruby

Sans confidence, competence, I program! Computer languages have always seemed prohibitively complex and very boring. Given my interest in working with data and ‘information’, taking the leap to explore Information Technology is a predictable and necessary next step…that I’ve avoided for years. Having I.T bigshots for both a boyfriend and a brother has done little to alleviate my dread of the terminal and its command lines.

To bulk up my GIS muscles, I tried and failed to teach myself Python from a book this past Fall. The failure was purely one of attention span…how to trudge through mundane code rules, vaguely applicable to matters of interest, when much friendlier reading material was calling to me from the library shelves? Then in January I started to learn Ruby at awesome (& free!) Learning-to-Code classes held every other Monday night at the Co-Work Buffalo office, which uses Chris Pines’ Learn to Program book/website as a guide. This learning attempt was much more successful, in that I actually accomplished stuff – geocoding being the biggest deal to me and my mapping.

Geocoding is one of the most important processes in spatial analysis: matching a place-descriptive data field (like an address, city name) to a precise location in terms of latitude/longitude. To create a geocoder in Ruby I first installed Ruby Gems, which is a “framework” for managing other packages/libraries of code. I then installed a geocoding package aptly named Geocoder, which operates within the Ruby Gems framework and uses Google’s Geocoding API by default to look up addresses and/or geographic coordinates.

I used these packages to write the program below, which reads in a list of addresses (the file Addresses.txt), and writes a new file (LatLong.txt) listing the latitude and longitude coordinates for each address.

geocode


My next programming goal is to venture into the endless possibilities of web-scraping, using the Ruby Mechanize package. Inspired by this hilarious map, I want to mine Craigslist for all the rich social data it has to offer.

Advertisements

About katosulliv

Transportation, mapping, and cities enthusiast.
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s