Rossy
Rossy

Reputation: 61

Using OSMNX to retrieve nearby points of interest

hoping someone can help me?

In summary, I am trying to retrieve nearby points of interest based on a set of given coordinates.

After doing some research, I found a neat function

osmnx.pois.pois_from_point(point, distance=None, amenities=None, custom_settings=None)

That works for pubs, restaurants etc.

However, hotels are not classified amenities, and nor are any other tourism related places.

I found that those are identified with tourism:hotel key/value pair.

Does anyone have an idea of how to retrieve those? I didn't seem to find a function which accepts tourism as a parameter to pass in, nor I could find any way to pass in customer attribute values for filtering.

Thanks in advance!

Upvotes: 6

Views: 4203

Answers (1)

gboeing
gboeing

Reputation: 6412

The OSMnx features module's functions take a flexible tags argument to query for any points of interest (or any OSM geospatial feature). See the documentation. This code snippet retrieves restaurants, pubs, and hotels around downtown LA:

import osmnx as ox
ox.settings.log_console = True

tags = {'amenity': ['restaurant', 'pub', 'hotel'],
        'building': 'hotel',
        'tourism': 'hotel'}
gdf = ox.features.features_from_point(point=(34.0483, -118.2531), dist=500, tags=tags)
gdf.shape #(109, 59)

Upvotes: 4

Related Questions