[Last Call] Learn how to a build a cloud-first strategyRegister Now


Pear GeoNames help

Posted on 2011-05-11
Medium Priority
Last Modified: 2012-05-11
I am trying to use the Pear Services GeoNames module, and need someone familiar with it to give me guidance on how to set up some inquiries.

I need:
All states and provinces in North America.
All cities in a particular State or Province.

All cities within X miles of a postal or zip code.

The documentation is very sparce, so if your are familiar with the GeoNames Pear module, I'll really appreciate your help.

Question by:birwin
1 Comment
LVL 111

Accepted Solution

Ray Paseur earned 2000 total points
ID: 35736815
Not sure if the PEAR part of this is a value-added feature or not.  I agree that the PEAR documentation is pretty sparse, but fortunately there is better documentation on the geonames project sites.  You need your own API key, then you can call the web services directly.

This is kind of a starting point to locate things about the GeoNames project:

Some of the data:

The forum:

North America is abbreviated NA and has geonameId=6255149

All cities within X miles of a ZIP code presents an interesting question and one you may want to think carefully about.  ZIP or Postal Codes are not geographic locations; they are postal carriers' routes.  As such, a ZIP code might be only a building or two in Manhattan but might be hundreds of square miles in the large states out west.  In most American cities there are several ZIP codes and even though these are given geocodes (Latitude/Longitude pairs) in a variety of data bases, my experience has been that these data bases may not apply the rules about geocoding consistently.  Example: Should the geocode of a ZIP code be the approximate geological center of the polyline that outlines the carriers' routes?  Or should it be the rooftop of the post office that carries that ZIP code?  ZIP+4 codes have more accurate geocodes in some data bases, but the size of the data base is greatly increased.  Many of the free ZIP code location tables have huge amounts of inaccuracy (in one study I found 20% of the reported ZIP geolocations varied by multiple miles between data sets).  Hopefully the GeoNames project will help the community clean that information up.

That said, you can ask clients for their ZIP codes and if you know the geocodes of your stores, you can show them the stores that are closest to them.  This works right most of the time especially if you list the 5 closest stores.

Most distance calculations for short distances (guessing here: anything less than 150 miles) can be done with plane geometry.  Longer distance calculations use the Haversine formula.  Driving distances can be confounding because typical point-to-point distance algorithms do not take into account things like rivers and bridges.  So you generally will find that the distance you compute is the minimum distance and the actual driving distance is longer.  In my experience the driving distance worked out to about 1.25x the point-to-point distance once the distance got to be more than about 10 miles.  Driving distance more closely correlates to point-to-point distance as distances get longer.

This article may be helpful:

Best of luck with the project, ~Ray

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month18 days, 1 hour left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question