I am working on the Nominatim geolocator in Python. Unfortunately, some addresses are missing, therefore I tried to make some condition-based workaround, which would allow executing something based at least on postcode, which works well in any case. Unfortunately, I failed for now. With the following code:
import pandas as pd
import folium
import web-browser
from geopy.geocoders import Nominatim
geolocator = Nominatim(timeout=10, user_agent="Krukarius")
def find_location(row):
place = row['Address']
place_data = newstr = place[-8:]
location = geolocator.geocode(place)
location_overall = geolocator.geocode(place_data)
if location != None:
return location.latitude, location.longitude
else:
#return 0,0
return location_overall
points = pd.read_csv("Addresses4.csv")
points[['Lat','Lng']] = points.apply(find_location, axis="columns", result_type="expand")
print(points)
points.to_csv('NewAddresses4.csv')
ValueError: Location should consist of two numerical values, but '' of type <class 'str'> is not convertible to float.
from Conditional-based geolocator in Python
No comments:
Post a Comment