pyrosm.OSM.get_data_by_custom_criteria#
- OSM.get_data_by_custom_criteria(custom_filter=None, osm_keys_to_keep=None, filter_type='keep', tags_as_columns=None, keep_nodes=True, keep_ways=True, keep_relations=True, extra_attributes=None, keep_other_tags=True, timestamp=None)#
Parse OSM data based on custom criteria.
- Parameters:
custom_filter (dict (optional)) – A custom filter to filter only specific elements from OpenStreetMap. If
None(the default), every tagged element is returned without key/value filtering (tagged nodes, ways, and relations); standalone ways with no tags are dropped. Reading everything is memory-heavy on large extracts, so prefer a pre-filtered PBF and/or a bounding box.filter_typeis ignored in this mode.osm_keys_to_keep (str | list) – A filter to specify which OSM keys should be kept.
filter_type (str) – “keep” | “exclude” Whether the filters should be used to keep or exclude the data from OSM.
tags_as_columns (list) – Which tags should be kept as columns in the resulting GeoDataFrame.
keep_nodes (bool) – Whether or not the nodes should be kept in the resulting GeoDataFrame if they are found.
keep_ways (bool) – Whether or not the ways should be kept in the resulting GeoDataFrame if they are found.
keep_relations (bool) – Whether or not the relations should be kept in the resulting GeoDataFrame if they are found.
extra_attributes (list (optional)) – Additional OSM tag keys that will be converted into columns in the resulting GeoDataFrame.
keep_other_tags (bool) – By default (
True) every tag is parsed:tags_as_columnsbecome their own columns and the rest are kept in a JSONtagscolumn.Falseresolves only the requested tags (tags_as_columnsplus the filter keys) and drops the JSONtagscolumn, so the read does minimal tag work (a stray tag literally keyedidis not surfaced asid_tagin this mode). Only supported by the out-of-core engine (OSM(..., engine='out_of_core')).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”.