Skip to content

Geospatial Python – Cardiff 19th Nov – 20th Nov 2019


These are the joining instructions for the Geospatial Python course held in Cardiff on the 19th November to 20th November 2019. For more information email

I understand and appreciate that everyone has their own unique computer setup. This is something that can cause Python users some problems. It can be confusing.

Because of this I recommend you install Anaconda. However you can use your own setup if you prefer.

Recommended Python Set up (Windows)

Important please check before course starts

I recommend using Anaconda This course is for Python 3, however it ‘should’ work on Python 2.7. At the time of the course there will be less than a year left of Python 2.7 support

You may need to open the Anaonda Prompt as an Administrator, by doing this it should remove any permission errors. Right click and select Run As Administrator.

If you can type ‘python’ into a the anaconda prompt then you should be good to go

type exit() to leave the Python environment and return to the command prompt. It will look like

(base) your directory (eg C:/users/…)


To install gdal (the most critical step).

conda install -c conda-forge gdal

It may take a while eventually you will get a prompt asking whether you wish to install, select Y (for yes) and press enter.

If you get to this stage then you have pretty much everything installed for day 1. For day 2 please also install the following packages

opencv install (we will not be using this on this course, but it is well worth installing)

conda install -c conda-forge opencv=3.3.1

sklearn install

conda install -c anaconda scikit-learn

skimage install

conda install -c anaconda scikit-image

raster stats install

conda install -c conda-forge rasterstats

scipy install

conda install -c anaconda scipy

rasterio install

conda install -c anaconda rasterio

GeoPandas install

conda install -c conda-forge geopandas

Shapely install

conda install -c conda-forge shapely

Open an anaconda prompt and check that gdal is installed




from osgeo import gdal,ogr

(shown below)

type exit() to leave the Python environment

Anaconda comes pre cooked with jupyter notebook

type (you might wish to change directory, for example, to the root of  D: first – cd d:)

jupter notebook

into the command prompt and it should open up a web browser within your directory of all your folder/files and notebooks.

I have written two detailed blog posts that should be of help if you have any issues

Python for Geospatial work flows part 1: Use anaconda

Python for Geospatial work flows part 2: Use Jupyter Notebooks

I will cover Jupyter Notebooks in this course, so you don’t need to read this post.

Further useful software

  1. Notepad ++
  2. OSGeo4W for QGIS

A note on Mac installation.

I run this course on a Windows 10 machine. If you need to install gdal on a Mac then I have been told that the following commands work:


conda install -c conda-forge/label/cf201901 gdal

I think that ensures gdal is correctly installed.


gdalinfo –version

To check I had gdal on the system


conda install krb5

Apparently this is a dependency of gdal but isn’t installed by default.

I don’t have access to a Mac so please let me know if this doesn’t work (I am not sure what will work if it doesn’t)

Please attempt to install gdal prior to attending the course, it is not fair on the other attendees if you don’t have a working installation and we have to spend time getting you setup.


I run the course through a folder on my computer. I suggest you create a folder on your machine


Please download (21mb)

The QGIS Sample Data

Extract this to


Please download the day 1 course data data_package_beg (~17mb)

Extract this to


Please download the day 2 course data data_package (~23mb)

Extract this to



I will make the course code available at the start of the morning and afternoon. I would like you to try and follow the examples as we go, but don’t worry about mistakes this is all good practice.


Throughout the course as our learning progresses I have created a series of challenges. These are to aid your learning, help you practice. At the end of the challenge I share a solution, I will make these available after the course. We will time permitting discuss other solutions. The aim is to experiment try new things.


Day 1 – Intro to Python, Gdal and Numpy


  • Introduction to Jupyter Notebooks
  • Intro to:
    • Python data types (lists, tuples, strings, integers, floats, dicts)
    • Programming basics (loops, if/else statements, operators)
    • Printing variables, getting help and installing libraries
    • Functions and inbuilt functions
    • Slicing lists


  • Working with directories of data
  • Reading and writing textfiles



  • Creating a point shapefile from a textfile
  • Shapefile cheat sheet
  • Introduction to NumPy


  • Reading a raster dataset in GDAL
  • Using subprocess to call GDAL functions


Day 2 – EO processing with a focus on classification


  • Recap
  • Rasterio, read/write and manipulate data
  • Masking satellite images using Shapefiles


  • Extract image boundary from Satellite data
  • Using K-Means for unsupervised image classification


  • Part 1 preparing data for supervised machine learning using Scikit-learn
  • Part 2 using Scikit-learn for machine learning on your data


  • Using Rasterstats to extract zonal information
  • Geopandas
  • Recap

Please contact me with any questions