[SOLVED] how to get a list of zip codes within a 10 mile radius
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
... where i can get a list of zip codes within a 10 mile radius.
Within a 10 mile radius of what? Is your input a town/state or a zip code? Is your input a single location keyed by a user prompt or a file of locations?
Calculating distances between two points identified by latitude and longitude requires more trigonometry than I know how to code. Herewith is simpler approach which may suit your purposes. Perhaps you can extend it to use an actual radius.
My Linux coding is all self-taught and probably exhibits lapses in variable quoting and so forth. Corrections and improvements are welcomed.
so now in order to know the part in purple i would first have to query:
Code:
select latitude, longitude
from zipcodes
where zip = 02144
does anyone know of a way to consolidate the 2 queries ? i tried sub-query but i dont think that would work since sub-query cant supply more than one answer and i need 2 ?
Wonder if some GIS package would do that? You'd have to have a free gis data set that includes us and zip code bounties. I've seen that stuff but usually it's for sale. Bet someone offers it free if you keep looking. I'd guess USPS has it but doubt it's free. All the real estate places have access to it somewhere up the chain.
bos <-> la should be about 2590 miles but i think that its the formula is fubar... same results with ms-excel (i am pretty sure the trig functions arent part of libre-office because i get #value errors).
#!/bin/bash
# ./zipcodes.sh zipcode miles
# it appears that the max limit for miles is 30.
curl "www.zip-codes.com/zip-code-radius-finder.asp?zip1=${1}&zipMilesHigh=${2}&print=true" 2>/dev/null |
egrep "[0-9][0-9][0-9][0-9][0-9]</a>" |
sed 's/<\/a>.*$//' |
sed "s/.*asp'>//" |
sort
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.