Pear GeoNames help

Posted on 2011-05-11
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 107

    Accepted Solution

    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 your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    The viewer will learn how to dynamically set the form action using jQuery.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now