Docs in progress for ‘QGIS testing’. Visit https://docs.qgis.org/2.18 for QGIS 2.18 docs and translations.

Opening Data

As part of an Open Source Software ecosystem, QGIS is built upon different libraries that, combined with its own providers, offer capabilities to read and often write a lot of formats:

  • Vector data formats include ESRI formats (Shapefile, Geodatabase…), MapInfo and MicroStation file formats, AutoCAD DWG/DXF, GeoPackage, GeoJSON, GRASS, GPX, KML, Comma Separated Values, and many more… Read the complete list of OGR vector supported formats.
  • Raster data formats include ArcInfo Binary Grid, ArcInfo ASCII Grid, JPEG, GeoTIFF, ERDAS IMAGINE, MBTiles, R or Idrisi rasters, ASCII Gridded XYZ, GDAL Virtual, SRTM, Sentinel Data, and many more… Read the complete list of raster supported formats.
  • Database formats include PostgreSQL/PostGIS, SQLite/SpatiaLite, Oracle, DB2 or MSSQL Spatial, MySQL…
  • Support of web data services (WM(T)S, WFS, WCS, CSW, ArcGIS Servers…) is also handled by QGIS providers (see QGIS as OGC Data Client).
  • You can also read supported files from archived folders and use QGIS native formats such as virtual and memory layers.

As of the date of this document, more than 80 vector and 140 raster formats are supported by the GDAL/OGR and QGIS native providers.

Note

Not all of the listed formats may work in QGIS for various reasons. For example, some require external proprietary libraries, or the GDAL/OGR installation of your OS may not have been built to support the format you want to use. To have a list of available formats, run the command line ogrinfo --formats (for vector) or check settings ‣ Options ‣ GDAL menu (for raster) in QGIS.

In QGIS, depending on the data format, there are different tools to open it, mainly available in the Layer ‣ Add Layer ‣ menu or from the Manage Layers toolbar (enabled through View ‣ Toolbars menu). However, all these tools point to a unique dialog, the Data Source Manager dialog that you can directly open with the dataSourceManager Open Data Source Manager button available on the Data Source Manager Toolbar or by pressing Ctrl+L. Indeed, the Data Source Manager dialog offers a unified interface to open vector or raster file-based data as well as databases or web services supported by QGIS. It can be set modal or not with the checkbox Modeless data source manager dialog in Settings ‣ Options ‣ General menu.

../../../_images/datasource_manager.png

QGIS Data Source Manager dialog

Beside this main entry point, you also have the dbManager DB Manager plugin that offers advanced capabilities to analyze and manipulate connected databases. More information on DB Manager capabilities are exposed in DB Manager Plugin.

There are also many other tools, native or third-party plugins, that help you open dedicated data formats.

This chapter will describe only the tools provided by default in QGIS to load data. It will mainly focus on the Data Source Manager dialog but more than describing each tab, it will also explore the tools based on the data provider or format specificities.

The Browser Panel

The Browser is one of the main ways to quickly and easily add your data to projects. It’s available as:

  • a Data Source Manager tab, enabled pressing the dataSourceManager Open Data Source Manager button (Ctrl+L);
  • as a QGIS panel you can open from the menu View ‣ Panels (or kde Settings ‣ Panels) or by pressing Ctrl+2.

In both cases, the Browser helps you navigate in your file system and manage geodata, regardless the type of layer (raster, vector, table), or the datasource format (plain or compressed files, database, web services).

To add a layer into a project, using the Browser interface:

  1. Enable the Browser as described above. A browser tree with your file system, databases and web services is displayed. You may need to connect databases and web services before they appear (see dedicated sections).

  2. Find the layer in the list.

  3. Double-click its name or drag-and-drop it into the map canvas. Your layer is now added to the Layers panel and can be viewed in the map canvas.

    Tip

    Open a QGIS project directly from the browser

    You can also open a QGIS project directly from the Browser panel by double-clicking its name or by drag-and-drop into the map canvas.

Once a file is loaded, you can zoom around it using the map navigation tools. To change the style of a layer, open the Layer Properties dialog by double clicking on the layer name or by right-clicking on the name in the legend and choosing Properties from the context menu. See section Symbology Properties for more information on setting symbology of vector layers.

At the top of the Browser panel, you find some icons that help you to:

  • addLayer Add Selected Layers: you can also add data into the map canvas by selecting Add selected layer(s) from the layer’s context menu;
  • draw Refresh the browser tree;
  • filterMap Filter Browser to search for specific data. Enter a search word or wildcard and the browser will filter the tree to only show paths to matching DB tables, filenames or folders – other data or folders won’t be displayed. See the Browser Panel(2) example on the figure_browser_panels. The comparison can be case-sensitive or not. It can also be set to:
    • normal: return any item containing the search text;
    • using wildcard(s): fine tune the search using ? and/or * characters to specify the position of the search text;
    • using a regular expression.
  • collapseTree Collapse All the whole tree;
  • metadata Enable/disable properties widget: when toggled on, a new widget is added at the bottom of the panel showing, if applicable, metadatas of the selected item.

Right-click an item in the browser tree helps you to:

  • in case of file or table, display its metadata or open it in your project. Tables can even be renamed, deleted or truncated;
  • in case of folder, bookmark it into your favourites, hide it from the browser tree. Hidden folders can be managed from the Settings ‣ Options ‣ Data Sources tab;
  • create connection to databases or web servers;
  • refresh, rename or delete schema.

You can also import files into databases or copy tables from one schema/database to another one with a simple drag-and-drop. There is a second browser panel available to avoid long scrolling while dragging. Just select the file and drag-and-drop from one panel to the other.

../../../_images/browser_panels.png

QGIS Browser panels side-by-side

Tip

Add layers to QGIS by simple drag-and-drop from your OS file browser

You can also add file(s) to the project by drag-and-dropping them from your operating system file browser to the Layers Panel or the map canvas.

The DB Manager

The DB Manager Plugin is another one of the main and native tools to integrate and manage spatial database formats supported by QGIS (PostGIS, SpatiaLite, GeoPackage, Oracle Spatial, MSSQL, DB2, Virtual layers) in one user interface. It can be activated from the Plugins ‣ Manage and Install Plugins… menu.

The dbManager DB Manager Plugin provides several features:

  • connect to databases and display its structure and contents;
  • preview tables of databases;
  • add layers to map canvas, either by double-click or drag-and-drop;
  • add layers to a database from the QGIS Browser or from another database;
  • create and add output of SQL queries to the map canvas;
  • create virtual layers.

More information on DB Manager capabilities are exposed in DB Manager Plugin.

../../../_images/db_manager.png

DB Manager dialog

Provider-based loading tools

Beside Browser Panel and DB Manager, the main tools provided by QGIS to add layers regardless the format, you’ll also find tools that are specific to data providers.

Note

Some external plugins also propose tools to open specific format files in QGIS.

Loading a layer from a file

To load a layer from a file, you can:

  • for vector data (like Shapefile, Mapinfo or dxf layer), click on addOgrLayer Add Vector Layer toolbar button, select the Layer ‣ Add Layer ‣ addOgrLayerAdd Vector Layer menu option or press Ctrl+Shift+V. This will bring up a new window (see figure_vector_add) from which you can check radioButtonOn File and click on Browse. You can also specify the encoding for the file if desired.

    ../../../_images/addvectorlayerdialog.png

    Add Vector Layer Dialog

  • for raster layers, click on the addRasterLayer Add Raster Layer icon, select the Layer ‣ Add Layer ‣ addRasterLayer Add Raster Layer menu option or type Ctrl+Shift+R.

That will bring up a standard open file dialog (see figure_vector_open), which allows you to navigate the file system and load a shapefile, a geotiff or other supported data source. The selection box Filter selectString allows you to preselect some supported file formats. Only the formats that have been well tested appear in the list. Other untested formats can be loaded by selecting All files (*.*).

../../../_images/shapefileopendialog.png

Open an OGR Supported Vector Layer Dialog

Selecting a file from the list and clicking Open loads it into QGIS. More than one layer can be loaded at the same time by holding down the Ctrl or Shift key and clicking on multiple items in the dialog. Figure_vector_loaded shows QGIS after loading the alaska.shp file.

../../../_images/shapefileloaded.png

QGIS with Shapefile of Alaska loaded

Note

Because some formats like MapInfo (e.g., .tab) or Autocad (.dxf) allow mixing different types of geometry in a single file, loading such format in QGIS opens a dialog to select geometries to use in order to have one geometry per layer.

Using the addOgrLayer Add Vector Layer tool:

  • You can also load specific formats like ArcInfo Binary Coverage, UK. National Transfer Format, as well as the raw TIGER format of the US Census Bureau or OpenfileGDB. To do that, you’d need to select radioButtonOn Directory as Source type. In this case a directory can be selected in the dialog after pressing Browse.

  • With the radioButtonOn Database source type you can select an existing database connection or create one to the selected database type. Available database types are ODBC, OGDI Vectors, Esri Personal Geodatabase, MySQL as well as PostgreSQL or MSSQL.

    Pressing the New button opens the Create a New OGR Database Connection dialog whose parameters are among the ones you can find in Creating a stored Connection. Pressing Open you can select from the available tables for example of the PostGIS enabled database.

  • The last source type, radioButtonOn Protocol, enables to open data from the web using for example GeoJSON or CouchDB format. After selecting the type you have to fill URI of the source.

Tip

Load layers and projects from mounted external drives on macOS

On macOS, portable drives that are mounted beside the primary hard drive do not show up as expected under File ‣ Open…. We are working on a more macOS-native open/save dialog to fix this. As a workaround, you can type /Volumes in the File name box and press Enter. Then you can navigate to external drives and network mounts.

Importing a delimited text file

Delimited text file (e.g. .csv, .txt) can be loaded in QGIS using the tools described above. However, loaded this way, it’ll show up like a simple table data. Sometimes, delimited text files can contain geometric data you’d want to visualize; this is what the addDelimitedTextLayerAdd Delimited Text Layer is designed for.

Click the dataSourceManager Open Data Source Manager icon to open the Data Source Manager dialog and enable the addDelimitedTextLayer Delimited Text tab, as shown in figure_delimited_text.

../../../_images/delimited_text_dialog.png

Delimited Text Dialog

First, select the file to import (e.g., qgis_sample_data/csv/elevp.csv) by clicking on the Browse button. In the Layer name field, provide the name to use for the layer in the project (e.g., Elevation).

File format

Once the file is selected, QGIS attempts to parse the file with the most recently used delimiter, trying to identify fields and rows. To enable QGIS to properly parse the file, it is important to select the correct delimiter. You can specify a delimiter by activating:

  • radioButtonOnCSV (comma separated values) to use the comma character;
  • radioButtonOffCustom delimiters, choosing among some predefined delimiters like comma, space, tab, semicolon…;
  • or radioButtonOffRegular expression delimiter and entering text into the Expression field. For example, to change the delimiter to tab, use \t (this is a regular expression for the tab character).

Records and fields

Other than settings to identify rows and fields in the data, some convenient options can be used to tweak the data recognition:

  • Number of header lines to discard: convenient when you want to avoid some lines to show in the import, either because those are blank lines or with another formatting.
  • checkboxFirst records has field names: values in the first row of data are used as field names, otherwise QGIS adds a fields row of a type field_1, field_2
  • checkboxDetect field types: automatically recognizes the field type. If unchecked then all attributes are treated as text fields.
  • checkboxDecimal separator is comma: if necessary, you can force a comma to be the decimal separator.
  • checkboxTrim fields: allows you to trim leading and trailing spaces from fields.
  • checkboxDiscard empty fields.

As you set the parser properties, a sample data preview updates at the bottom of the dialog.

Geometry definition

Once the file is parsed, set Geometry definition to

  • radioButtonOnPoint coordinates and provide the X field and Y field if the layer is of point geometry type and contain such coordinate fields. If the coordinates are defined as degrees/minutes/seconds, activate the checkboxDMS coordinates checkbox;
  • radioButtonOnWell known text (WKT) option if the spatial information is represented by WKT: select the Geometry field containing the WKT definition and choose the approriate Geometry field or let QGIS auto-detect it;
  • If the file contains non-spatial data, activate radioButtonOn No geometry (attribute only table) and it will be loaded as an ordinary table.

Besides the features geometry information, you can also set the layer’s Geometry CRS using the setProjection Select CRS widget.

Layer settings

Additionally, you can enable:

  • checkboxUse spatial index to improve the performance of displaying and spatially selecting features;
  • checkboxUse subset index to improve performance of subset filters (when defined in the layer properties);
  • checkboxWatch file to watch for changes to the file by other applications while QGIS is running.

At the end, click OK to add the layer to the map. In our example, a point layer named Elevation is added to the project and behaves like any other map layer in QGIS. However, this layer is the result of a query on the .csv source layer (hence, linked to it) and would require to be saved in order to get a spatial layer on disk.

Importing a DXF or DWG file

DXF and DWG files can be added to QGIS by simple drag-and-drop from the common Browser Panel. You’ll be prompted to select the sublayers you’d like to add to the project. Layers are added with random style properties.

Note

DXF files containing several geometry types (point, line and/or polygon), the name of the layer will be made from <filename.dxf> entities <geometry type>.

To keep the dxf/dwg structure and its symbology in QGIS, you may want to use the dedicated Project ‣ Import/Export ‣ Import Layers from DWG/DXF… tool. Indeed, the DWG/DXF Import dialog allows you to import into GeoPackage database any element of the drawing file.

In the dialog, you have to:

  • Input a location for a GeoPackage file, that will be created to store the DWG/DXF content to;
  • Specify which coordinate system the data in the DWG data is in;
  • Then use the Import button to select the DWG/DXF file to use (one per geopackage). The GeoPackage database will be automatically populated with the drawing file content. Depending on the size of the *CAD file, this could take some time;
  • The checkbox Expand block references will transform the existing blocks into normal elements;
  • the checkbox Use curves promotes the output layers geometry type to a curved one.

After the .dwg or .dxf data is imported into the GeoPackage database the frame in the lower half of the dialog is populated with the list of layers from the imported file. There you can select which layers to add to the QGIS project:

  1. At the top, set a Group name to group the drawing files in the project.
  2. Check layers to show: Each selected layer is added to an ad hoc group which contains vector layers for the point, line, label and area features of the drawing layer. The style of each layer is setup so that it resembles the look it originally had in *CAD.
  3. Check whether layer should be visible at opening.
  4. Alternatively using the checkbox Merge layers option places all layers in a single group.
  5. Press OK to open the layers in QGIS.

Importing OpenStreetMap Vectors

In recent years, the OpenStreetMap project has gained popularity because in many countries no free geodata such as digital road maps are available. The objective of the OSM project is to create a free editable map of the world from GPS data, aerial photography or local knowledge. To support this objective, QGIS provides support for OSM data.

Using the Browser Panel, you can load a .osm file to the map canvas, in which case you’ll get a dialog to select sublayers based on the geometry type. The loaded layers will contain all the data of that geometry type in the file and keep the osm file data structure.

GPS

Loading GPS data in QGIS can be done using the core plugin: GPS Tools. Instructions are described in Section GPS Plugin.

GRASS

Working with GRASS vector data is described in Section GRASS GIS Integration.

SpatiaLite Layers

addSpatiaLiteLayer The first time you load data from a SpatiaLite database, begin by:

  • clicking on the addSpatiaLiteLayer Add SpatiaLite Layer toolbar button;
  • selecting the addSpatiaLiteLayer Add SpatiaLite Layer… option from the Layer ‣ Add Layer menu;
  • or by typing Ctrl+Shift+L.

This will bring up a window that will allow you either to connect to a SpatiaLite database already known to QGIS, which you can choose from the drop-down menu, or to define a new connection to a new database. To define a new connection, click on New and use the file browser to point to your SpatiaLite database, which is a file with a .sqlite extension.

QGIS also supports editable views in SpatiaLite.

QGIS Custom formats

QGIS proposes two custom formats you can load in the application using their own loading tool:

Connecting to web services

With QGIS you can have access to different types of OGC web services (WM(T)S, WFS(-T), CSW …). Thanks to QGIS Server, you can also publish these services. Description of these capabilities and how-to are provided in chapter Working with OGC Data.