I'm trying to add some data in OSM file format in a QGIS 3.4 Graphical Modeler. I'm interested in the line type of data (layer ID 1) inside .osm file but I can only access point data (layer ID 0). The two tested methods were:

  1. Algorithm "Load layer into project". Only point data are loaded. There are no options to specify the target layer.
  2. Algorithm "Convert format" from GDAL/Vector. Despite the fact that, apparently, I have control of the conversion options through "Additional creation options field" where I can pass something like

-sql "SELECT * FROM lines"

in reality, it seems that the conversion is preceded by plain a hard-coded ogr2ogr command in form of

ogr2ogr -f ESRI Shapefile input output.shp

This hard-coded command is ignoring any other parameters, thus producing a .shp file with the first layer from the .osm file, the points.

Any clues on how to access the line type of data from the .osm file?

1 Answer 1


You should load first your layer in the QGIS mapcanvas. QGIS will ask you which sublayer you want to add. I choosed "multipolygons".

layer properties

Notice the |layername=multipolygons in the source.

You can drop your layer from the canvas. It seems you don't want to load first your layer into the canvas (because in that case, you can just use a vector layer input, QGIS will give your line layer already).

We are going to apply the same logic in the modeler.

Now in the modeler, I add an file input. I add a string concatenation algorithm:

  • First argument is my path
  • Second argument is |layername=multipolygons.

string concatenation

Then I can use this layer path in another algorithm: graphical modeler with OSM data

Layers which are available from the OSM OGR Driver https://www.gdal.org/drv_osm.html :

  1. points
  2. lines
  3. multilinestrings
  4. multipolygons
  5. other_relations difficult to use in QGIS
  • String concatenation algorithm did the trick. Thank you! Feb 24, 2019 at 20:49

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.