Monday, May 12, 2014

Import OpenStreetMap features into QGIS

QGIS 2.2 has a built in function to import OpenStreetMap features into a SpatiaLite database. Using the function requires us to perform three basic steps:
  • Download data
  • Import topology from XML
  • Export topology to SpatiaLite
The following steps illustrate how to import OpenStreetMap features into QGIS.

Download data
  1. Start QGIS. Optional: Navigate the map view to the area where you want to download OpenStreetMap features.


  2. Select Vector | OpenStreetMap | Download data.

    The Download OpenStreetMap data dialog box appears.

  3. Optional. Choose an extent method e.g. From map canvas.
  4. In the Output file field, click the [...] button.

    The Save As dialog box appears.

  5. Type in a file name, e.g. fortaleza.osm. Click Save. Click OK.

    The OpenStreetMap data has been downloaded.

  6. Click OK. Click Close.
Import topology from XML
  1. Select Vector | OpenStreetMap | Import topology from XML.

    The OpenStreetMap Import dialog box appears.

  2. In the Input XML file (*.osm) field, click the [...] button.

    The Open dialog box appears.

  3. Browse and select the previously downloaded *.osm file, e.g. fortaleza.osm. Click Open.

    The Output SpatiaLite DB file and Connection name fields are populated with default values.

  4. Click OK.

    The OpenStreetMap tables are imported into the SpatiaLite DB.

  5. Click OK. Click Close.
     
Export topology to SpatiaLite.
  1. Select Vector | OpenStreetMap | Export topology to SpatiaLite.

    The Export OpenStreetMap topology to SpatiaLite dialog box appears.

  2. In the Input DB file field, click the [...] button.

    The Open dialog box appears.
  3. Browse and select the previously created SpatiaLite DB file, e.g. fortaleza.osm.db. Click Open.
  4. In the Export type field, toggle on a geometry feature type, e.g. Polylines.


  5. Optional. In the Output layer name field, type in a layer name to use, e.g. fortaleza_polylines.
  6. Click OK.

    The layer is created in QGIS.
  7. Click OK.


  8. Optional. Repeat the previous steps 4-6 for additional geometry types.
  9. Click Close.

No comments:

Post a Comment