QGIS

From OpenStreetMap Wiki
Jump to navigation Jump to search
QGIS
QGIS 2.2 Valmiera showing new menu design.png
License: GNU General Public License (free of charge)
Platforms: Windows, Linux, and macOS
Version: 3.24.2 releases (2022-04-15)
Language: English
Website: https://qgis.org
Programming languages: C++ and Python

a free, multiplatform GIS application

QGIS (previously also known as Quantum GIS) is a free (GNU GPL v2) and open source GIS application enabling the user to visualize, manage, edit, analyse data, and compose printable maps. It runs on Linux, Unix, Mac OSX, Windows and can be downloaded free of charge from qgis.org. It powers 3rd party open-source apps for mobile and tablet, Mergin Maps ([1]), QField or IntraMaps Roam.

OpenStreetMap in QGIS

In QGIS version 3, there are built-in features to use raster and vector data from OpenStreetMap. There is no built-in possibility to upload changes back to a OpenStreetMap server directly from QGIS. For this purpose, please use one of the Editors.

Raster maps

The XYZ Tiles source section includes OpenStreetMap as a standard feature. Right clicking on that reveals an option to add that as a layer.

See this screenshot

Note that QGIS caches the raster maps. Changes made on OpenStreetMap will not show up until the QGIS cache is cleared. The Clear cache button is hidden in the Settings -> Options... -> Network form.

See this screenshot

Vector data

OSM files

Vector data can be loaded into QGIS from an OSM file without any extra add-ins. Use Layer -> Add Layer -> Add Vector Layer menu and specify an OSM file to be imported into a QGIS project. An OSM file can be exported from OpenStreetMap in a number different ways. For example, use the Export button at https://www.openstreetmap.org/

QuickOSM plugin

QuickOSM allows you to work quickly with OSM data in QGIS thanks to Overpass API.

One of tutorials is available at Searching and Downloading OpenStreetMap Data (QGIS3)¶.

Previous Versions

QGIS 2: Importing OSM vector layers

QGIS 2.0 integrates OpenStreetMap import as a core functionality. To get OSM data, use the "Vector → Openstreetmap" menu:

  1. "Load data" will connect to the OSM server and download data. You can skip this step if you already have a .osm XML file.
  2. "Import topology from an XML file" below will convert your .osm file into a spatialite database, and create a db connection.
  3. "Export topology to Spatialite" then allows you to open the database connection, select the type of data you want (points, lines, and polygons) and choose tags to import. Do this three times (clicking 'Load from DB' for each) to create three spatialite geometry layers.
  4. Add this layer to your project via the "add a spatialite layer" menu.

More details here. Note that this process imports raw OSM GIS data not any particular map style/symbology.

QuickOSM

QuickOSM allows you to work quickly with OSM data in QGIS thanks to Overpass API.

OpenStreetMap Plugin (obsolete)

For QGIS older than version 2: The QGIS OSM Plugin lets you load in vector data from OpenStreetMap, and even edit and upload your changes. However, due to a bug related to 64-bit Identifiers, newer data is not read. See the QGIS OSM Plugin page for more info and workarounds.

Shapefiles, PostGIS and other conversion options

There are many ways converting OSM data to other formats which can then be opened within QGIS. In particular note the various options for Shapefiles and PostGIS databases.

Using raster maps from OpenStreetMap

There are a couple of different approaches to bring in tiles from OpenStreetMap (or from other OpenStreetMap tile providers) :

  • Install QuickMapServices plugin, find its button on the toolbar and click it to see a list of layers, including OSM layers.
  • The QGIS OpenLayers Plugin offers another easy way. In QGIS2.0 go to "Plugins" menu -> "Manage Installed Plugins...", then search for OpenLayers under 'Get More'. In older 1.x QGIS you need to enable the "Plugin Installer" from the Plugin Manager and then from "Plugins" -> "Fetch Python Plugins" and select the "Openlayers Plugin". The list of available OSM tile layers then appears from the "Plugins" -> "OpenLayers plugin" menu. (Note that this process alters the CRS (coordinate reference system) for the QGIS project, and that you may encounter issues with printing the map).
  • GDAL support is built in, so you can make a GDAL XML config and load this as a raster layer.
  • The Bigmap service makes it relatively easy to import a georeferenced image created from glued-together map tiles (for a very limited area).

See Question:How to get OpenStreetMap as a raster layer in QGIS?

To make OSM layer look smooth make sure you use ESPG:3857 projection and set a scale to start from 1:2257.

You can also import this file to set the scale pyramid for your project:

<qgsScales version="1.0">
<scale value="1:591659030"/>
<scale value="1:295829515"/>
<scale value="1:147914757"/>
<scale value="1:73957378"/>
<scale value="1:36978689"/>
<scale value="1:18489344"/>
<scale value="1:9244672"/>
<scale value="1:4622336"/>
<scale value="1:2311168"/>
<scale value="1:1155584"/>
<scale value="1:577792"/>
<scale value="1:288896"/>
<scale value="1:144448"/>
<scale value="1:72224"/>
<scale value="1:36112"/>
<scale value="1:18056"/>
<scale value="1:9028"/>
<scale value="1:4514"/>
<scale value="1:2257"/>
</qgsScales>

Styles for OSM data in QGIS

There are an increasing number of QGIS styles pre-prepared and available for Openstreetmap data - for example:

More OpenStreetMap Plugins

  • QuickOSM, as mentioned above, gets data from OSM via Overpass API.
  • OSMinfo lets you click to find OSM information about what a nearby object is.
  • Quantumnik was a QGIS plugin which helped in Mapnik style authoring. It worked with QGIS 1.8 or lower.

General QGIS info

See also wikipedia:Quantum GIS.

Features

The major features of QGIS include:

  • Direct viewing and exploration of spatial data
    • Advanced symbology (edit rendering styles)
    • QGIS Browser as a simple and fast data viewer
  • Support for numerous vector, raster, and database formats
  • Create, edit and export spatial data
    • Work with nodes, lines and polygons
    • Convert between different coordinate systems (re-projection)
    • Down/upload directly to a GPS unit
  • Perform spatial analysis
    • Find polygon centroids and basic statistics
    • Distance matrix and line intersections
  • Publish your map on the internet
  • An extensible plug-in architecture
  • Remote control JOSM [2] with QuickOSM

Documentation & Tutorials

Rendering of Gallarate (see the 'Using OpenStreetMap data' tutorial [ dead link ]).

The QGIS wiki provides numerous guides and video tutorials to help users of all abilities. For new users a good place to start is the Introduction to Quantum GIS video. It is also important to have a basic understanding about the #Coordinate Reference System.

Other useful pages to bookmark:

  1. The free Beginning Quantum GIS guides stored in Google Docs (produced by learnosm).
  2. How do I do that in QGIS [ dead link ] on the QGIS wiki.
  3. QGIS Tutorials by Ujaval Gandhi.

QGIS allows you to to create advanced symbology (similar to Mapnik or Osmarender) in a powerful but very easy way (a few mouse clicks), see examples here [ dead link ] and a detailed video on youtube.

Coordinate Reference System

Earth is a three-dimensional body, roughly spherical in shape, yet the vast majority of maps are flat (2-dimesional). A Coordinate Reference System (CRS) defines a method of projecting all or part of the Earth onto a 2D surface. QGIS has support for approximately 2,700 known CRS. Some, such as WGS-84 are global projections, whereas others represent only specific regions.

Setting the CRS

When working with geo-spatial data it is essential that you are using the correct CRS. If you are lucky the projection will be specified as part of the vector file (for example, ESRI Shapefiles often include projection data in the .prj file), however you will often have to manually select the correct CRS.

To specify the CRS of a vector layer, select the layer and choice Layer->Set CRS of Layer(s).... Each layer can have a different CRS. If this is the case, you will need to convert them to the same CRS in order for them all to display correctly. The easiest way to do this is to use 'on the fly' CRS transformation:

  1. Settings->Project Properties (or click on the globe symbol in the lower right corner).
  2. Select the Coordinate Reference System (CRS) tab.
  3. Check the Enable 'on the fly' CRS transformation checkbox.
  4. Pick a suitable project CRS to work with (e.g. WGS-84).

More information can be found in this video tutorial.

Using QGIS to convert between CRS

QGIS can be used to convert between CRS. Open the input layer making sure to select the correct CRS as described above. Use Layer->Save As... to export the layer with a different CRS (you may choice between the "Project" CRS or select a CRS from QGIS's extensive list).

Using QGIS to filter data from government sources and convert it to KML

In Sweden multiple government agencies give out data in large shapefiles. These files do not load nicely in JOSM because of their size and/or JOSMs premature shp support.

To filter out part of a shp file in QGIS you can do this:

  1. get the file, e.g. http://gpt.vic-metria.nu/data/land/NR.zip
  2. open the shp file in QGIS
  3. enable editing
  4. select a number of nodes and delete them
  5. rightclick on the layer and choose "Export.."
  6. select KML (this is better supported in JOSM)
  7. click save and open up the result in JOSM

Here is a video tutorial describing more advanced filtering based on attributes. In this example it would be nice to only have the nature reserves where "BESLSTATUS" = 'Gällande' is true because that means they are in effect (and not just planned). Follow the tutorial in the video to archive this.

See also

External links

References