r/learnpython•
veryxcit

Python way of solving my problem on Stackoverflow :). Lat and Long calculation based on Radius

http://stackoverflow.com/questions/35489369/radius-from-a-latitude-and-longitude-co-ordinate

That's my original question, someone answered it (most likely correctly) but what I need is the python way of solving it. I left a comment on the answer as well.

Basically I have a DB full of zipcodes and their lat, long co-ordinates. I want to calculate mathematically given a certain zipcode (and its original lat, long) a square area around that original point depending on a given radius. So the inputs are original_lat, original_long, radius and I want to calculate two points that define my square the upper left and bottom right -- say p1_lat, p1_long and p2_lat and p2_long. Once those values are calculated I can query the DB with comparison operators and therefore extract the zipcodes within that square area.

The big picture is that I need to calculate nearby zipcodes given an original zipcode. There are some live APIs out there, but I also need an offsite version in case the live is unavailable.

Also I'm doing this on Python 3 and as far as I know pyzipcode isn't updated yet :/

Thanks guys/gals.

Posted Feb 21, 2016, 8:35 PM UTC

33
Loading comments…