You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Leaving this as a quick solution to add OSM attributes to the urban extents output, using the Nominatim geocoder from geopy. I can add it as a notebook example or to the source code.
from geopy.geocoders import Nominatim
urban_extents.loc[:, "centroid"] = urban_extents.geometry.apply(lambda ext: ext.centroid)
extents_geocode = {}
for idx, row in urban_extents.iterrows():
res = geolocator.reverse(query = (row.centroid.y, row.centroid.x), language = "en", zoom = 10)
extents_geocode[idx] = res
addresses = [l.raw['address'] for l in list(extents_geocode.values())]
cities = [a['city'] if 'city' in a.keys() else "" for a in addresses]
counties = [a['county'] if 'county' in a.keys() else "" for a in addresses]
states = [a['state'] if 'state' in a.keys() else "" for a in addresses]
urban_extents.loc[:, "city"] = cities
urban_extents.loc[:, "county"] = counties
urban_extents.loc[:, "state"] = states
The text was updated successfully, but these errors were encountered:
What are you guys running as your geocoder these days? We are still on Bing...Sent from my Galaxy
-------- Original message --------From: Andres Chamorro ***@***.***> Date: 23/07/2021 20:48 (GMT+00:00) To: worldbank/GOST_Urban ***@***.***> Cc: Subscribed ***@***.***> Subject: [worldbank/GOST_Urban] add city name attribute to urban extents based on OSM (#1)
Leaving this as a quick solution to add OSM attributes to the urban extents output, using the Nominatim geocoder from geopy. I can add it as a notebook example or to the source code.
from geopy.geocoders import Nominatim
urban_extents.loc[:, "centroid"] = urban_extents.geometry.apply(lambda ext: ext.centroid)
extents_geocode = {}
for idx, row in urban_extents.iterrows():
res = geolocator.reverse(query = (row.centroid.y, row.centroid.x), language = "en", zoom = 10)
extents_geocode[idx] = res
addresses = [l.raw['address'] for l in list(extents_geocode.values())]
cities = [a['city'] if 'city' in a.keys() else "" for a in addresses]
counties = [a['county'] if 'county' in a.keys() else "" for a in addresses]
states = [a['state'] if 'state' in a.keys() else "" for a in addresses]
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
Leaving this as a quick solution to add OSM attributes to the urban extents output, using the Nominatim geocoder from geopy. I can add it as a notebook example or to the source code.
The text was updated successfully, but these errors were encountered: