Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying QGIS Python Programming Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
QGIS Python Programming Cookbook

QGIS Python Programming Cookbook

By : Joel Lawhead
3.8 (6)
close
close
QGIS Python Programming Cookbook

QGIS Python Programming Cookbook

3.8 (6)
By: Joel Lawhead

Overview of this book

If you are a geospatial analyst who wants to learn more about automating everyday GIS tasks or a programmer who is responsible for building GIS applications,this book is for you. The short, reusable recipes make concepts easy to understand. You can build larger applications that are easy to maintain when they are put together.
Table of Contents (11 chapters)
close
close
10
Index

Iterating over layers


For many GIS operations, you need to loop through the map layers to look for specific information or to apply a change to all the layers. In this recipe, we'll loop through the layers and get information about them.

Getting ready

We'll need two layers in the same map projection to perform this recipe. You can download the first layer as a ZIP file from https://geospatialpython.googlecode.com/files/MSCities_Geo_Pts.zip.

You can download the second zipped layer from https://geospatialpython.googlecode.com/files/Mississippi.zip.

Unzip both of these layers into a directory named ms within your qgis_data directory.

How to do it...

We will add the layers to the map through the map registry. Then, we will iterate through the map layers and print each layer's title. To do this, perform the following steps:

  1. First, let's open the polygon and the point layer using the QGIS Python Console:

    lyr_1 = QgsVectorLayer("/Users/joellawhead/qgis_data/ms/mississippi.shp", "Mississippi", "ogr")
    lyr_2...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
QGIS Python Programming Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon