pyrosm.OSM.get_pois#
- OSM.get_pois(custom_filter=None, extra_attributes=None, timestamp=None, tags_to_keep=None)#
Parse Point of Interest (POI) from OSM.
- Parameters:
custom_filter (dict) – An optional custom filter to filter only specific POIs from OpenStreetMap, see details below.
extra_attributes (list (optional)) – Additional OSM tag keys that will be converted into columns in the resulting GeoDataFrame.
tags_to_keep (list (optional)) – When given, only these OSM tag keys are kept as columns, replacing the default set of tag columns (reduces memory). Structural columns and filtering are unaffected; extra_attributes still apply.
timestamp (str | datetime | int) –
If provided, the data from given moment of time will be returned. The time should be provided in UTC. Note: This functionality only works with OSH.PBF files that can be downloaded manually e.g. from Geofabrik (requires login with OSM account).
The logic: the closest version of each element up to given timestamp will be selected to the result. This means that elements can be older than the given timestamp (the most up-to-date version is selected), but not newer (records having exactly the selected timestamp will be kept). In case only a date is given, the time will represent midnight of the given day, such as “2021-01-01 00:00:00”.
Notes
By default, Pyrosm will parse all OSM elements (points, lines and polygons) that are associated with following keys:
amenity
shop
tourism
You can opt-out / opt-in specific elements by using ‘custom_filter’. To parse elements associated with only specific tags, such as amenities, you can specify:
custom_filter={"amenity": True}
You can also combine multiple filters at the same time. For instance, you can parse all ‘amenity’ elements AND specific ‘shop’ elements, such as supermarkets and book stores by specifying:
custom_filter={"amenity": True, "shop": ["supermarket", "books"]}
See also
You can check the most typical OSM tags for different map features from OSM Wiki https://wiki.openstreetmap.org/wiki/Map_Features. It is also possible to get a quick look at the most typical OSM tags from Pyrosm configuration:
>>> from pyrosm.config import Conf >>> print("All available OSM keys", Conf.tags.available) All available OSM keys ['aerialway', 'aeroway', 'amenity', 'building', 'craft', 'emergency', 'geological', 'highway', 'historic', 'landuse', 'leisure', 'natural', 'office', 'power', 'public_transport', 'railway', 'route', 'place', 'shop', 'tourism', 'waterway']
>>> print("Typical tags associated with tourism:", Conf.tags.tourism) ['alpine_hut', 'apartment', 'aquarium', 'artwork', 'attraction', 'camp_pitch', 'camp_site', 'caravan_site', 'chalet', 'gallery', 'guest_house', 'hostel', 'hotel', 'information', 'motel', 'museum', 'picnic_site', 'theme_park', 'tourism', 'viewpoint', 'wilderness_hut', 'zoo']