Building mapping applications with QGIS create your own sophisticated applications to analyze and display geospatial information using QGIS and Python Westra - Download the full ebook version right now
Building mapping applications with QGIS create your own sophisticated applications to analyze and display geospatial information using QGIS and Python Westra - Download the full ebook version right now
https://ebookultra.com/download/qgis-and-applications-in-territorial-
planning-1st-edition-nicolas-baghdadi/
https://ebookultra.com/download/pyqgis-programmer-s-guide-extending-
qgis-2-x-with-python-1st-edition-gary-sherman/
https://ebookultra.com/download/create-your-own-website-using-
wordpress-in-a-weekend-1st-edition-moore/
https://ebookultra.com/download/invent-your-own-computer-games-with-
python-early-access-al-sweigart/
Create Your Own Website 4th Edition Scott Mitchell
https://ebookultra.com/download/create-your-own-website-4th-edition-
scott-mitchell/
https://ebookultra.com/download/build-your-own-ajax-web-
applications-1st-edition-matthew-eernisse/
https://ebookultra.com/download/create-your-own-employee-handbook-a-
legal-and-practical-guide-lisa-guerin/
https://ebookultra.com/download/teaching-with-digital-video-watch-
analyze-create-1st-edition-glen-l-bull/
https://ebookultra.com/download/building-node-applications-with-
mongodb-and-backbone-1st-edition-mike-wilson/
Building mapping applications with QGIS create your
own sophisticated applications to analyze and display
geospatial information using QGIS and Python Westra
Digital Instant Download
Author(s): Westra, Erik
ISBN(s): 9781783984671, 1783984678
Edition: Online-Ausg
File Details: PDF, 5.59 MB
Year: 2014
Language: english
Building Mapping Applications
with QGIS
Erik Westra
BIRMINGHAM - MUMBAI
Building Mapping Applications with QGIS
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 author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be 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.
ISBN 978-1-78398-466-4
www.packtpub.com
Credits
Reviewers Proofreaders
David McDermott Cathy Cumberlidge
Pablo Pardo Ameesha Green
Heegu Park Sonia Sanghera
Christopher Wesson
Indexer
Commissioning Editor Monica Ajmera Mehta
Pramila Balan
Production Coordinator
Acquisition Editor Conidon Miranda
Sonali Vernekar
Cover Work
Content Development Editor Conidon Miranda
Rikshith Shetty
Technical Editor
Shruti Rawool
Copy Editors
Alfida Paiva
Vikrant Phadkay
About the Author
Erik Westra has been a professional software developer for over 25 years, and has
worked almost exclusively with Python for the past decade. Erik's early interest in
graphical user interface design led to the development of one of the most advanced
urgent courier dispatch systems used by messenger and courier companies
worldwide. In recent years, he has been involved in the design and implementation
of systems that match seekers and providers of goods and services across a range of
geographical areas. This work has included the creation of real-time geocoders and
map-based views of constantly changing data. He is based in New Zealand, and
works for companies worldwide.
I would like to thank Ruth, the love of my life, for all her support
and encouragement. I would also like to thank my two children,
Anneke and Oscar, for reminding me what is important in life.
About the Reviewers
His first GIS position was for a UK-based unaddressed mail company. He spent 18
months working with address data, promoting the use of GIS, redesigning delivery
maps, and creating Python scripts to automate common repetitive tasks.
He currently works in the GIS team for a local authority in the UK. Along with
working in GIS, he is the Local Land and Property Gazetteer Custodian and Street
Naming and Numbering Officer. In this role, he has expanded his knowledge of
database management, programming, and web GIS. He has also presented at the
QGIS South East user group, and was part of the panel at GeoUtilities London 2014.
I would like to thank James Rutter for allowing me the time to peer
review this book.
Pablo Pardo is a geographist from Spain. He has studied MSc in GIS, and
specialized in natural risk assessment, focusing his MSc thesis on open data quality.
He also received a certificate of higher education in software development.
After several years of working as a GIS technician, he is now starting his freelance
career, mixing GIS consulting with data analysis and programming.
This is the first book he has helped review. He likes open data, free software,
and geo stuff. You can find more about him at www.pablopardo.es.
A five-year work experience drove him to get a higher degree in business and
management, so he went to the Korean Advanced Institute of Science and
Technology for his MBA (Master's degree in Business Administration), and to the
University of Southern California for his MSBA (Master of Science in Business
Administration). During his time at two graduate schools, KAIST and USC, he
mainly focused on IT and the creative industry. His studies have given him great
opportunities to enhance his cooperation and management skills of various teams
and people, and his knowledge, along with this work experience, has driven him
to pursue successful IT business and efficient marketing strategies.
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.PacktPub.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.PacktPub.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.
TM
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
[ ii ]
Table of Contents
[ iii ]
Table of Contents
[ iv ]
Preface
As software applications become more and more a part of people's lives, the
concepts of location and space become more important. Developers are regularly
finding themselves having to work with location-based data. Maps, geospatial data,
and spatial calculations are increasingly becoming just another part of the everyday
programming repertoire.
A decade ago, geospatial concepts and development was limited to experts in the
Geographic Information Sciences. These people spent years working with maps
and the complex mathematics that underlie them. Often coming from a university
background, these specialists would spend years becoming familiar with a particular
Geographic Information System (GIS), and would make a career of using that system
to draw maps and process geospatial data.
While the ever-popular Google Maps meant that anyone can view and manipulate
a map, the more advanced custom display and processing of geospatial data was
still limited to those who used a professional GIS system. All this changed with
the advent of freely available (and often open source) tools for manipulating and
displaying geospatial data. Now, anybody can learn the necessary concepts and start
building their own mapping applications from scratch. Rather than being limited to
the minimal capabilities and restrictive licensing terms of Google Maps, developers
can now build their own mapping systems to meet their own requirements, and
there are no limits to what can be done.
While the necessary tools and libraries are freely available, the developer still needs
to put them together into a workable system. Often, this is a rather complex process
and requires a lot of understanding of geospatial concepts, as well as how to compile
the necessary wrappers and configure the tools to work on a particular computer.
Preface
Chapter 2, The QGIS Python Console, explores the QGIS Python Console window,
and explains how it acts as a useful tool while building your own custom mapping
applications. It also gives you a taste of what can be done with Python and QGIS,
and improves your confidence and familiarity with the QGIS environment.
Chapter 3, Learning the QGIS Python API, introduces the Python libraries available
for the QGIS Python developer, and shows how these libraries can be used to
work with geospatial data and create useful and interesting maps based on
your geospatial data.
Chapter 4, Creating QGIS Plugins, introduces the concept of a QGIS plugin, and
explains how to write a plugin using Python. We take an in-depth look at how
plugins work, and how to create a useful geospatial application as a QGIS plugin.
We also look at the possibilities and limitations of QGIS plugins.
Chapter 6, Mastering the QGIS Python API, delves once more into the PyQGIS library,
looking at some more advanced aspects of this library, as well as various techniques
for working with QGIS using Python.
Chapter 7, Selecting and Editing Features in a PyQGIS Application, looks at how Python
programs built using PyQGIS can allow the user to select, add, edit, and delete
geospatial features within a map interface.
[2]
Preface
Chapter 8, Building a Complete Mapping Application Using Python and QGIS, covers the
process of designing and building a complete turnkey mapping application called
"ForestTrails". You will design the application, implement the overall user interface,
and construct a suitable high-resolution basemap for use by the application.
Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.
[3]
Preface
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"This uses the QGIS_PREFIX environment variable we set earlier to tell QGIS where
to find its resources."
viewer = MapViewer("/path/to/shapefile.shp")
viewer.show()
app.exec_()
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
def unload(self):
self.iface.removePluginMenu("Test Plugin", self.action)
self.iface.removeToolBarIcon(self.action)
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "If you
haven't already installed QGIS, click on the Download Now button on the main
QGIS web page to download the QGIS software."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.
[4]
Preface
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.
[5]
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.
Getting Started with QGIS
This chapter provides an overview of the QGIS system and how you can work
with it using the Python programming language. In particular, this chapter will
cover the following:
About QGIS
QGIS is a popular, free, and open source Geographic Information System (GIS),
which runs on all major operating systems. People often use QGIS to view, edit,
and analyze geospatial data. For our purposes, however, QGIS is more than just
a GIS system; it is also a geospatial programming environment, which we can
use to build our own geospatial applications using Python.
Before reading further, you should spend 15 minutes looking through the website
and getting familiar with the application and the documentation available online.
In particular, you should check out the Documentation page, where three
important manuals are available: QGIS User guide/Manual, QGIS Training manual,
and PyQGIS cookbook.
Other documents randomly have
different content
morsian. Suontaustan Silla oli siitä jo varoittanut Tildaa, vaan kun
Tilda sanoi juuri pitävänsä sellaisesta miehestä, joka muillekin
kelpaisi, oli Sillakin sulkenut suunsa.
— Mitä turhia täällä odottelet, etkö nähnyt, johan tuo meni tuolla
etäällä?
— Kuka tuo?
— No, poimi nyt, vaan tule ajoissa kotiin ettei isä ennätä kysyä ja
— pyyhi suusi puhtaaksi marjoista.
— Niin, yhä sinäkin vain vetelet samaa virttä. Sinusta olisi kai
hauskaa nähdä minut ijän kaiken vanhana piikana.
— Hyvä niin, hyvä näin. Niin oot äitisi sylissä kuin on marja
mättähällä, niin oot sulhosi sylissä kuin on kukka sammalessa, sanoo
joku runoilija.
— Oi, minä rakastan niin, rakastan niin… että minä en voi mitata
sitä sinulle.
— Ei vielä…
— Voi kyllä, vaan ei niin monena iltana. Eilen hänen jo piti tulla,
vaan…
III.
— Teille tuli vieraita. Kun minulla oli matka tänne, pyysivät minut
Teitä paluuttamaan.
— Keitä ne ovat?
— Tunsitteko te niitä?
Kun hän astui pihaportista sisään, näki hän että piha oli tyhjä.
Palvelusväki oli poistunut pihanpäätupaan, koskapahan sieltä lasista
näyttiin kurkisteltavan. Hän nousi rappuja ylös omaan asuntoonsa,
avasi oven kamariinsa ja lensi kalman kalpeaksi. Hän melkein tuijotti
eteensä, ei uskonut omia silmiään, vihdoin toki vihansa sanoihin
purki:
— Ja minkätähden?
— Sentähden että se olisi parasta sekä Leenulle itselleen että
Tuohelalle, teille, isällenne ja kaikille ihmisille.
IV.
— En!
— Palkitset?
— Niin, niin, minä koetan sovitella.
— Myöhäistä?
— Vielä…
— Niin, ja kaikki.
V.
— Ei, ei, eihän voi olla mahdollista, että ihmiset ovat niin pahoja.
Eihän suuri Jumalakaan sitä salli. Ethän salli niin suurten vääryyksien
tapahtua? Tai tahtonetko meitä ihmisraukkoja niin kovasti rangaista
jo täällä? — Voi kun edes äiti eläisi! Minä painaisin pääni povellesi,
purkaisin sinulle sydämeni surut kaikki ja neuvoja sinulta saisin. Sinä
lohduttaisit minua vielä… me rukoilisimme yhdessä. Niin, kunpa vaan
olisi edes yksikään ystävä, jolle kertomalla voisi keventää huolensa.
Vaan ei yhtään, ei yhtään! Isä on sokea vihassaan ja veljet… Niin,
Kallekin kertoi minulle poloiselle, paljasti niin paljon maailman
pahuutta, etten osannut ennen edes aavistaakaan. Ehk'ei kuitenkaan
kaikki ole totta, ehkä tahtovat he sittenkin ainoastaan saada meidät
eroituiksi keinoilla millä hyvänsä ja nyt tuon keksivät. Oikeudessa isä
ja kaikki! Jumalani, anna oikeuden voittaa, kosta kaikki vääryys,
vaan ethän tahtone, kuten ihmiset, omaiseni, että minun pitäisi
halveksia ja vihata häntä, jota rakastan. Vai olenko ollut niin paha,
että olen häntä enemmän kuin Sinua rakastanut? Senkötähden nämä
surut? Ei, sinä et voi, tai vaikka voit, et tahdo siitä näin rangaista…
Ja Leenu parka istui nurmella ja itki. Koko päivän oli hän paikasta
toiseen levotonna harhaillut ja koettanut turhaan ikäviään
haihduttaa. Häntä oli säälitty ja jätetty kertomatta kaikki pahimmat
kohdat jutussa. Oikeusistuntoja oli asian johdosta pidetty jo
useampiakin. Muitakin riitoja oli ennen niin rauhallisten naapurien
välille ilmestynyt. Nyt oli viimeinen ratkaiseva istunto käräjätalolla.
Kaikki olivat Parveelastakin menneet sinne, jotka vaan pääsivät.
Leenu olisi tahtonut mukaan hänkin näkemään edes omaansa, jota
ei pitkiin aikoihin ollut saanut tavata. Mutta isä kun ajoi asiaa
tyttärensä puolesta, oli kieltänyt, ja Leenun oli parin palvelijattaren
kanssa täytynyt kotiin jäädä.
— Näitkö häntä, Silla? Oliko hän muuttunut paljo? Mitä hän puhui,
oliko suruissaan?
— Muuttunut…
— Kuka voisi enään uskoa, että Sillankin sameat silmät ovat ilosta
loistelleet ja että minunkin surkastunut sydämeni on ollut aikoinaan
ilosta pakahtua ja kuitenkin… Ei, Leenu-lapsi, liikaa on minun
mieleisiin muisteluihin upottaa muistoja katkerista kokemistani, jotka
nyt lempilapsieni onnea uhkaavina verestävät kestetyt kärsimykset ja
jotka nyt rakastamiani raatamalla kokonaan särkevät syksyisen
sydämeni.
— Syyttömän.
— Sinä.
— Lakkaa, lakkaa!
— Ei koskaan!
*****
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com