Building mapping applications with QGIS create your own sophisticated applications to analyze and display geospatial information using QGIS and Python Westra pdf download
Building mapping applications with QGIS create your own sophisticated applications to analyze and display geospatial information using QGIS and Python Westra pdf download
https://ebookultra.com/download/building-mapping-applications-with-qgis-
create-your-own-sophisticated-applications-to-analyze-and-display-
geospatial-information-using-qgis-and-python-westra/
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.
Random documents with unrelated
content Scribd suggests to you:
all the company except Johnson was very surly and ill-tempered;
of the philosopher he appeared extremely fond, rubbed against
him, and displayed every mark of awkward partiality and subdued
kindness. "How is it," said one of the company, "that this savage
animal is so attached to Mr. Johnson?" "From a very natural
cause," replied Mallet; "the bear is a Russian philosopher, and he
knows that Linnæus would have placed him in the same class
with the English moralist. They are two barbarous animals of one
species."
The Doctor disliked Mallet for his tendency to infidelity, and this
sarcasm turned that dislike into positive hatred. He never spoke
to him afterwards, but has gibbeted him in his octavo Dictionary
under the article alias.
[112] I cannot learn in what year the duration of this fair was
shortened; but I should suppose from the following circumstance,
very soon afterwards. This print was published in 1733, and on
the 24th of June 1735 the Court of Aldermen came to a resolution
touching Bartholomew Fair, "that the same shall not exceed
Bartholomew eve, Bartholomew day, and the day after; and that
during that time nothing but stalls and booths shall be erected for
the sale of goods, wares, and merchandizes, and no acting be
permitted."
[113] A Mr. Banckes, who a few years afterwards published
some rhymes on this print, asserts, "that the performance at the
booth, on the sign of which is written, The Fall of Bajazet, is the
droll of Fair Rosamond." From the dresses, etc., I should imagine
this ingenious gentleman is wrong. He also observes, "that young
Louis XV., King of France, his queen, children, prime minister, etc.,
were this year exhibited in Smithfield and the Borough at very
reasonable prices, to spectators of all degrees." Our artist,
however, had forgot himself in regard to the matter of which
these great personages were made, the whole town having been
informed by their master of the ceremonies that they were of a
composition far exceeding wax. The same writer goes on to
inform us:
"There Yeates and Pinchbeck change the scene
To slight of hand, and clock machine;
First numerous eggs are laid, and then,
The pregnant bag brings forth a hen," etc.
From the above lines, I should suppose that the late Mr.
Pinchbeck, with his wonderful and surprising piece of mechanism
the Panopticon, was at this fair; though he frequently spoke of
one of his brothers, "who," he said, "was a showman, and who
once gave a very large sum for an elephant, and took a room at
Southwark Fair, with an intention of exhibiting it; but the passage
to this room," added he, "was so narrow, that though my poor
brother 'got the beast into it, a'never could get un out on't; a'
stuck in the middle on't and died!' So, sir, you sees my poor
brother lost all his money. Ah! he was a most unfortunate dog in
everything he took in hand! and so was I, God knows." Cætera
desunt.
[114] The late Lord Sandwich, not very eminent for his
reverence of the clerical habit, being once in a company where
there were a number of clergymen, offered, in a whisper, to lay a
considerable wager with the gentleman who sat next him, that
among the ten parsons there was not one Prayer-book. The
wager was accepted, and a mock dispute gave him occasion to
ask for a Prayer-book to decide it. They had not one.—He soon
after privately offered to lay another wager with the same
gentleman, that among the ten parsons there was half a score
corkscrews. This also was accepted; and the butler being
previously instructed, coming into the room with a bottle of claret
and a broken corkscrew, requested any gentleman to lend him
one. Every priest who was present had a corkscrew in his pocket!
[115] Of Henley's absurdities we have heard much; but they
had their source in an adoption of that manner which he knew
would be agreeable to his auditors, rather than in ignorance. The
following circumstance proves he was a man of some humour:—
"I never," says a person who knew little about the doctor, "saw
Orator Henley but once, and that was at the Grecian Coffeehouse,
where a gentleman he was acquainted with coming in, and
seating himself in the same box, the following dialogue passed
between them:—
Henley. "Pray what is become of our old friend Dick Smith? I
have not seen him for several years."
Gentleman. "I really don't know. The last time I heard of him
he was at Ceylon, or some of our settlements in the West Indies."
Henley (with some surprise). "At Ceylon, or some of our
settlements in the West Indies! My good sir, in one sentence
there are two mistakes. Ceylon is not one of our settlements, it
belongs to the Dutch; and it is situated, not in the West, but in
the East Indies."
Gentleman (with some heat). "That I deny!"
Henley. "More shame for you! I will engage to bring a boy of
eight years of age who will confute you."
Gentleman (in a cooler tone of voice). "Well,—be it where it
will, I thank God I know very little about these sort of things."
Henley. "What, you thank God for your ignorance, do you?"
Gentleman (in a violent rage). "I do, sir. What then?"
Henley. "Sir, you have a great deal to be thankful for."
[116] These lines are from Banckes' Poems, p. 87, in which a
contracted copy of the print is placed as the headpiece of an
epistle to the painter. This good gentleman, with true poetic
vanity, pathetically exclaims,
C h atto & W i n d u s
(Successors to John Camden Hotten),
74 & 75, PICCADILLY, LONDON, W.
MACLISE'S GALLERY OF
ILLUSTRIOUS LITERARY CHARACTERS.
With Notes by the late WILLIAM MAGINN, LL.D.
Edited, with copious Notes, by William Bates, B.A., Professor of Classics in Queen's
College, Birmingham. The volume contains the whole 83 Splendid and most
Characteristic Portraits, now first issued in a complete form. In demy 4to, over
400 pages, cloth gilt and gilt edges, 31s. 6d.; or, in morocco elegant, 70s.
"What a truly charming book of pictures and prose, the quintessence, as it were, of
Maclise and Maginn, giving the very form and pressure of their literary time, would
this century of illustrious characters make."— Notes and Queries.
BEAUTIFUL PICTURES
BY BRITISH ARTISTS.
A Gathering of Favourites from our Picture Galleries, 1800-1870. By Wilkie,
Constable, J. M. W. Turner, Mulready, Sir Edwin Landseer, Maclise, Leslie, E. M.
Ward, Frith, Sir John Gilbert, Ansdell, Marcus Stone, Sir Noel Paton, Eyre Crowe,
Faed, Madox Brown. All Engraved in the highest style of Art. With Notices of the
Artists by Sydney Armytage, M.A. A New Edition. Imperial 4to, cloth gilt and gilt
edges, 21s.; or, in morocco elegant, 65s.
Armorial Register of the Order of the Garter, from Edward III, to the Present
Time. The several Shields beautifully emblazoned in Gold and Colours from the
Original Stall Plates in St. George's Chapel, Windsor. All emblazoned by hand. A
sumptuous volume, bound in crimson morocco, gilt, £20.
Boccaccio's Decameron.
Now fully translated into English, with
Introduction by Thomas Wright, F.S.A. Crown
8vo, with the Beautiful Engravings by Stothard
which adorned Pickering's fine Edition,
published at £2 12s. 6d. This New Edition is
only 7s. 6d.
⁂ A faithful translation, in which are restored
many passages omitted in former Editions.
Book of Hall-Marks ; or, Manual of Reference for the Goldsmith
and Silversmith. By Alfred Lutschaunig, Manager of the Liverpool Assay Office.
Crown 8vo, with 46 Plates of the Hall-Marks of the different Assay Towns of the
United Kingdom, as now stamped on Plate and Jewellery, 7s. 6d.
⁂ This work gives practical methods for testing the quality of gold and silver. It was
compiled by the author for his own use, and as a Supplement to "Chaffers."
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