geopy for incomplete address, need approximate coordinates

38 Views Asked by At

I have a list of publishing houses names, and I need to get their coordinates through Python.

For example:

names = ["Raintree", "Texas A&M University Press"] # publishing houses

I did:

from geopy.geocoders import Nominatim

geolocator = Nominatim(user_agent="openstreetmap") # "Geopy Library")

def get_lat_lon(x):
    try:
        location = geolocator.geocode(x)
        complete_add = location.address
        return (location.longitude, location.latitude)
    except: return (0, 0)

print(get_lat_lon(names[0]+ " Publishing house"))

But I can't get the coordinates, what is the way to do it in Python? It is true, that we can have multiples addresses for the same name, but it's not a problem, as long as I add "Publishing house" so it doesn't get confused with something else.

0

There are 0 best solutions below