Geographic Information Systems for Public Policy - Lecture XIV

QGIS Scripting Part II

Sergio Rey

Last Time

  • QGIS console
  • Working with layers
  • Exercise 2 in the console

Today

  • Exercise 2 in the console
  • Cloning Layers
  • Exercise 4

Exercise 2 in the console

Creating attributes

Create an attribute named pctHISP that reports the percentage of the tract’s total population that is Hispanic.

Creating attributes

Create an attribute named majHISP that takes a value of 1 if pctHISP > 0.50, 0 otherwise

Cloning a layer (saving the original)

Handling Paths

Windows

Mac OS X

Exercise 4

Program requirements (URL)

Approach

  • Plan the workflow (don’t just jump in writing code)
  • Break workflow into discrete, tractable steps
  • Work on one stage at a time
  • Use the console prompt to test ideas

Philosophy

  • Complexity -> simplicity
  • Make it work
  • Make it right
  • Make it fast (optional in this course)

Next up

  • Exercise 4 continued.

Creative Commons License
GIS for Public Policy’20 by Sergio Rey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.