Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Plot zip codes on US Map

by Stegalex (Chaplain)
on Jul 01, 2002 at 18:56 UTC ( #178641=perlquestion: print w/ replies, xml ) Need Help??
Stegalex has asked for the wisdom of the Perl Monks concerning the following question:

I would like to plot the zip codes from my orders database against a U.S. State map as a means of graphically depicting where our customers are (for management).

How would you tackle this problem?

Please refrain from commenting on whether this is a dumb thing to do as the point is moot - it's a requirement from on-high. Thanks in advance!

~~~~~~~~~~~~~~~
I like chicken.

Comment on Plot zip codes on US Map
Re: Plot zip codes on US Map
by dws (Chancellor) on Jul 01, 2002 at 19:15 UTC
    I would like to plot the zip codes from my orders database against a U.S. State map as a means of graphically depicting where our customers are (for management).

    This problem breaks nicely into a couple of pieces:

    1. You'll need a mapping of zip codes to geographics coordinates.
    2. You'll need a graphic image of a map.
    3. You'll need a way to translate/scale geographic coordinates to map image coordinates.
    4. You'll need a way to composite images.

    You can find (1) by doing a bit of google searching. Finding (2) is a matter of looking around until you find a map image that you like. The only complication with (3) is dealing with Alaska and Hawaii if they appear as sidebars on the map, instead of in their "true" locations. (4) is easily handled by GD.

Re: Plot zip codes on US Map
by DamnDirtyApe (Curate) on Jul 01, 2002 at 19:15 UTC
Re: Plot zip codes on US Map
by maverick (Curate) on Jul 01, 2002 at 19:16 UTC
(jeffa) Re: Plot zip codes on US Map
by jeffa (Chancellor) on Jul 01, 2002 at 19:16 UTC
    WWW::MapBlast sounds like a good starting point. This module will give you the latitude and longitude of a given zip code. Next step would be to use a module like GD to apply the zip codes. I would try some kind of World to Viewport algorithm to do so. It has been a long time since i did any graphics programming, last time was in Java. You can find my explanation on World to Viewport here (which is paraphrased from the book Computer Graphics).

    Remember also that jcwren has already done this something very similar at the Big Monk Map.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: Plot zip codes on US Map
by cacharbe (Curate) on Jul 01, 2002 at 19:21 UTC
    Personally, I would get a list of Zip / Long-Lat pairs and use the coordinates as a starting source to plot them on a map, and then maybe talk with jcwren about how he created the Big Monk Map functionality on his website.

    And if you want to find the distances between them, check here to see the differences in some of the algorithms.

    C-.

    ---
    Flex the Geek

Re: Plot zip codes on US Map
by greenFox (Vicar) on Jul 02, 2002 at 02:53 UTC

    Its been a while and I don't have the code at hand but I have done something similar using a Perl Tk canvas object. By using Northings & Eastings instead of Lat/Long I was able to plot as x-y points. I had data available in Northing Easting format and if I recall correctly it was all within the one zone.

    Geography::CoCo man page (not on CPAN that I could see) will convert Lat/Lon to Northing/Easting (or grid) format.

    --
    my $chainsaw = 'Perl';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://178641]
Approved by dws
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-11-26 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (164 votes), past polls