Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering  QGIS

You're reading from   Mastering QGIS Go beyond the basics and unleash the full power of QGIS with practical, step-by-step examples

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781786460370
Length 486 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (5):
Arrow left icon
Kurt Menke, GISP Kurt Menke, GISP
Author Profile Icon Kurt Menke, GISP
Kurt Menke, GISP
 Corti Corti
Author Profile Icon Corti
Corti
 Smith Jr., GISP Smith Jr., GISP
Author Profile Icon Smith Jr., GISP
Smith Jr., GISP
 Pirelli Pirelli
Author Profile Icon Pirelli
Pirelli
 Van Hoesen, GISP Van Hoesen, GISP
Author Profile Icon Van Hoesen, GISP
Van Hoesen, GISP
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Mastering QGIS - Second Edition
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Preface
1. A Refreshing Look at QGIS FREE CHAPTER 2. Creating Spatial Databases 3. Styling Raster and Vector Data 4. Preparing Vector Data for Processing 5. Preparing Raster Data for Processing 6. Advanced Data Creation and Editing 7. Advanced Data Visualization 8. The Processing Toolbox 9. Automating Workflows with the Graphical Modeler 10. Creating QGIS Plugins with PyQGIS and Problem Solving 11. PyQGIS Scripting Index

Running an external algorithm or command


There are often a bunch of legacy programs or scripts for which there are no resources to port them into another language or framework. Thanks to Python and PyQGIS, it's simple to integrate your existing programs into QGIS.

Running a simple command

We can run an external command in different ways, but we will explore how to do it with the Processing Toolbox that supports the progress bar, which is often useful to log algorithm steps.

To execute an external command, we will follow these steps:

  1. Create a Processing Toolbox script called runping.

  2. Code the script.

  3. Test the script.

Step one is similar to that described in the Creating a test Processing Toolbox script section.

The code of the script is in the following code snippet:

import subprocess
import time

proc = subprocess.Popen(
    ["ping", "-c", "10", "localhost"],
    stdout=subprocess.PIPE,
    stdin=subprocess.PIPE,
    stderr=subprocess.PIPE)

counter = 0
for line in iter(proc.stdout.readline, '')...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images