grat·i·cule, |ˈgratəˌkyoōl|, n. technical
Navigation. a network of parallels and meridians on a map or chart.

Graticule is a geocoding API for looking up address coordinates and performing distance calculations. It supports many popular APIs, including:

There is a companion Rails plugin that makes geocoding seem like magic.


require 'rubygems'
require 'graticule'
geocoder = Graticule.service(:google).new "api_key"
location = geocoder.locate "1600 Amphitheatre Parkway, Mountain View, CA"
location.coordinates    #=> [37.423021, -122.083739]        #=> "US"

See the API documentation for more details.

International Support

Graticule supports several services with international support. The international geocoders require slightly more structured data than the US ones:

g = Graticule.service(:local_search_maps).new
location = g.locate :street => '48 Leicester Square', :locality => 'London', :country => 'UK'
location.coordinates  #=> [51.510036, -0.130427]

Distance Calculation

Graticule includes 3 different distance formulas, Spherical (simplest but least accurate), Vincenty (most accurate and most complicated), and Haversine (somewhere inbetween).

location = geocoder.locate("Holland, MI")
location.distance_to(geocoder.locate("Chicago, IL"))
#=> 101.997458788177

Command Line

Graticule also includes a command line interface to the various geocoders:

$ geocode -s yahoo -a yahookey Washington, DC
Washington, DC US
latitude: 38.895222, longitude: -77.036758


Install the gem by executing:

gem install graticule

Or, download it from RubyForge.


Contributions are welcome and appreciated! Join the mailing list and grab the source from: