![]() | | ||||||||
| | #1 |
| Advanced Warrior War Room Member Join Date: Aug 2009 Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
|
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! | |
| | |
| | #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
|
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 |
| | |
| | #3 |
| Senior Warrior Member War Room Member Join Date: May 2009
Posts: 1,297
Thanks: 262
Thanked 467 Times in 220 Posts
|
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 |
| | |
| | #4 |
| Advanced Warrior War Room Member Join Date: Aug 2009 Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
|
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! | |
| | |
| | #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
| Quote:
And when you say 5mi, do you mean straight distance(like I was talking about originally), normal driving distance, or current driving distance. Steve | |
| | |
| | #6 | |
| Advanced Warrior War Room Member Join Date: Aug 2009 Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
| Quote:
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! | ||
| | |
| | #7 |
| Senior Warrior Member Join Date: Jan 2009 Location: Oregon
Posts: 1,196
Thanks: 3
Thanked 69 Times in 61 Posts
|
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. |
| | |
| | |
| | #8 | |
| Advanced Warrior War Room Member Join Date: Aug 2009 Location: Reno, NV
Posts: 620
Thanks: 56
Thanked 129 Times in 90 Posts
| Quote:
-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! | ||
| | |
![]() |
|
| Tags |
| cities, code, codes, find, script, zip |
| Thread Tools | |
| |
![]() |