You are previewing Building Mapping Applications with QGIS.
O'Reilly logo
Building Mapping Applications with QGIS

Book Description

Create your own sophisticated applications to analyze and display geospatial information using QGIS and Python

In Detail

QGIS is one of the premiere open source Geographical Information Systems. While developing Python geospatial applications can be challenging, QGIS simplifies the process by combining the necessary geoprocessing libraries with a sophisticated user interface, all of which can be directly controlled using Python code.

Starting with an introduction to QGIS and how to use the built-in QGIS Python Console, we will teach you how to write Python code that makes use of the geospatial capabilities of QGIS. Building on this, you will ultimately learn how to create your own sophisticated standalone mapping applications built on top of QGIS. You will learn how to use the Python Console as a window into the QGIS programming environment, and then use that environment to create your own Python scripts and plugins to customize QGIS. As your knowledge of the PyQGIS library grows, you will use it to perform a variety of real-world geospatial programming tasks, culminating in the creation of your own complex standalone applications to load, analyze, and display geospatial data.

What You Will Learn

  • Use the Python Console to explore and control QGIS
  • Perform geospatial development tasks using the PyQGIS Python library
  • Create useful geospatial applications implemented as QGIS Python plugins
  • Use QGIS as a standalone geoprocessing library within your Python programs
  • Build complex interactive map-based GUIs within your own Python programs
  • Understand how Python scripting can be used to customize the QGIS system
  • Utilize the true potential of Python and QGIS to create your own complete mapping applications
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Building Mapping Applications with QGIS
      1. Table of Contents
      2. Building Mapping Applications with QGIS
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Getting Started with QGIS
        1. About QGIS
          1. Installing and running QGIS
          2. Understanding QGIS concepts
        2. Linking QGIS and Python
          1. Exploring the Python Console
          2. Examining a Python plugin
          3. Writing an external application
        3. Summary
      9. 2. The QGIS Python Console
        1. Using the console
        2. Working with geospatial data in the console
        3. Scripting the QGIS user interface
          1. The status bar
          2. The message bar
          3. Progress indicators
          4. QGIS logging
          5. Custom dialogs and windows
        4. Summary
      10. 3. Learning the QGIS Python API
        1. About the QGIS Python APIs
        2. Deciphering the C++ documentation
        3. Organizing the QGIS Python libraries
          1. The qgis.core package
            1. Maps and map layers
            2. Coordinate reference systems
            3. Vector layers
              1. Displaying vector data
              2. Accessing vector data
              3. Spatial indexes
            4. Raster layers
              1. How raster data is displayed
              2. Accessing raster data
            5. Other useful qgis.core classes
          2. The qgis.gui package
            1. The QgisInterface class
            2. The QgsMapCanvas class
            3. The QgsMapCanvasItem class
            4. The QgsMapTool class
            5. Other useful qgis.gui classes
        4. Using the PyQGIS library
          1. Analyzing raster data
          2. Manipulating vector data and saving it to a shapefile
          3. Using different symbols for different features within a map
          4. Calculating the distance between two user-defined points
        5. Summary
      11. 4. Creating QGIS Plugins
        1. Getting ready
        2. Understanding the QGIS plugin architecture
        3. Creating a simple plugin
        4. The plugin development process
          1. Using the Plugin Builder
          2. Automating the build process
          3. Plugin help files
          4. Unit testing
          5. Distributing your plugin
        5. Writing a useful plugin
        6. Possibilities and limitations of plugins
        7. Summary
      12. 5. Using QGIS in an External Application
        1. Introducing Lex
        2. Getting the data
        3. Designing the application
        4. Creating the application's framework
        5. Adding the user interface
        6. Connecting the actions
        7. Creating the map canvas
        8. Labeling the points
        9. Filtering the landmarks
        10. Implementing the zoom tool
        11. Implementing the pan tool
        12. Implementing the explore mode
        13. Further improvements and enhancements
        14. Summary
      13. 6. Mastering the QGIS Python API
        1. Working with symbol layers
        2. Combining symbol layers
        3. Implementing symbol layers in Python
        4. Implementing renderers in Python
        5. Working with custom map layers
        6. Creating custom map canvas items
        7. Using memory-based layers
        8. Summary
      14. 7. Selecting and Editing Features in a PyQGIS Application
        1. Working with selections
        2. Using the layer editing mode
        3. Adding Points
        4. Editing Points
        5. Deleting Points and other features
        6. Adding lines and polygons
        7. Editing lines and polygons
        8. Summary
      15. 8. Building a Complete Mapping Application using Python and QGIS
        1. Introducing ForestTrails
        2. Designing the ForestTrails application
        3. Creating the application
          1. Laying out the application
          2. Defining the toolbar icons
          3. The module
          4. The module
          5. The module
          6. The module
          7. Running the application
        4. Obtaining the basemap
        5. Defining the map layers
        6. Defining the map renderers
        7. The Pan Tool
        8. Implementing the track editing mode
        9. Summary
      16. 9. Completing the ForestTrails Application
        1. The Add Track map tool
        2. Testing the application
        3. Vertex snapping
        4. The Edit Track map tool
        5. The Delete Track map tool
        6. The Get Info map tool
        7. The Set Start Point and Set End Point actions
        8. The Find Shortest Path action
        9. Adjusting the toolbar actions
        10. Suggested improvements
        11. Summary
      17. Index