In QGIS 1.8 I used the openstreetmap plugin to request data from the server, or open a .osm XML file, which produced 3 layers (polygons, polylines and points) in QGIS.

This was great (give or take the 64bit bug which highly affects the freshly mapped area I work on), but how do I do that in QGIS 2.x?

I can't find any updated documentation about it.

In the vector menu, I've tried importing from osm servers, I get a .osm file, but then I'm stuck. There's a menu option for loading an XML file, but it produces a spatialite db, which apparently only has non-geometry tables when I try to add it as a spatialite layer. If I open the attribute table, I can see node ids, ways and so on, but I can't figure out how to actually make use of them.

I've also tried adding a vector layer from a .osm XML file. I get a gpsbabel window that shows nothing, then finally an invalid data source message in QGIS.

  • 2
    Tom, I wrote a step-by-step instructions to get the OSM data in a QGIS. Hope this is simple to follow for beginners. qgistutorials.com/en/docs/downloading_osm_data.html Commented Apr 14, 2014 at 15:43
  • Here is a decent style (with nice setup instructions): github.com/yannos/Beautiful_OSM_in_QGIS It's intended for PostGIS (not Spatialite).
    – kontextify
    Commented Oct 5, 2018 at 10:43
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – csk
    Commented Oct 5, 2018 at 18:13

4 Answers 4


Update for QGIS 3.x: The old OSM importer from QGIS 2 was dropped in QGIS 3 due to lots of unresolved bugs. The QuickOSM plugin also enables to read osm raw files. You can use user Layer - Add Layer - Add Vector Layer instead. In that case, OSM data are opened with GDAL as documented by http://gdal.org/drv_osm.html

In QGIS 2.x, There are 3 steps involved

  1. Get an OSM File, you can get it using josm or overpass or any other source. It has to be a valid xml. You can also download it from qgis Vector > OpenStreetMap > Download OSM Data menu, but sometimes it does not give result. I would recommend using overpass turbo.
  2. Vector > OpenStreetMap > Import Topology from XML, this as you said will produce a spatialite database with non-geometry tables. This i think is the topology.
  3. Finally, you can get data by Vector > OpenStreetMap > Export Topology to Spatialite, here you need to give the db file made above and just like in qgis 1.8 you will have option to choose points, lines or polygons. Below that in exported tags section you can load all the tags contained in the file and select only those which you require. This is additional feature than in 1.8.

The layer gets added to map, if you want all nodes, ways you can repeat step 3 with other options.


  • 4
    This feels incredibly complicated, but it does work. For the sake of clarity, after step 3, you still need to add a spatialite layer, connect to the db you created, and choose the layer(s) created in step 3 to finally see the result. Thanks for your help!
    – Laurent S
    Commented Oct 4, 2013 at 6:18
  • For me, the layers were automatically created and added. The connection to the database was established in step 2 (unless you unchecked it).
    – AndreJ
    Commented Oct 5, 2013 at 12:40

I found downloading OSM data using the plugin and going through the import and export motions very tedious. That's why I wrote up a different solution: http://anitagraser.com/2014/05/31/a-guide-to-googlemaps-like-maps-with-osm-in-qgis/


Raw OSM files can be quite huge. That’s why it’s definitely preferable to download the compressed binary .pbf format instead of the XML .osm format. As a download source, I’d recommend Geofabrik.

For the first preprocessing step: extracting the area of interest, we can use Osmosis:

C:\Users\anita_000\Geodata\OSM_Noirmoutier>..\bin\osmosis.bat --read-pbf pays-de-la-loire-latest.osm.pbf --bounding-box left=-2.59 bottom=46.58 right=-1.44 top=47.07 --write-xml noirmoutier.osm

While QGIS can also load .osm files, I found that performance and access to attributes is much improved if the .osm file is converted to spatialite.

C:\Users\anita_000\Geodata\OSM_Noirmoutier>ogr2ogr -f "SQLite" -dsco SPATIALITE=YES noirmoutier.db noirmoutier.osm

In QGIS, we can load the points, lines, and multipolygons using Add SpatiaLite Layer. When we load the spatialite tables, there are some issues:

  • There is no land polygon. Instead, there are “coastline” line features.
  • Most river polygons are missing. Instead there are “riverbank” line features.

Creating the missing river polygons is not a big deal:

  1. select all the lines where waterway=riverbank.
  2. use the Polygonize tool from the processing toolbox to automatically create polygons from the areas enclosed by the selected riverbank lines. (Note that Processing by default operates only on the selected features but this setting can be changed in the Processing settings.)

Creating the land polygon (or sea polygon if you prefer that for some reason) is a little more involved since most of the time the coastline will not be closed for the simple reason that we are often cutting a piece of land out of the main continent. Therefore, before we can use the Polygonize tools, we have to close the area. To do that, I suggest to first select the coastline using "other_tags" LIKE '%"natural"=>"coastline"%' and create a new layer from this selection (save selection as …) and edit it (don’t forget to enable snapping!) to add lines to close the area. Then polygonize.

  • 1
    If you're running a fairly reliable computer, and you want the ogr2ogr stage to complete before the next ice age, add --config OGR_SQLITE_SYNCHRONOUS OFF.
    – scruss
    Commented Nov 8, 2014 at 12:49

If you don't like the plugin, fetch the OSM data you need with Overpass API, and add the result to QGIS with Add Vector Layer (enabeling All files filter).

QGIS 2.0 uses GDAL 1.10's ogr2ogr OSM importer which does a good job.

Relation support seems to be better than the plugin does at the moment.

Just make sure you download ways and relations completely, that is all nodes of the ways, and all members of the relations, with all their nodes.


You know, you don't need to put the data into SpatialLite. You can just:

  1. Download the data (Vector > OpenStreetMap > Download Data, creates an .osm file)
  2. Load the data (.osm file) as a vector layer (Layer > Add Vector Layer). After you select the file, it'll ask you which layers you want to add (as GDAL makes separate files for each type: Point, Line, MultiLine, MultiPolygon, GeomCollection). Select what you want and load it up.
  • This works in some way, but it doesn't seem to separate layers based on tags. So basically roads and rivers end up in the same Line layer, which isn't really helpful if you want to run analysis on the resulting data.
    – Laurent S
    Commented Apr 1, 2014 at 19:55
  • 1
    It wasn't clear from your question what you were doing with the data once it was imported. You can of course select out whatever features you want from the data within QGIS. As mentioned above, if you know you only want certain data (and it's not in too large an area), downloading data with Overpass would probably be better, as you can pre-select for just certain features. I find Overpass Turbo to be a user friendly way to develop queries. Here's an example of all highways in bounding box: overpass-turbo.eu/s/2VX
    – neuhausr
    Commented Apr 2, 2014 at 14:26

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