Chris Holden (ceholden@gmail.com) - https://github.com/ceholden

Introduction

Tutorial of basic remote sensing and GIS methodologies using open source software (GDAL in Python)

Why Python?

  • Easy to learn

    • Python is an interpreted, dynamically typed language with little boilerplate code required to begin doing useful things
    • Test out your code in Python's interpreter (read-evaluate-print loop) before you put your code into a script
    • Very readible and closer to human thoughts than C/Java/R/MATLAB
  • Python is an actual programming language with a large standard library

    • tools for file manipulation, command line argument parsing, and web access and parsing already exist and are robust
    • Python already widely used in other scientific communities and outside of science for web servers, desktop applications, and server management
  • Scientific Python provides very well documented and easy to use interfaces to pre-existing numeric methods

    • Linear alebgra, classification routines, regression methods, and more have been published for decades as Fortran or C codes
    • Libraries such as SciPy, NumPy, and SciKits wrap and extend these pre-existing codes in an easy to use package
    • Python provides numerous tools to introspect objects and Python code conventions make access of documentation easy (e.g., type ?np.random.randint to access the documentation string (docstring) of NumPy random number generator
  • Large community with innumerable examples on blogs, StackOverflow, Github, etc.

  • Develop Python plugins for QGIS

  • Script analyses in QGIS or ArcMap

  • Many GDAL tools written in Python

    • useful for example code and a strong recommendation
  • Free

Other resources

There are many resources for doing remote sensing and GIS with Python on the web, but here are some of the better ones:

Note on Python 2 vs Python 3

In this tutorial series we will be assuming you are using Python 2.7, not Python 3. To ensure you are running a compatible version of Python, you can print the version by typing:

python --version

at the command line.

If you don't know what why it would be important, continue below to the chapter titles.

You may be able to port most of the tutorial to Python 3, but we will stick to Python 2 because QGIS is still using Python 2.7 for scripting and plugin development. I will make an effort to make things compatible by importing functionality from the __future__ module.