TMWP
TMWP

Reputation: 1625

Python Google Map API gives OSM_type that does not match documentation

I was using Google's Map API to extract address information for latitude and longitude coordinates from within Python. As shown in the code below, there is an attribute called osm_type that I believe is "open street maps type". But when I google for documentation, I find just "type" and all the lists I am finding do not include "way" as one of the expected answers to type. Does anyone know where I can get a list of types that are valid for osm_type?

Code:

from geopy.geocoders import Nominatim
geolocator = Nominatim()
from geopy.exc import GeocoderTimedOut
import time

lat = 43.2335233435383   
lon = -70.9108497973799
location = geolocator.reverse(str(lat) + ", " + str(lon), timeout=10)
print(location.raw)

Output:

{'address': {'city': 'Dover',
  'country': 'United States of America',
  'country_code': 'us',
  'county': 'Strafford County',
  'house_number': '155',
  'postcode': '03820',
  'road': 'Long Hill Road',
  'state': 'New Hampshire'},
 'boundingbox': ['43.233423343538',
  '43.233623343538',
  '-70.91094979738',
  '-70.91074979738'],
 'display_name': '155, Long Hill Road, Dover, Strafford County, New Hampshire, 03820, United States of America',
 'lat': '43.2335233435383',
 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
 'lon': '-70.9108497973799',
 'osm_id': '18868744',
 'osm_type': 'way',
 'place_id': '201786637'}

Upvotes: 0

Views: 152

Answers (1)

undercovertek
undercovertek

Reputation: 148

As far as I can tell, the specific code you are using does not support returning the type. However, running a few spot checks with your code, inputting other latitudes and longitudes, I found that a McDonalds in NY produced an osm_type of "node" instead of "way" and "way" comes up a lot. I got "node" with: Latitude=40.730949, Longitude=-74.001083.

If instead of checking Google Maps documentation, you look at Open Street Maps documentation, you will see that this field is most likely defining the type of data rather than the type of address. These types are defined by the given URL:

  • node
  • way
  • relation

That should answer what "way" means for you in this context.

Accessing the type as defined for the Google Maps API will probably require a different piece of code (if its possible). The command you are using does not appear to have that field in its output.

This page on location searches, would seem to indicate that "type" is a field used in a location search to narrow down what you are looking for. These types do not appear to be a part of the API call you are using.

Upvotes: 1

Related Questions