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 GeoPackage, GML, GeoJSON, GPX, KML, Comma Separated Values, ESRI formats (Shapefile, Geodatabase…), MapInfo and MicroStation file formats, AutoCAD DWG/DXF, GRASS and many more… Read the complete list of supported vector formats.
  • Raster data formats include GeoTIFF, JPEG, ASCII Gridded XYZ, MBTiles, R or Idrisi rasters, GDAL Virtual, SRTM, Sentinel Data, ERDAS IMAGINE, ArcInfo Binary Grid, ArcInfo ASCII Grid, and many more… Read the complete list of supported raster formats.
  • Database formats include PostgreSQL/PostGIS, SQLite/SpatiaLite, Oracle, DB2 or MSSQL Spatial, MySQL…
  • Web map and data services (WM(T)S, WFS, WCS, CSW, XYZ tiles, ArcGIS services, …) are also handled by QGIS providers. See QGIS as OGC Data Client for more information about some of these.
  • You can read supported files from archived folders and use QGIS native formats such as QML files (QML - The QGIS Style File Format) and virtual and memory layers.

More than 80 vector and 140 raster formats are supported by GDAL 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 see the list of available formats, run the command line ogrinfo --formats (for vector) and gdalinfo --formats (for raster), or check settings ‣ Options ‣ GDAL menu (for raster) in QGIS.

In QGIS, depending on the data format, there are different tools to open a dataset, 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 open with the dataSourceManager Open Data Source Manager button, available on the Data Source Manager Toolbar, or by pressing Ctrl+L. 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 the 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 can be found in DB Manager Plugin.

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

This chapter will describe only the tools provided by default in QGIS for loading 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, databases, 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 on 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 for vector layers.

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

  • addLayer Add Selected Layers: you can also add data to 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 in figure_browser_panels. The comparison can be case-sensitive or not. It can also be set to:
    • Normal: show items containing the search text
    • Wildcard(s): fine tune the search using the ? and/or * characters to specify the position of the search text
    • 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, metadata for the selected item.

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

  • for a file or a table, display its metadata or open it in your project. Tables can even be renamed, deleted or truncated.
  • for a folder, bookmark it into your favourites or hide it from the browser tree. Hidden folders can be managed from the Settings ‣ Options ‣ Data Sources tab.
  • manage your spatial bookmarks: bookmarks can be created, exported and imported as XML files.
  • create a connection to a database or a web service.
  • refresh, rename or delete a schema.

You can also import files into databases or copy tables from one schema/database to another 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 tool for integrating and managing spatial database formats supported by QGIS (PostGIS, SpatiaLite, GeoPackage, Oracle Spatial, MSSQL, DB2, Virtual layers). 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 their structure and contents
  • preview tables of databases
  • add layers to the map canvas, either by double-clicking or drag-and-drop.
  • add layers to a database from the QGIS Browser or from another database
  • create SQL queries and add their output to the map canvas
  • create virtual layers

More information on DB Manager capabilities is found in DB Manager Plugin.

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

DB Manager dialog

Provider-based loading tools

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

Note

Some external plugins also provide 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 GML, ESRI Shapefile, Mapinfo and DXF layers), click on the 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 the Data Source Manager with the Vector tab active (Add Vector Layer Dialog), where you can check radioButtonOn File and click on the (browse) button. 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. This will bring up the Data Source Manager with the Raster tab active (Add Raster Layer Dialog), where you can check radioButtonOn File and click on the (browse) button.

    ../../../_images/addrasterlayerdialog.png

    Add Raster Layer Dialog

That will bring up a standard open file dialog (see figure_vector_open and figure_raster_open), which allows you to navigate the file system and load a supported data source. The pull-down menu at the bottom allows you to select a supported file format. Only formats that have been well tested appear in the list. Other formats can be loaded by selecting All files (the top item in the pull-down menu).

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

Open an OGR Supported Vector Layer Dialog

../../../_images/geotiffopendialog.png

Open a GDAL Supported Raster 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 datasets 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 vector 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 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. Some possible database types are ODBC, Esri Personal Geodatabase, MSSQL as well as PostgreSQL or MySQL .

    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 lets you select from the available tables, for example of PostGIS enabled databases.

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

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.

Loading a mesh layer

Mesh layers (currently .grb, .grb2, .bin, .grib, grib1, grib2, nc, 2dm, 3Di Results) can be loaded by clicking the addMeshLayer Mesh tab in the datasource manager. For further instructions, read Working with Mesh Data.

Importing a delimited text file

Delimited text files (e.g. .txt, .csv, .dat, .wkt) can be loaded using the tools described above. This way, they will show up as simple tables. Sometimes, delimited text files can contain coordinates / geometries that you could want to visualize. This is what addDelimitedTextLayerAdd Delimited Text Layer is designed for.

Click the dataSourceManager Open Data Source Manager icon to open the Data Source Manager 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, identifying fields and rows. To enable QGIS to correctly parse the file, it is important to select the right delimiter. You can specify a delimiter by choosing between:

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

Records and fields

Some other convenient options can be used for data recognition:

  • Number of header lines to discard: convenient when you want to avoid the first lines in the file in the import, either because those are blank lines or with another formatting.
  • checkboxFirst record has field names: values in the first line are used as field names, otherwise QGIS uses the field names 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: you can force decimal separator to be a comma.
  • 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, Y field, Z field (for 3-dimensional data) and M field (for the measurement dimension) if the layer is of point geometry type and contains such 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 as WKT: select the Geometry field containing the WKT geometry 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.

Beside 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 Add 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. This layer is the result of a query on the .csv source file (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 Browser Panel. You will be prompted to select the sublayers you would like to add to the project. Layers are added with random style properties.

Note

For DXF files containing several geometry types (point, line and/or polygon), the name of the layers will be generated as <filename.dxf> entities <geometry type>.

To keep the dxf/dwg file structure and its symbology in QGIS, you may want to use the dedicated Project ‣ Import/Export ‣ Import Layers from DWG/DXF… tool which allows you to:

  1. import elements from the drawing file into a GeoPackage database.
  2. add imported elements to the project.

In the DWG/DXF Import dialog, to import the drawing file contents:

  1. Input the location of the Target package, i.e. the new GeoPackage file that will store the data. If an existing file is provided, then it will be overwritten.
  2. Specify the coordinate reference system of the data in the drawing file.
  3. Check checkbox Expand block references to import the blocks in the drawing file as normal elements.
  4. Check checkbox Use curves to promote the imported layers to a curved geometry type.
  5. 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 file, this can take some time.

After the .dwg or .dxf data has been 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 the layers will resemble the look they originally had in *CAD.
  3. Choose if the layer should be visible at opening.
  4. Checking the checkbox Merge layers option places all layers in a single group.
  5. Press OK to open the layers in QGIS.
../../../_images/dwg_dxf_import_dialog.png

Import dialog for DWG/DXF files

Importing OpenStreetMap Vectors

The OpenStreetMap project is popular 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 and local knowledge. To support this objective, QGIS provides support for OSM data.

Using the Browser Panel, you can load an .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 .osm file, and keep the osm file data structure.

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 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.

GPS

Loading GPS data in QGIS can be done using the core plugin GPS Tools. Instructions are found in section GPS Plugin.

GRASS

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

QGIS Custom formats

QGIS proposes two custom formats:

QLR - QGIS Layer Definition File

Layer definitions can be saved as a Layer Definition File (QLR - .qlr) using Export ‣ Save As Layer Definition File… in the layer context menu.

The QLR format makes it possible to share “complete” QGIS layers with other QGIS users. QLR files contain links to the data sources and all the QGIS style information necessary to style the layer.

QLR files are shown in the Browser Panel and can be used to add layers (with their saved styles) to the Layers Panel. You can also drag and drop QLR files from the system file manager into the map canvas.

Connecting to web services

With QGIS you can get access to different types of OGC web services (WM(T)S, WFS(-T), WCS, CSW, …). Thanks to QGIS Server, you can also publish such services. Chapter Working with OGC Data contains descriptions of these capabilities.

Using XYZ Tile services

XYZ Tile services can be found in the XYZ Tiles top level entry in the Browser. By default, the OpenStreetMap XYZ Tile service is configured. You can add other services that use the XYZ Tile protocol by choosing New Connection in the XYZ Tiles context menu (right-click to open). figure_xyz_tiles_openstreetmap shows the dialog with the OpenStreetMap XYZ Tile service configuration.

../../../_images/xyz_tiles_dialog_osm.png

XYZ Tiles - OpenStreetMap configuration

Configurations can be saved (Save Connections) to XML and loaded (Load Connections) through the context menu. The XML file for OpenStreetMap looks like this:

<!DOCTYPE connections>
<qgsXYZTilesConnections version="1.0">
  <xyztiles url="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
   zmin="0" zmax="19" password="" name="OpenStreetMap" username=""
   authcfg="" referer=""/>
</qgsXYZTilesConnections>

Layer Properties… in the connection’s context menu opens a dialog where you can get a preview of the service in the Preview tab.

Authentication configuration is supported.

Examples of XYZ Tile services: