Loading Data: Mastering QGIS



This section of the free chapter preview of Mastering QGIS covers loading different data types into QGIS desktop.  Mastering QGIS is designed to bring users who want to go beyond the basics of QGIS to an advanced level of QGIS expertise. 

Loading data in QGIS

One strength, of QGIS is its ability to load a large number of data types. In this section, we will cover loading various types of data into QGIS Desktop.

In general, data can be loaded in four ways. The first way, which will be covered in detail in this section, is to use the Layer | Add Layer menu and select the appropriate type of data you wish to load. The second way is to open the Browser panel, navigate to the data you wish to load, and then drag the data on to the map display, or on to the Layers panel. The third way to load data is to enable the Manage Layers toolbar, and click on the button representing the data type you wish to load. The fourth way is to locate the data in QGIS Browser, drag to the data, and drop it onto the QGIS Desktop Map Display or Layers panel.

Loading Vector data

To load vector files, click Layer | Add Layer | Add Vector Layer. This will open the Add vector layer dialog allowing us to choose the source type and source of the dataset we wish to load.

Free weekly newsletter

Fill out your e-mail address to receive our newsletter!

The Source type contains four options of File, Directory, Database, and Protocol. When you choose a source type, the source interface will change to display appropriate options. Let’s take a moment to discuss what type of data these four source types can load.

  • File: Flat-files stored on disk. Commonly used flat-file types:
  • Esri shapefile (.shp)
  • AutoCAD DXF (.dxf)
  • comma separated values (.csv)
  • GPS eXchange Format (.gpx)
  • Keyhole Markup Language (.kml)
  • SQLite/SpatiaLite (.sqlite/.db)
  • Directory: Data stored on disk encased in a directory. Commonly used directory types:
  • S. Census TIGER/Line
  • Arc/Info Binary Coverage
  • Database: Databases stored on disk or available through service connections. Commonly used database types:
  • ODBC
  • Esri Personal GeoDatabase
  • MySQL
  • PostgreSQL
  • Protocol: Protocols available at a specific URI. QGIS currently supports loading the GeoJSON protocol.

Loading Raster data

To load raster data into QGIS, click Layer | Add Layer | Add Raster Layer. This will open a file browser window allowing you to choose a GDAL supported raster file. Commonly used raster types supported by GDAL are:

  • Arc/Info ASCII Grid (.asc)
  • Erdas Imagine Images (.img)
  • GeoTIFF (.tif .tiff)
  • JPEG/JPEG-2000 (.jpg .jpeg/.jp2 .j2k)
  • Portable Network Graphics (.png)
  • Rasterlite (.sqlite)
  • USGS Optional ASCII DEM (.dem)

To add an Oracle GeoRaster, click Layer | Add Layer | Add Oracle GeoRaster Layer, then connect to an Oracle database to load the raster. More information about loading database layers is in the following section.

The Geospatial Data Abstraction Library (GDAL) is a free and open source library that translates and processes vector and raster geospatial data formats. QGIS, as well as many other programs, use GDAL to handle many geospatial data processing tasks.

You may see references to OGR or GDAL/OGR as you work with QGIS and GDAL. OGR stands for OGR Simple Features Library and references the vector processing parts of GDAL. OGR is not really a stand-alone project, as it is part of the GDAL code now, however, for historical reasons, OGR is still used.

More information about GDAL and OGR can be found at http://gdal.org. GDAL is an Open Source Geospatial Foundation (http://osgeo.org) project.

Loading Databases

QGIS supports PostGIS, SpatiaLite, MSSQL, and Oracle databases. Regardless of the type of database you wish to load, the loading sequence is very similar. Therefore, instead of covering specific examples, the general sequence will be covered.

First, click Layer | Add Layer and then choose the database type you wish to load. This will open a window with opens for adding data stored in a database. As an example, the following screenshot shows the window that opens when Layer | Add Layer | Add SpatiaLite Layer is selected.

Note that the window will look the same for any database you choose, except the window name.

QGIS supports leading GIS data from PostGIS, SpatiaLite, MSSQL, and Oracle databases.
QGIS supports leading GIS data from PostGIS, SpatiaLite, MSSQL, and Oracle databases.

To load data from a database, we must first create a connection to the database. To create a new connection, click the New button to open a connection information window. Depending on the database type you are connecting to, different connection options will be shown. Once you have created a database connection, select it from the dropdown list and press Connect; you will see a list of all layers contained within the database display. If there is a large number of tables, you can select Search options and perform a search on the database. To load a layer, select it in the list, then click Add. If you only wish to load a portion of the layer, select the layer then click Set Filter to open the Query Builder. If you set a query, then add the layer, only the filtered features will be added.

Web services

QGIS supports the loading of OGC-compliant web services such as WMS/WMTS, WCS, and WFS. Loading a web service is similar to loading a database service. In general, you will create a new server connection, connect to the server to list the available services, and add the service to the QGIS project.

<– Previous: Tour of QGIS     ~ From Mastering QGIS ~     Next: Coordinate Systems in QGIS –>

Photo of author
About the author