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
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 2. Creating Spatial Databases FREE CHAPTER 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

Exploring iface and QGis


The iface class used in the preceding snippets is important in every PyQGIS code; it is used to access most graphical QGIS components, from displayed layers to the toolbar buttons.

Note

The iface class is a Python wrapper for the C++ class, QgisInterface, which is documented at http://qgis.org/api/classQgisInterface.html. Most QGIS classes have a Qgs prefix. Some special classes can have the Qgis or QGis prefixes.

The prefix Qgs is the Qt namespace registered by Gary Sherman, the QGIS creator, so Qt (Q) and Gary Sherman (gs).

The most common use of the iface class is to get a reference of the canvas where maps are displayed:

canvas = iface.mapCanvas()

The class can also be used as a shortcut to load raster or vector layers; for example loading the raster, path/to/my/raster.tif, and naming it myraster in the legend panel. This can be done by typing the following command:

iface.addRasterLayer("path/to/my/raster.tif", "myraster")

Note

Pay attention to writing paths with Windows...

lock icon The rest of the chapter is locked
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