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 Mar 2015
Publisher
ISBN-13 9781784398682
Length 420 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (12) 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. The Processing Toolbox 8. Automating Workflows with the Graphical Modeler 9. Creating QGIS Plugins with PyQGIS and Problem Solving 10. PyQGIS Scripting Index

Loading data

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 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 type 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)
    • 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 protocol.

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 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, 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 is short for OGR Simple Features Library and 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 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 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

Note

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.

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.

You have been reading a chapter from
Mastering QGIS
Published in: Mar 2015
Publisher:
ISBN-13: 9781784398682
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