# Geocode for Ruby

**URL:** <https://www.ruby-forum.com/t/geocode-for-ruby/50252>\
**Category:** Rails\
**Created:** [December 14, 2005, 4:09pm UTC](https://www.ruby-forum.com/t/geocode-for-ruby/50252 "2005-12-14T16:09:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [December 14, 2005, 4:09pm UTC](https://www.ruby-forum.com/t/geocode-for-ruby/50252/1 "2005-12-14T16:09:24Z")

</div>

Hey,

Does anybody know of a good Geocode library for Ruby, similar to Perl’s  
Geocode::Postal, that i could use in my rail app? I need to do some  
“within  
5 miles” calculations of zipcodes and i dont have a nice ruby (or gem)  
utility to do it.

any help would be appreciated.

thanks  
adam

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [December 14, 2005, 4:38pm UTC](https://www.ruby-forum.com/t/geocode-for-ruby/50252/2 "2005-12-14T16:38:48Z")

</div>

Adam D. wrote:

> Hey,
> 
> Does anybody know of a good Geocode library for Ruby, similar to Perl’s  
> Geocode::Postal, that i could use in my rail app? I need to do some  
> “within  
> 5 miles” calculations of zipcodes and i dont have a nice ruby (or gem)  
> utility to do it.
> 
> any help would be appreciated.
> 
> thanks  
> adam

Adam - I don’t have any “libraries” per-se, but my sites currently are  
built on rails and use geocoding to do some proximity querying. I have  
some documentation at [http://www.geocodeamerica.com/home/proximity](http://www.geocodeamerica.com/home/proximity) that  
might be helpful (its talks about integrating proximity queries in with  
google maps, but does have some ruby code at the end). Feel free to  
email me with any questions.

Dave

> **[Favorite Run](https://favoriterun.com/)**
>
> The Gift of Running 

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [December 14, 2005, 5:51pm UTC](https://www.ruby-forum.com/t/geocode-for-ruby/50252/3 "2005-12-14T17:51:45Z")

</div>

Adam:  
On Dec 14, 2005, at 7:38 AM, Dave wrote:

> Adam D. wrote:
> 
> > Does anybody know of a good Geocode library for Ruby, similar to  
> > Perl’s  
> > Geocode::Postal, that i could use in my rail app? I need to do some  
> > “within  
> > 5 miles” calculations of zipcodes and i dont have a nice ruby (or  
> > gem)  
> > utility to do it.

It doesn’t read like you’re doing strict geocoding here. To solve the  
“within 5 miles” of zipcode problem, you need are the coordinates  
extremities of said zipcode. Since latitude and longitude correspond  
to distance, you then need to obtain how many degrees correspond to  
your desired distance. You then merely need to check if the given  
address’s coordinates fall into this range.  
Cheers,  
Hasan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [December 14, 2005, 6:15pm UTC](https://www.ruby-forum.com/t/geocode-for-ruby/50252/4 "2005-12-14T18:15:49Z")

</div>

in my database i have zipcode, longitude, latitude, city name, state. I  
understand pretty much whats involved in calculating distance, but there  
are  
a lot of factors involved in that formula so i was hoping that a library  
already existed to do such things. i have read thru Geocode::Postal in  
the  
perl module and its pretty involved.

adam
