Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering  QGIS

You're reading from   Mastering QGIS Go beyond the basics and unleash the full power of QGIS with practical, step-by-step examples

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781786460370
Length 486 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (5):
Arrow left icon
John Van Hoesen, GISP John Van Hoesen, GISP
Author Profile Icon John Van Hoesen, GISP
John Van Hoesen, GISP
Kurt Menke, GISP Kurt Menke, GISP
Author Profile Icon Kurt Menke, GISP
Kurt Menke, GISP
Paolo Corti Paolo Corti
Author Profile Icon Paolo Corti
Paolo Corti
Richard Smith Jr., GISP Richard Smith Jr., GISP
Author Profile Icon Richard Smith Jr., GISP
Richard Smith Jr., GISP
Luigi Pirelli Luigi Pirelli
Author Profile Icon Luigi Pirelli
Luigi Pirelli
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. A Refreshing Look at QGIS FREE CHAPTER 2. Creating Spatial Databases 3. Styling Raster and Vector Data 4. Preparing Vector Data for Processing 5. Preparing Raster Data for Processing 6. Advanced Data Creation and Editing 7. Advanced Data Visualization 8. The Processing Toolbox 9. Automating Workflows with the Graphical Modeler 10. Creating QGIS Plugins with PyQGIS and Problem Solving 11. PyQGIS Scripting Index

Loading data into QGIS Desktop

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 Add Layer menu under Layer and select the appropriate type of data that 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 onto the map display or onto 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 that you wish to load. The fourth way is to locate the data in QGIS Browser, drag the data, and drop it onto the QGIS Desktop map display or the Layers panel.

Loading vector data

To load vector files, click on Add Vector Layer by navigating to Layer | Add Layer. This will open the Add Vector Layer dialog that will allow us to choose the source type and the source of the dataset that we wish to load.

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

  • File: This can load flat files that are stored on disk. The commonly used flat file types are as follows:
    • ESRI shapefile (.shp)
    • GeoJSON (.geojson)
    • Geography Markup Language (.gml)
    • AutoCAD DXF (.dxf)
    • Comma separated values (.csv)
    • GPS eXchange Format (.gpx)
    • Keyhole Markup Language (.kml)
    • SQLite/SpatiaLite (.sqlite/.db)
  • Directory: This can load data stored on disk that is encased in a directory. The commonly used directory types are as follows:
    • U.S. Census TIGER/Line
    • Arc/Info Binary Coverage
  • Database: This can load databases that are stored on disk or those available through service connections. The commonly used database types are as follows:
    • ODBC
    • ESRI Personal GeoDatabase
    • MSSQL
    • MySQL
    • PostgreSQL
  • Protocol: This can load protocols that are available at a specific URI. QGIS currently supports loading the GeoJSON and CouchDB protocols.

Loading raster data

To load raster data into QGIS, click on Add Raster Layer by navigating to Layer | Add Layer. This will open a file browser window and allow you to choose a GDAL-supported raster file. The commonly used raster types supported by GDAL are as follows:

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

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

Note

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, uses 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 Simple Features Library references the vector processing parts of GDAL. OGR is not really a standalone 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 OSGeo (http://osgeo.org) project.

Loading databases

QGIS supports PostGIS, SpatiaLite, Microsoft SQL Server, 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 on Add Layer under Layer and then choose the database type you wish to load. This will open a window with options for adding the data stored in a database. As an example, the following screenshot shows the window that opens when you navigate to Layer | Add Layer | Add SpatiaLite Layer:

Loading databases

Tip

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

To load data from a database, we must first create a connection to the database. To create a new connection, click on 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 drop-down list and click on Connect; you will see a list of all layers contained within the database display. If there are 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 and click on Add. If you only wish to load a portion of the layer, select the layer and then click on Set Filter to open the query builder. If you set a query and then add the layer, only the filtered features will be added.

Loading 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 that you must first set up the connection to the service, then connect to the service to choose which layers to add to the map canvas.

As an example, to add a WMS service, click Layer | Add Layer | Add WMS/WMTS Layer. On the window that appears, click New to open the Create a new WMS connection window (shown in the following figure) where you can define the parameters of the new service. Enter a Name for the service, the URL of the service, set any of the remaining options that may apply, and then click OK to add the service as an available connection.

Loading web services

With the new service added, make sure it is selected, then click Connect to connect to the service, and list the available layers. To add a layer to the map canvas, select it, choose the Image encoding, Coordinate Reference System, and Layer name, and then click Add.

Tip

Some services support multiple CRS. After connecting to a service, select a layer and then click Change to choose the coordinate system to use.

You have been reading a chapter from
Mastering QGIS - Second Edition
Published in: Sep 2016
Publisher: Packt
ISBN-13: 9781786460370
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image