0

I'm doing some webscraping where I get a list of locations. I want to try and convert these to their respective longitude and latitude coordinates. I found geopy which looks like it does the right stuff.

With or without geopy, how can I convert this list to their respective coordinates (lon: (from -180,180) and lat: (from -90,90)) from within Python 3.5?

Preferably precise coordinates but if not possible, general area coordinates would work as well.

I found this resource that I was trying to mimic https://pypi.python.org/pypi/geopy

#Convert to Longitude/Latitude
from geopy.geocoders import Nominatim

geolocator = Nominatim()

locations = ['Kahekili Beach/Old Airport Beach, Leeward Shore Maui', 'Outside Honokohau Harbor South / Naia / Ripoff Reef, North Kona Coast', 'Ulua Beach, Leeward Shore Maui', 'Kaiwi Pt./Arch Cave/Wash Rock/Sand Channel/Kamanu/Devils Doorway, North Kona Coast', 'Honolua Bay MLCD, Leeward Shore Maui', 'Golden Arches', 'Lone Tree Arch / Freeze Face Cave, North Kona Coast', 'Old Airport', 'Turtle Heaven, North Kona Coast', 'Turtle Pinnacle/Turtle Towers/North of Honokohau Harbor Entrance/Terrapin Station/Turtle Pai, North Kona Coast']    
for location in locations:
    location = geolocator.geocode(location)


Error
 +Service timed out
O.rka
  • 29,847
  • 68
  • 194
  • 309
  • 1
    Had more luck with this but does not work for all the addresses http://pastebin.com/QwKdgXhk – Padraic Cunningham Apr 20 '16 at 01:30
  • Thanks for the heads up tho! – O.rka Apr 20 '16 at 01:32
  • 1
    FWIW, `Turtle Heaven, North Kona Coast` also fails in https://developers.google.com/maps/documentation/geocoding/intro#Geocoding – Padraic Cunningham Apr 20 '16 at 01:33
  • 1
    I second what @PadraicCunningham the main problem with using geopy is that these locations aren't really compatible with it. I know a bit about Hawaii and SCUBA Diving these appear to all be sites in the ocean (or at least off coast in some fashion. That's going to be a bit tough for standard location tools. You might be better off trying to match names after scraping something like this: http://www.shorediving.com/content/gps_table.htm – snorp Apr 20 '16 at 01:44
  • 1
    Also, Turtle Heaven found in a moorings database. http://www.malama-kai.org/blog/moorings/?f=Turtle+Heaven Perhaps it'd be useful to know what your end goal is. Do you want precision or just some coordinates that are in the area? Searching for just the beach name and Hawaii against the Google Maps API seems to give decent results – snorp Apr 20 '16 at 01:48
  • yea I definitely have put the end goal. preferably specific location but general area is fine with me. there is the general area name in each string . I'm not sure how to search for it with geopy – O.rka Apr 20 '16 at 02:52
  • @O.rka, do you know the country when you parse? – Padraic Cunningham Apr 21 '16 at 12:28
  • No I don't. The dataset that I was scraping from had only values liek the ones above – O.rka Apr 21 '16 at 22:45

0 Answers0