You are previewing QGIS 2 Cookbook.
O'Reilly logo
QGIS 2 Cookbook

Book Description

Become a QGIS power user and master QGIS data management, visualization, and spatial analysis techniques

About This Book

  • Explore and create time-based visualizations and build interactive maps

  • Maximize your use of the QGIS features, plugins and toolbox automation

  • Packed with lots of sample datasets to enable a better understanding of the code

  • Who This Book Is For

    If you are an intermediate GIS user, with either previous experience in QGIS or any other GIS application, this is the book for you. The recipes can be used to learn more advanced techniques in QGIS or to replicate the functionalities equivalent to other GIS platforms. This book assumes that you already have a working QGIS system in place.

    What You Will Learn

  • Import and export common tricky spatial data formats

  • Perform classic vector and raster analysis with QGIS

  • Utilize spatial databases and data management tools

  • Use and create geographic web services and maps

  • Explore and create time-based visualizations

  • Perform network building and routing analysis

  • Extend QGIS capabilities with popular plugins and toolbox automation

  • Make beautiful and unique maps with customized cartography

  • In Detail

    QGIS is a user-friendly, cross-platform desktop geographic information system used to make maps and analyze spatial data. QGIS allows users to understand, question, interpret, and visualize spatial data in many ways that reveal relationships, patterns, and trends in the form of maps. This book is a collection of simple to advanced techniques that are needed in everyday geospatial work, and shows how to accomplish them with QGIS. You will begin by understanding the different types of data management techniques, as well as how data exploration works. You will then learn how to perform classic vector and raster analysis with QGIS, apart from creating time-based visualizations. Finally, you will learn how to create interactive and visually appealing maps with custom cartography. By the end of this book, you will have all the necessary knowledge to handle spatial data management, exploration, and visualization tasks in QGIS.

    Style and approach

    This book covers practical examples, with step-by-step instructions on how to use real world data covering common GIS operations and the different analysis techniques. It provides detailed explanations and applications of QGIS concepts that will allow the user to effectively analyze spatial data.

    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 http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. QGIS 2 Cookbook
      1. Table of Contents
      2. QGIS 2 Cookbook
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why Subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Data Input and Output
        1. Introduction
        2. Finding geospatial data on your computer
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Adding layers with the Layer menu
            2. Adding a folder to Favorites
            3. Nonfile data sources
        3. Describing data sources
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Importing data from text files
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        5. Importing KML/KMZ files
          1. How to do it…
          2. How it works…
          3. There's more…
        6. Importing DXF/DWG files
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Opening DWG files
        7. Opening a NetCDF file
          1. How to do it…
          2. How it works…
          3. There's more…
            1. The NetCDF Browser plugin
        8. Saving a vector layer
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Fine-tuning the export operation
            2. Opening the layer after creating it
        9. Saving a raster layer
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        10. Reprojecting a layer
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        11. Batch format conversion
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        12. Batch reprojection
          1. How to do it…
          2. How it works…
          3. There's more…
        13. Loading vector layers into SpatiaLite
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        14. Loading vector layers into PostGIS
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      9. 2. Data Management
        1. Introduction
        2. Joining layer data
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Cleaning up the attribute table
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Configuring relations
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Joining tables in databases
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Creating views in SpatiaLite
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Creating views in PostGIS
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Creating spatial indexes
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Georeferencing rasters
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        10. Georeferencing vector layers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        11. Creating raster overviews (pyramids)
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        12. Building virtual rasters (catalogs)
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      10. 3. Common Data Preprocessing Steps
        1. Introduction
        2. Converting points to lines to polygons and back – QGIS
          1. Getting ready
          2. How to do it…
            1. Converting points to lines (or polygons)
            2. Converting lines to polygons
            3. Converting polygons to lines
            4. Converting polygons or lines to points
          3. How it works…
          4. There's more…
        3. Converting points to lines to polygons and back – SpatiaLite
          1. Getting ready
          2. How to do it…
            1. Points to lines
            2. Lines to polygons
          3. How it works…
          4. There's more…
          5. See also
        4. Converting points to lines to polygons and back – PostGIS
          1. Getting ready
          2. How to do it…
            1. Converting points to lines
            2. Converting lines to polygons
            3. Converting lines or polygons to points
          3. How it works…
          4. There's more…
          5. See also
        5. Cropping rasters
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Clipping vectors
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Extracting vectors
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Converting rasters to vectors
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Converting vectors to rasters
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        10. Building DateTime strings
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        11. Geotagging photos
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      11. 4. Data Exploration
        1. Introduction
        2. Listing unique values in a column
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Exploring numeric value distribution in a column
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. See also
        4. Exploring spatiotemporal vector data using Time Manager
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Creating animations using Time Manager
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Designing time-dependent styles
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Loading BaseMaps with the QuickMapServices plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Loading BaseMaps with the OpenLayers plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Viewing geotagged photos
          1. Getting ready
          2. How to do it…
            1. Going a little further
          3. How it works…
          4. There's more…
          5. See also
      12. 5. Classic Vector Analysis
        1. Introduction
        2. Selecting optimum sites
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Dasymetric mapping
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Calculating regional statistics
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Estimating density heatmaps
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Estimating values based on samples
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      13. 6. Network Analysis
        1. Introduction
        2. Creating a simple routing network
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Calculating the shortest paths using the Road graph plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Routing with one-way streets in the Road graph plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Calculating the shortest paths with the QGIS network analysis library
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. Routing point sequences
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Automating multiple route computation using batch processing
          1. Getting ready
          2. How to do it…
        8. Matching points to the nearest line
          1. Getting ready
          2. How to do it…
          3. How it works…
        9. Creating a routing network for pgRouting
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        10. Visualizing the pgRouting results in QGIS
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        11. Using the pgRoutingLayer plugin for convenience
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        12. Getting network data from the OSM
          1. Getting ready
          2. How to do it…
          3. How it works…
      14. 7. Raster Analysis I
        1. Introduction
        2. Using the raster calculator
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Preparing elevation data
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Calculating a slope
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Using a ratio for elevation values
            2. Other slope algorithms
            3. Calculating the slope
          5. See also
        5. Calculating a hillshade layer
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Enhancing your map view with a hillshade layer
        6. Analyzing hydrology
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Calculating a topographic index
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        8. Automating analysis tasks using the graphical modeler
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      15. 8. Raster Analysis II
        1. Introduction
        2. Calculating NDVI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Extracting bands
        3. Handling null values
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Controlling the rendering of null values
        4. Setting extents with masks
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Restricting analysis to a given area
            2. Removing superfluous no-data values
            3. Masking using a vector mask
        5. Sampling a raster layer
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Other raster-vector data transfer operations
        6. Visualizing multispectral layers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Modifying and reclassifying values in raster layers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Reclassifying into classes of equal amplitude
            2. Reclassifying into classes of equal area
          5. See also
        8. Performing supervised classification of raster layers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      16. 9. QGIS and the Web
        1. Introduction
        2. Using web services
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Using WFS and WFS-T
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Searching CSW
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Using WMS and WMS Tiles
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Using WCS
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Using GDAL
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Serving web maps with the QGIS server
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Scale-dependent rendering
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        10. Hooking up web clients
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        11. Managing GeoServer from QGIS
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Editing a remote style
            2. Support for multiple formats
          5. See also
      17. 10. Cartography Tips
        1. Introduction
        2. Using Rule Based Rendering
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Handling transparencies
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Understanding the feature and layer blending modes
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Saving and loading styles
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Configuring data-defined labels
          1. Getting ready
          2. How to do it…
            1. Example: moving and rotating a label
          3. How it works…
          4. There's more…
        7. Creating custom SVG graphics
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Making pretty graticules in any projection
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Making useful graticules in printed maps
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        10. Creating a map series using Atlas
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
      18. 11. Extending QGIS
        1. Introduction
        2. Defining custom projections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Working near the dateline
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Working offline
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Using the QspatiaLite plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Adding plugins with Python dependencies
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Using the Python console
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Writing Processing algorithms
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Writing QGIS plugins
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Creating plugins with more complex UI elements
            2. Documenting you plugin
            3. Releasing your plugin
        10. Using external tools
          1. Getting ready
          2. How to do it…
            1. GPSBabel
            2. spatialite-gui
            3. pgAdmin
          3. How it works…
          4. There's more…
      19. 12. Up and Coming
        1. Introduction
        2. Preparing LiDAR data
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Opening File Geodatabases with the OpenFileGDB driver
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Using Geopackages
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. The PostGIS Topology Editor plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. The Topology Checker plugin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. GRASS Topology tools
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Hunting for bugs
          1. Getting ready
          2. How to do it…
            1. Creating a backtrace under Linux
            2. Capturing debug output with DebugView under Windows
          3. How it works…
          4. There's more…
          5. See also
        9. Reporting bugs
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      20. Index