33,59 €
Learn to view, edit and analyse geospatial data using QGIS and Python 3
QGIS 3.4 is the first LTR (long term release) of QGIS version 3. This is a giant leap forward for the project with tons of new features and impactful changes. Learn QGIS is fully updated for QGIS 3.4, covering its processing engine update, Python 3 de-facto coding environment, and the GeoPackage format.
This book will help you get started on your QGIS journey, guiding you to develop your own processing pathway. You will explore the user interface, loading your data, editing, and then creating data. QGIS often surprises new users with its mapping capabilities; you will discover how easily you can style and create your first map. But that’s not all! In the final part of the book, you’ll learn about spatial analysis and the powerful tools in QGIS, and conclude by looking at Python processing options.
By the end of the book, you will have become proficient in geospatial analysis using QGIS and Python.
If you are a developer or consultant familiar with the basic functions and processes of GIS and want to learn how to use QGIS to analyze geospatial data and create rich mapping applications, this book is for you. You’ll also find this book useful if you’re new to QGIS and wish to grasp its fundamentals
Andrew Cutts is a Geospatial freelancer based in West Sussex, UK. He has almost 20 years industry experience across several sectors. He holds a degree in Geography and a Masters in GIS (awarded in 2002). Andrew consults for clients worldwide and gives training in Geospatial technology, themes include Python, GIS and Earth Observation. Andrew writes extensively on the topic of Geospatial technology on his blog www.acgeospatial.co.uk and is the co-host of the scenefromabove podcast. You can follow him on Twitter @map_andrew. Anita Graser is a spatial data scientist, open source GIS advocate, and author with a background in geographic information science. She is currently working with the Center for Mobility Systems at the Austrian Institute of Technology in Vienna and teaching QGIS classes at UNIGIS Salzburg. She serves on the QGIS project steering committee. and has published several books about QGIS. Furthermore, she develops tools, such as the Time Manager plugin for QGIS. You can follow her on Twitter @underdarkGIS.Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 175
Veröffentlichungsjahr: 2018
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor:Richa TripathiAcquisition Editor: Prachi BishtContent Development Editor: Anugraha ArunagiriTechnical Editor: Aniket IswalkarCopy Editor: Safis EditingProject Coordinator: Ulhas KambaliProofreader: Safis EditingIndexer: David Punnoose MuthukadenGraphics: Tania DuttaProduction Coordinator: Shraddha Falebhai
First published: September 2013 Second Edition: December 2014Third Edition: March 2016 Fourth Edition: November 2018
Production reference: 1221118
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78899-742-3
www.packtpub.com
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Andrew Cutts is a Geospatial freelancer based in West Sussex, UK. He has almost 20 years industry experience across several sectors. He holds a degree in geography and a masters, in GIS (awarded in 2002). Andrew consults for clients worldwide and gives training in Geospatial technology. The themes covered include Python, GIS, and Earth Observation. Andrew writes extensively on the topic of Geospatial technology on his blog (www.acgeospatial.co.uk) and is the co-host of the #scenefromabove podcast. You can follow him on Twitter at @map_andrew.
Anita Graser is a spatial data scientist, open source GIS advocate, and author, with a background in geographic information science. She is currently working with the Center for Mobility Systems at the Austrian Institute of Technology in Vienna and teaching QGIS classes at UNIGIS Salzburg. She serves on the QGIS project steering committee and has published several books about QGIS. She also develops tools, including the Time Manager plugin for QGIS. You can follow her on Twitter at @underdarkGIS.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Learn QGIS Fourth Edition
Dedication
About Packt
Why subscribe?
Packt.com
Contributors
About the authors
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Where Do I Start?
Installing QGIS 3.4
Installing QGIS on Windows
Installing QGIS using the OSGeo4W installer
Latest QGIS release
Advanced installer (to specify version)
Installing on Ubuntu
Running QGIS for the first time
Plugins
What is new in QGIS 3
Introducing the QGIS user interface
Menu bar
Toolbars
Information bar
Layers and browser panels
Map
Finding help and reporting issues
Summary
Data Creation and Editing
Data formats
GeoPackage
Loading data
Getting data into QGIS
Interacting with data
Navigation
Data attributes toolbar
Inspecting the data
Measuring data
Selecting data
Vector data
Editing attribute data
Building your own vector data
Projections
Creating data
Create a ShapeFile
Editing tools
Snapping
Mistakes and correcting with editing
Populating attribute data
Data joins
Using temporary scratch layers
Checking for topological errors and fixing them
Finding errors with the Topology Checker
Fixing invalid geometry errors
Raster data
Other data
Creating a GeoPackage
Exporting to a different format
Spatial Databases
Summary
Visualizing Data
Styling data
Interactive styling
Styling raster layers
Layer styling – Terrain
Layer styling – satellite image
Raster Toolbar
Styling data – landcover map
Saving styles
Styling vector layers
Creating point styles – an example of an airport style
Simple marker
SVG
Default symbols
Creating line styles – an example of a river
Creating polygon styles – an example of a landmass style
Summary
Creating Great Maps
Communicating with data
Labeling
Interactively editing labels
Displaying more information using labels
Line labels
Polygon labels
Creating a map
Loading data
Adding layout items
Add a title (or any text)
Further map creation options
Adding Grids
Adding an overview map
Adding an attribute table
Map outputs
Saving maps to share
Creating an Atlas
Presenting Maps online
Exporting a web map
QGIS2Web – an excellent way to export your data in openlayers or leaflet
Exporting a 3D web map
Summary
Spatial Analysis
Processing toolbox
Analyzing raster data
Clipping rasters
Analyzing elevation/terrain data
Terrain projections – slope maps
Using the raster calculator
Combining raster and vector data
Converting between rasters and vectors
Raster to vector
Vector to raster
Accessing raster and vector layer statistics
Computing zonal statistics
Creating a heatmap from points
Advanced vector and raster analysis with processing
Finding nearest neighbors
Converting between points, lines, and polygons
Building workflows with processing tools
Identifying features in the proximity of other features
Sampling a raster at point locations
Mapping density with hexagonal grids
Calculating area shares within a region
Batch processing multiple datasets
Automated geoprocessing with the graphical modeler
Create a model that automates the creation of hexagonal heatmaps
Documenting and sharing models
Summary
Extending QGIS with Python
Adding functionality using actions
Configuring your first Python action
Opening files using actions
Opening a web browser using actions
Getting to know the Python console
Loading and exploring datasets – vector data
Loading and exploring datasets – raster data
Styling layers
Filtering data
Creating a memory layer
Exporting map images
Creating custom geoprocessing scripts using Python
Writing your first processing script
Building a basic buffer script
Running the script
Extending the script
Developing your first plugin
Creating the plugin template with Plugin Builder
Accessing qgis.core from the command line external to Python
Setting up the pb_tool
Assigning a logo to the plugin
Customizing the plugin GUI
Implementing plugin functionality
Adding a message box when OK is clicked
3D view
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
QGIS is a user-friendly, open source Geographic Information System (GIS) that runs on Linux, Unix, macOS, and Windows. The popularity of open source GIS, and QGIS in particular, has been growing rapidly over the last few years.
This book will take you, as a new user, on a journey from the first time you fire up QGIS, all the way through to being on the cusp of developing your own processing pathway. We will travel together through familiarization with the user interface, loading some data, editing it, and then creating data. QGIS often surprises new users with its mapping capabilities. We will unlock these doors by looking at styling and creating your first map. And that is not all! Learning about spatial analysis and the powerful tools in QGIS will form the final part of this introductory book, before we end our journey by looking at the Python processing options.
This book is for users, developers, and consultants who know the basic functions and processes of GIS and want to learn how to use QGIS to analyze geospatial data and create rich mapping applications.
Chapter 1, Where Do I Start?, covers the installation of QGIS 3.4, major changes since QGIS 2.x, UI, and getting help.
Chapter 2, Data Creation and Editing, covers data formats, loading data, interacting with it, and vector and raster data.
Chapter 3, Visualizing Data, explains how to interactively style vector and raster GIS data.
Chapter 4, Creating Great Maps, covers the labeling of data, creating maps, and map outputs.
Chapter 5, Spatial Analysis, explains the Processing Toolbox, spatial analysis of vector and raster data, batch processing, and modeling.
Chapter 6, Extending QGIS with Python, covers actions, the Python console, plugins, and 3D applications.
We will cover installation in Chapter 1, Where Do I Start. This book steps through the basic tasks of QGIS 3.4 through to the advanced topics, such as Python programming. To get the most from this book, it is recommended to follow the chapters in sequence.
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packt.com
.
Select the
SUPPORT
tab.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learn-QGIS-Fourth-Edition. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781788997423_ColorImages.pdf.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.
Welcome to QGIS. There has never been a better time to start using QGIS, you have made a great choice! You may have already started using QGIS 3.4, you may have experience with older versions, or you may be familiar with other GIS software. No matter where you are on your learning journey, the first time you install any software can be a little daunting.
This chapter is all about getting a feel for the software, building your confidence, and developing the urge to explore. By the end of this chapter, you will grasped some of the basic ideas and concepts.You will be in the perfect position to begin working with data, designing and styling it, and working toward creating a map.
In this chapter, we will cover the following topics:
Installing QGIS
What has changed since QGIS 2.x?
Toolbars and GUI
Getting help
Setting up
Community of users
QGIS runs on all operating systems; it is even possible to install it on a Raspberry Pi. The QGIS project provides ready-to-use packages as well as instructions to build from source code at http://download.qgis.org. Here, we will cover how to install QGIS on two systems: Windows and Ubuntu.
Like many other open source projects, QGIS offers you a choice between different releases. For the tutorials in this book, we will use the QGIS 3.4 long term release (LTR) version. We recommend installing this version in order to follow this book with ease. As you build familiarity and confidence, you may wish to work with different versions. The core QGIS functionality generally remains the same. Newer versions will include the latest release (LR), which is normally updated every four months, or the developer version (DEV) for which you can get nightly builds, if needed. While exciting, the DEV version should not be relied on for anything other than testing or inspecting new features.
On Windows, we have two different options for installing QGIS. These are the OSGeo4W and the standalone installer.
The OSGeo4W installer is a small, flexible installation tool that makes it possible to download and install QGIS and many more OSGeo tools with all their dependencies. The main advantage of this installer over the standalone installer is that it makes updating QGIS and its dependencies very easy. I recommend that you use OSGeo4W where practical. You can download the 32-bit and/or the 64-bit OSGeo4W installers from http://osgeo4w.osgeo.org . You can download directly from http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe for the 32-bit version. If you have a 64-bit version of Windows, you can also download from http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe. Download the version that matches your operating system and keep it. In the future, whenever you want to change or update your system, just run it again.
If you prefer, you can use the standalone installer. This is one file to download (approximately 400 MB in size). It contains a QGIS release, the Geographic Resources Analysis Support System (GRASS) GIS, and the System for Automated Geoscientific Analyses (SAGA) GIS in one package. For a beginning, this is the easiest installation option.
In this section, we will focus on installing QGIS using the OSGeo4W installer. This is a convenient way to install QGIS and a host of other open source GIS tools.
Start by double-clicking on OSGeo4W executable. This will lead you to the following screenshot:
Select the Express Desktop Install radio button. This may not install QGIS 3.4. If you wish to specify a version, please see the next section on Advanced Installers. The Advanced Install radio button is useful if you want to customize your installation, or choose your installation version or perhaps by install the development version of QGIS:
Accept the defaults and click on the Next button. This will set off the download process. Progress will be displayed as each component is downloaded. Having these installed will provide you with more tools to perform Geospatial analysis. After a short period of time, you should see OSGeo4W in your programs menu along with all the other installed software, similar to the following screenshot:
If QGIS is appearing in your programs menu, then it is now installed on your machine.
Select the radio button next to Advanced Install, as shown in the following screenshot:
Step through the installation wizard. When you get to the Select Packages, choose the version you require. In the following screenshot I have selected the 3.4.0-1 release:
You can select other packages if required. Once you have chosen the software, click on the Next button. Step through the wizard by accepting the defaults and the installation will begin.
On Ubuntu, the QGIS project provides packages for the LTR, LR, and DEV versions. For this book, we recommend installing the LTR version of 3.4 if available (release date: February 2019).
To avoid conflicts that may occur due to incompatible packages, make sure that you only add one of the following package source options. The specific lines that you have to add to the source list depend on your Ubuntu version. The following version is latest release for Debian stretch:
deb
https
:
//
qgis
.
org
/
debian
stretch
main
deb
-
src
https
:
//
qgis
.
org
/
debian
stretch
main
After choosing the repository, we will add the qgis.org repository's public key to our apt keyring. This will avoid the warnings that you might otherwise get when installing from a non-default repository. Run the following command in the terminal:
wget -O - https://qgis.org/downloads/qgis-2017.gpg.key | gpg --import
gpg --fingerprint CAEB3DC3BDF7FB45
gpg --export --armor CAEB3DC3BDF7FB45 | sudo apt-key add -
Finally, to install QGIS, run the following commands. The first will fetch any updates to packages on your system, and the second will install QGIS, the python library, and the grass plugins:
sudo apt-get update
sudo apt-get install qgis python-qgis qgis-plugin-grass
In recent years, QGIS has become the most popular open source desktop GIS software. Some people are using it just
