geopy

Calculate point based on distance and direction

大憨熊 提交于 2019-11-27 20:23:11
问题 I would like to calculate a point based on direction and distance using GeoDjango or GeoPy. For example, If I have a point that is (-24680.1613, 6708860.65389) I would like to find out a point 1KM North, 1KM East, 1KM Sourh and 1KM west using Vincenty distance formula. I closest thing I can find is a "destination" function in distance.py (https://code.google.com/p/geopy/source/browse/trunk/geopy/distance.py?r=105). Although I cannot find this documented anywhere and I'm yet to figure out how

error (429) Too Many Requests while geocoding with geopy in Python

别等时光非礼了梦想. 提交于 2019-11-27 07:03:04
问题 I have a Pandas dataframe with ~20k rows, and I am trying to geocode by address column into lat/long coordinates. How do I use time.sleep() or maybe other function to stop OSM Nominatim from Too Many Requests 429 error that I am getting now? Here's the code I use for this: from geopy.geocoders import Nominatim from geopy.distance import vincenty geolocator = Nominatim() df['coord'] = df['address'].apply(geolocator.geocode).apply(lambda x: (x.latitude, x.longitude)) df.head() Thanks in advance

Geopy: catch timeout error

倖福魔咒の 提交于 2019-11-27 05:49:30
问题 I am using geopy to geocode some addresses and I want to catch the timeout errors and print them out so I can do some quality control on the input. I am putting the geocode request in a try/catch but it's not working. Any ideas on what I need to do? Here is my code: try: location = geolocator.geocode(my_address) except ValueError as error_message: print("Error: geocode failed on input %s with message %s"%(a, error_message)) I get the following exception: File "/usr/local/lib/python2.7/site