I would like to automate a simple operation in the QGIS graphical modeler or a simple Python script.

  1. add all line features from a .pbf file
  2. filter all features with certain values within a certain field (e.g. "waterway" = 'canal')

Doing this manually is fairly easy, by just dragging the file in the canvas, selecting all line features, and then right clicking it to select filter.

However, in the graphical modeller I struggle with the very first step of loading the .pbf files' lines.

QuickOSM I know there is QuickOSM, but again I can do it manually, but the algorithm "Open sublayers from an OSM file" that you can add to the graphical modeler doesn't do the job. First you cannot distinguish between lines and other features types (as in the manual tool). And then, I can link it to some filter algorithms in the graphical modeler (eg. "Filter by geometry type", "Extract by attribute", or "extract by expresion"), but the best I get is an empty line feature :-(.

It is indicating separate outputs for the different feature classes, but how can I access them?: enter image description here

It seems that it is possible filtering the pbf file while loading it by configuring the .ini file (https://gdal.org/drivers/vector/osm.html). Thereby, I hope to obtain only one line feature output that I can use as input for follow up algorithms, but no idea how to do it.

esy-osmfilter Besides, esy-osmfilter is an easy Python solution, but it runs into memory crash for large data extracts.

1 Answer 1


I want to mention that the MemoryError in esy-osmfilter does not depend on the size of your pbf file, but on the count and size of your positively filtered items. You don’t get an error if you look in Europe (30GB) for pipelines but you will get one if you search in Africa (4GB) for highways. This is related to the upper memory limit in python. However, you will receive proper results if you loop esy-osmfilter over african country files one by one or concretize your filtering options in the prefilter.

Disclosure: I am the main developer of esy-osmfilter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.