[GIS] Python: Geopy’s Nominatim reverse geocoding: Access Type (e.g. amenity)

nominatimopenstreetmappython

I have some corrdinates (lat/long) and I want to get further information on them. When using the nominatim homepage, I get quite a good overview of the available information, which exist. But when using my python code, I only get the basic address information. In the end, I want to add especially the amenity information, which I will later on use to filter my data.

The picture shows, what I want (in yellow): https://i.stack.imgur.com/Gn2C6.png

And his is what I do in python and what I get:

p = geopy.point.Point(48.705293, 8.984022)

r = Nominatim(user_agent="my-application").reverse(p)

print(r)

>>Logistikfläche, Calwer Straße, Sindelfingen (Stadt), Sindelfingen, Landkreis Böblingen, Baden-Württemberg, 71063, Deutschland



Best Answer

As far as I know, you can show bunch of data from Nominatim reverse geocode. This is an example:

from geopy.geocoders import Nominatim

locator = Nominatim(user_agent=”myGeocoder”)
coordinates = “53.480837, -2.244914”
location = locator.reverse(coordinates)
location.raw

If you just wanna look for the address, simply type location.address. Whereas, raw element of location is used to show a lot of data like this:

{‘address’: {‘building’: ‘Eagle Insurance Buildings’, 
‘city’: ‘Manchester’, 
‘country’: ‘United Kingdom’, 
‘country_code’: ‘gb’, 
‘county’: ‘Greater Manchester’, 
‘house_number’: ‘68’, 
‘postcode’: ‘M2 4JG’, 
‘road’: ‘Cross Street’, 
‘state’: ‘England’, 
‘state_district’: ‘North West England’, 
‘suburb’: ‘City Centre’}, 
‘boundingbox’: [‘53.480856’, ‘53.4810634’, ‘-2.2451761’, ‘-2.2449576’], 
‘display_name’: ‘Eagle Insurance Buildings, 68, Cross Street, City Centre, Manchester, Greater Manchester, North West England, England, M2 4JG, United Kingdom’,
‘lat’: ‘53.4809597’, 
‘licence’: ‘Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 
‘lon’: ‘-2.24506682746292’, 
‘osm_id’: 37139875, 
‘osm_type’: ‘way’, 
‘place_id’: 86197794}

Hope it helps, I refer to this.