Looking for a map tool
May 4, 2006 12:40 PM   Subscribe

A tool that takes a US zip code and tells me the ten largest towns/cities within a radius of x miles?

I'm working on a project where it'll be necessary to know the ten largest communities within a 50 mile radius of a given zip code. Many of these zip codes are very rural areas and so eyeballing it isn't an ideal solution. Thanks for the help.
posted by panoptican to Computers & Internet (9 answers total)
 
I don't have it installed anymore, but mappoint could do that, I'm sure.
You might try the Web Service and see if you can get it done for free.
posted by madajb at 1:05 PM on May 4, 2006


I did something similar a couple of years back. It's easy to get the long/lat of each ZIP code. It's not so easy to get the long/lat of each city and town in the US for free - although it should be! - but you can buy that data. A degree of latitude is 69 miles, and within the latitudes of the US, a degree of longitude is beween 45 and 60 miles, so if you don't have to be super-accurate, you can just divide by 50 and save yourself a lot of trigonometry. Now just throw all the data into a DBMS like Postgres that extends SQL with a Cartesian point type and proximity functions, and you're all set.
posted by nicwolff at 1:52 PM on May 4, 2006


Sounds like this is something you're looking for. http://www.melissadata.com/lookups/zipradius.asp
posted by hf11201 at 2:08 PM on May 4, 2006


Look for density of zipcodes for a population estimate.
posted by devilsbrigade at 3:54 PM on May 4, 2006


nicwolff: how up to date is that text file you linked? There are companies that sell that data for lots of money because it's updated relatively often.

panoptician: Can you write a tool if you have the right data?

Your best bet is going to be to acquire a text file that can be imported into a database. It needs to contain:
1) Zip code
2) City name
3) Latitude
4) Longitude
5) Population of CITY (not zip code!!!)
6) or population of zip code, which can be used to derive 5

[note: I'm assuming by largest you mean population.. if you mean square mileage, you'd want that instead]
Problem you'll have regarding #5 and 6 is that big cities contain many zip codes, but a zip code lat/long search searches for .. well .. zip codes!

Then you'll want to store this in a SQL table, and do something like this (just steal the crazy math):
SELECT distinct city
(3963.1 * 
	ACOS(
		(SIN(RADIANS([source latitude])) * SIN(RADIANS(latitude)))
		 + (
		 COS(RADIANS([source latitude])) * Cos(RADIANS(latitude)) * Cos(RADIANS([source longitude]) - RADIANS(longitude))))) AS distance, zip AS zip
FROM zipcodes
WHERE (3963.1 * 
	ACOS(
		(SIN(RADIANS([source latitude])) * SIN(RADIANS(latitude)))
		 + (
		 COS(RADIANS([source latitude])) * Cos(RADIANS(latitude)) * Cos(RADIANS([source latitude]) - RADIANS(longitude)))) < [radius])br>
ORDER BY distance
Replace radius, source latitude, source longitude with the appropriate amounts, etc.

That should be a start.. assuming you have some programming and sql knowledge...
posted by twiggy at 4:02 PM on May 4, 2006


The USPS's own Post Office Locator gives a list of PO's nearest the input Zip, with mileage and map links for each. (And, in spite of the instructions, entering just the Zip is sufficient.)
posted by rob511 at 4:42 PM on May 4, 2006


You might be interested in zipdecode.
posted by trip and a half at 10:32 PM on May 4, 2006


Second madajb - Microsofts MapPoint is the one that's easiest.

I'm just doing something similar and wish I'd known about it years ago...
posted by DrtyBlvd at 11:52 PM on May 4, 2006


I have an old DOS program called Zipkey that lets you look up ZIP codes to see where they are, or look up cities to see what the ZIP code is. I think it might work for you. If you can't find it, email me (in profile) and I'll send it to you (it's shareware).
posted by attercoppe at 8:03 AM on May 5, 2006


« Older Signifigant Events in the History of Magic   |   How to undo more Newer »
This thread is closed to new comments.