Go Back   WarriorForum - Internet Marketing Forums > The Warrior Forum > Main Internet Marketing Discussion Forum
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 02-18-2010, 06:16 PM   #1
Advanced Warrior
War Room Member
 
Join Date: Aug 2009
Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
Default Need script to find cities or zip codes around a zip code

This seems like it would be such a common function that it must have been done a few times.

Given a zip code, I need to find cities within 5/10/15/20/30/50 mile radius.

Prefer a php script or SOA service.

There are tons of scripts that will map a zip code to the city(s) it's in, but I need SURROUNDING cities (or zip codes) as well.

Only Continental USA is needed right now.

TIA!
-David

Here's the "Missing Manual" for Rapid Action Profits (RAP)

Advanced Marketing Strategies Using Rapid Action Profits

RAP Newbies -- half is "getting started" info you won't find anywhere else!
SageSound is offline   Reply With Quote
Old 02-18-2010, 08:19 PM   #2
Senior Warrior Member
War Room Member
 
Join Date: Jan 2003
Location: , , USA.
Posts: 11,102
Thanks: 1,449
Thanked 742 Times in 645 Posts
Default Re: Need script to find cities or zip codes around a zip code

Actually, zipcode areas can be large. You will need to have a zipcode database with some absolute value that can relate to distance. I happen to have done this before, and used latitude and longitude. If you use lon/lat, you can use the "great circle algorithm" to determine distance. of course, you have to use lon and lat to estimate maximum distance to limit the choices checked.

BTW this can work internationally by simply adding entries, though MY database only covers the US. I think PHP and PERL BOTH have implementations of the great circle algorithm in a standard library.

Steve
seasoned is online now   Reply With Quote
Old 02-18-2010, 08:26 PM   #3
Senior Warrior Member
War Room Member
 
Gary King's Avatar
 
Join Date: May 2009
Posts: 1,297
Thanks: 262
Thanked 467 Times in 220 Posts
Default Re: Need script to find cities or zip codes around a zip code

David,

Search for zip code radius or zip code locator.

There are open source ones and lots of guides to build your own.

I have one in classic ASP if that would fit, but I know you said you prefer php.

You'll also need a zip code database - there are lots of them out there. I have used a few, but settled on Zip Code Databases as the primary one, mainly because the updates are timely and the data is scrubbed. It's not the cheapest, but the one I've used (not an aff link BTW).

All the best - if asp will work for you, pm me.

Gary
Gary King is offline   Reply With Quote
Old 02-18-2010, 09:16 PM   #4
Advanced Warrior
War Room Member
 
Join Date: Aug 2009
Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
Default Re: Need script to find cities or zip codes around a zip code

Steve, I've written GIS apps before, and I know the math involved.

I mainly want to find names of cities surrounding a specific location in roughly concentric rings as you get further out, up to 50 miles or so. Also, it doesn't need to be super-exact. For instance, I'm in Reno. Carson City is 25 mi south of here, and it's considered a LONG WAY. In Phoenix, Mesa is anywhere from 5 mi to 30 mi from Phoenix based on where you are, and nobody thinks its very far. In LA, Manhattan Beach is just a "quick" 90 min cruise up the freeway from Newport Beach; San Diego is about the same.

The point is, People in Reno don't consider Carson City to be "nearby", even though someone in Newport Beach might consider Long Beach or Manhattan Beach as both "nearby" although they're 2-3x farther away.

The trouble with zip code areas is that they don't map neatly to city boundaries, so there would be a lot of mapping back and forth. You'd have to translate all of the boundaries to lat/lon coords then superimpose them on each other and look for intersecting areas based on circular radii.

Gary, I could translate from ASP if needed.

But, as I said, I can't imagine that this isn't something that virtually every bulk mail vendor, trucking company, shipper, and courier in the country might use for generating estimates. So I'd prefer to find a site or service that already has it implemented rather than have to roll-my-own.

Thx
-David

Here's the "Missing Manual" for Rapid Action Profits (RAP)

Advanced Marketing Strategies Using Rapid Action Profits

RAP Newbies -- half is "getting started" info you won't find anywhere else!
SageSound is offline   Reply With Quote
Old 02-18-2010, 09:33 PM   #5
Senior Warrior Member
War Room Member
 
Join Date: Jan 2003
Location: , , USA.
Posts: 11,102
Thanks: 1,449
Thanked 742 Times in 645 Posts
Default Re: Need script to find cities or zip codes around a zip code

Quote:
Originally Posted by SageSound View Post
Steve, I've written GIS apps before, and I know the math involved.

I mainly want to find names of cities surrounding a specific location in roughly concentric rings as you get further out, up to 50 miles or so. Also, it doesn't need to be super-exact. For instance, I'm in Reno. Carson City is 25 mi south of here, and it's considered a LONG WAY. In Phoenix, Mesa is anywhere from 5 mi to 30 mi from Phoenix based on where you are, and nobody thinks its very far. In LA, Manhattan Beach is just a "quick" 90 min cruise up the freeway from Newport Beach; San Diego is about the same.

The point is, People in Reno don't consider Carson City to be "nearby", even though someone in Newport Beach might consider Long Beach or Manhattan Beach as both "nearby" although they're 2-3x farther away.

The trouble with zip code areas is that they don't map neatly to city boundaries, so there would be a lot of mapping back and forth. You'd have to translate all of the boundaries to lat/lon coords then superimpose them on each other and look for intersecting areas based on circular radii.

Gary, I could translate from ASP if needed.

But, as I said, I can't imagine that this isn't something that virtually every bulk mail vendor, trucking company, shipper, and courier in the country might use for generating estimates. So I'd prefer to find a site or service that already has it implemented rather than have to roll-my-own.

Thx
-David
f you want to reliably get to 5mi, etc.... it is FAR more complicated. You are talking about an address database, etc... But mail vendors wouldn't need that or want it. Trucking companies, and shippers wouldn't either. They work by zones generally. I haven't worked with couriers, but THEY probably do things by zones, or actual time. Even TAXIs only do things one of TWO ways, zone, or actual metered distance. And the metered distance may not be the same even on the same route. They often take distance, time, tolls, fees, and surcharges into effect. If they wait for you at the airport, there may be a charge for waiting, parking, airport fees, toll charges, etc.... before you even go the first mile.

And when you say 5mi, do you mean straight distance(like I was talking about originally), normal driving distance, or current driving distance.

Steve
seasoned is online now   Reply With Quote
Old 02-18-2010, 10:13 PM   #6
Advanced Warrior
War Room Member
 
Join Date: Aug 2009
Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
Default Re: Need script to find cities or zip codes around a zip code

Quote:
And when you say 5mi, do you mean straight distance(like I was talking about originally), normal driving distance, or current driving distance.
The METRIC I'm trying to find is "nearby cities" based roughly on WHERE YOU ARE -- not a zip code or city name, but your actual location and what's "nearby". (The dang zip code areas in Phoenix are something like 2 mi wide by 12-15 mi long. They don't cross city boundaries but they do wrap around neighboring cities in some cases.)

People on the East Coast find this particularly amusing and/or confusing, because you can literally drive through three states and dozens of cities in the distance it takes to get from far south Phoenix to far north Phoenix on I-17.

So I figure the easiest way to reckon it is concentric circles based on radius, and what city boundaries fall within each of those radii.

It's not "driving time" or anything like that. Just, what towns and cities are "nearby" based on your current location?

The distance from Philadelphia to New York is about the same as Phoenix to Tucson. Only you'll find nearly three dozen towns and cities in two states between Philly and NY, but only a few cities in two counties between Phx and Tucson.

You can look on a map and eyeball it in a few seconds; but I want something that works online. (It can even use a geoip to get lat/long and search out from there.)

-David

Here's the "Missing Manual" for Rapid Action Profits (RAP)

Advanced Marketing Strategies Using Rapid Action Profits

RAP Newbies -- half is "getting started" info you won't find anywhere else!
SageSound is offline   Reply With Quote
Old 02-18-2010, 10:41 PM   #7
Senior Warrior Member
 
Join Date: Jan 2009
Location: Oregon
Posts: 1,196
Thanks: 3
Thanked 69 Times in 61 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Default Re: Need script to find cities or zip codes around a zip code

Here is a script in action that does what you want: Select Zip Codes by Radius or Modified Polygon
You may have to contact the author of the website to get the backend script about how it works though.

Traffic-Bug is offline   Reply With Quote
Old 02-18-2010, 10:47 PM   #8
Advanced Warrior
War Room Member
 
Join Date: Aug 2009
Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
Default Re: Need script to find cities or zip codes around a zip code

Quote:
Originally Posted by Traffic-Bug View Post
Here is a script in action that does what you want: Select Zip Codes by Radius or Modified Polygon
You may have to contact the author of the website to get the backend script about how it works though.
Wow, now THAT is COOL! (I don't need the visual, tho.)

-David

Here's the "Missing Manual" for Rapid Action Profits (RAP)

Advanced Marketing Strategies Using Rapid Action Profits

RAP Newbies -- half is "getting started" info you won't find anywhere else!
SageSound is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > The Warrior Forum > Main Internet Marketing Discussion Forum

Tags
cities, code, codes, find, script, zip

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 10:23 PM.