You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to replicate output of tags-filter command #273
importosmium# Define the filters for the desired tagsfilters= [
osmium.filter.KeyFilter('highway').enable_for(osmium.osm.WAY),
osmium.filter.TagFilter(('public_transport', 'platform')).enable_for(osmium.osm.WAY),
osmium.filter.TagFilter(('railway', 'platform')).enable_for(osmium.osm.WAY),
osmium.filter.KeyFilter('park_ride').enable_for(osmium.osm.WAY),
osmium.filter.TagFilter(('type', 'restriction')).enable_for(osmium.osm.RELATION)
]
# Apply filters using a ForwardReferenceWriter to maintain referential completenesswriter=osmium.ForwardReferenceWriter('aachen-filtered.osm.pbf', ref_src='osm_data/aachen.osm.pbf', overwrite=True)
fp=osmium.FileProcessor('osm_data/aachen.osm.pbf')
# Add filters to the file processorforfinfilters:
fp=fp.with_filter(f)
# Process the file and write filtered datawithwriter:
forobjinfp:
writer.add(obj)
I would have expected these two to result in the same output file, but that does not seem to be the case.
Here's a comparison of the osmium check-refs command for both files:
# bash command
There are 49207 nodes, 14943 ways, and 272 relations in this file.
Nodes in ways missing: 0
# python code
There are 293587 nodes, 59950 ways, and 1035 relations in this file.
Nodes in ways missing: 0
Could anyone provide an explaination for the difference, to make a working python version of the bash command?
Activity
fbarbe00 commentedon Jan 7, 2025
For reference, the osm file I tried this with comes from here: https://github.com/motis-project/test-data/raw/aachen/aachen.osm.pbf