This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

pyrosm exclude filter not working

0

hi

I'm trying to use pyrosm to read a pbf file and filter it to get 'major' driving edges i.e. which are not parking/parking aisle etc. I tried using the "exclude" filter type to get edges that don't have specific tags, but I still get such edges. Any idea what am I doing wrong?

thanks

My code is:

from pyrosm import OSM, get_data
drive_filter = dict(
    area=['yes'],
    service=['parking', 'parking_aisle', 'private', 'emergency_access','parking_aisle'],
    highway=['cycleway', 'footway', 'path', 'pedestrian', 'steps', 'track',
             'corridor', 'elevator', 'escalator', 'proposed', 'construction',
             'bridleway', 'abandoned', 'platform', 'raceway'],
    motor_vehicle=['no'],
    motorcar=['no']
)
osm = OSM(get_data("test_pbf"))
driving = osm.get_data_by_custom_criteria(custom_filter=drive_filter,
                                          osm_keys_to_keep="highway",
                                          filter_type="exclude")
print(driving['service'].unique())

Output is:

[None 'driveway' 'parking_aisle']

asked 14 Mar '21, 15:45

anatrk's gravatar image

anatrk
11113
accept rate: 0%

edited 15 Mar '21, 07:07

Source code available on GitHub .