pythonosmfilter

get all ways by using esy-osmfilter


I have a pbf file, made with

`osmconvert64 --drop-relations "{}" -B="{}" -o="{}"'.\
                        format(input_osm, poly_file, output_osm)`

however I do not know how to retrieve only the ways from this file. I have tried with esy-osmfilter, however I cannot imagine what to put in the Elements tag

PBF_inputfile = output_osm
JSON_outputfile = "{}\\{}.geojson".format(user_input.output, city)
prefilter = {Node: {}, Way: {"highway": ["motorway", "motorway_link", "trunk", "trunk_link"], },
                             Relation: {}}
whitefilter = []
blackfilter = []
[Data, _] = run_filter('highway', PBF_inputfile, JSON_outputfile, prefilter, whitefilter,
                                       blackfilter, NewPreFilterData=True, CreateElements=False,
                                       LoadElements=False,verbose=True)
[_, Elements] = run_filter('all_ways', PBF_inputfile, JSON_outputfile, prefilter, whitefilter,
                                           blackfilter, NewPreFilterData=False, CreateElements=True,
                                           LoadElements=False, verbose=True)

export_geojson(Elements['all_ways']['Way'], Data,
                               filename=JSON_outputfile, jsontype='Line')

I get an error:

ERROR:esy.osmfilter.osm_filter:Warning2: whitefilter is not a list of list of tuples

I probably need to set whitefilter and blackfilter, but I do not know how to use them. I could not understand from the examples here


Solution

  • just follow the dokumentation than something like this should do the magic:

    [(("highway","motorway"),), (("highway","motorway_link"),), . . ]