Have a question?
Message sent Close
4.5 out of 5
40 reviews on Udemy

Learning the Open Source GIS Stack: Python for Geospatial

leverage geospatial tasks with Python programming
Arthur Lembo
283 students enrolled
English [Auto]
You will learn how to write basic Python scripts.
You will also learn how to integrate Python packages that have GIS functionality.
As a bonus, this course will also show how to use Arcpy, and integrate ArcGIS with FOSS4g.
And you'll learn how to integrate SQL, PostGIS, and SpatiaLite.

If you are in the field of GIS, you’re probably hearing everyone talking about Python, whether it’s Arcpy in ArcGIS or special Python packages for doing things like geocoding.  In this course I am going to show you how to write Python code to perform spatial analysis.  The course isn’t so much about learning Python, but rather how to integrate different spatial libraries within your Python code.  Using the course videos, you will work alongside of me to learn how I go about cobbling together Python code and various packages to solve spatial problems.  I’ll provide you with all the data that I demonstrate in the course.

Of course, we’ll have a brief overview of Python.  But after the brief refresher, we will dive into using Python with Open Source GIS and commercial GIS software.  Most courses only go over a single GIS program’s use of Python.  But in this class, you’ll get exposed to all kinds of different GIS software products, and learn how to tie them all together with Python.  

Welcome to the course

Goals and objectives - what you'll learn

Loading our software and data

Installing QGIS 3.8

In this section we are going to download QGIS 3.8.  If you get a newer version, even better. 

Installing Postgres 11
Our data

This lecture is going to give a brief overview of the data we'll be using for our course.  Make sure to download the python.zip file, and then unzip it in a folder: c:trainingpython 

You'll have to restore the tompkins.backup file into Postgres if you wish to follow along with the coding.

Installing Python 3

There are lots of version of Python out there.  I'm using Python 3.7.  If you get 3.8 or newer, you'll be just fine. 

Loading data into Postgres

Now that the software is loaded, we want to add the Tompkins data set.  This lecture will show you how to restore the Tompkins.backup file into Postgres.

A gentle overview of Python

The general overview

In this lecture, you'll get introduced to Python as a scripting language.  We won't be writing code just yet.  For now, I want to describe the many flavors of Python and get you familiar with the interface.  Also, I want to give us all a wake up call regarding some of the complexities when working with many different versions of Python. 

The Python language: strings

Get ready.  We're going to start writing python code - in this lecture, we'll stick to strings.  The best thing you can do is follow along with the video, and then replicate the code.  By typing it in yourself (rather than copy/pasting from a master copy), you are more likely to really pick up on the language. 

Reading and writing from files

So much of what we do with python programming is reading and writing data.  In this lecture, we'll read data from a CSV file, and start processing the data.  We'll also learn how to write the output into another file. 

The Python Language: numbers and lists

In this lecture, we continue our gentle tour of python, and will start introducing examples of numeric data types and functions, and also functions that work with lists.

Statements and control

What makes scripting so powerful is how we can control the flow of the program and the user experience.  In this lecture, we'll learn about important concepts like loops and conditional statements.

A simple program to convert temperature

We are going to write a very simple script to convert temperatures.  This seems almost juvenile.  But, even a simple program for temperature conversion requires us to interact with the user, introduce if/then statements, and also performing calculations.  So, its a great jumping off point for the rest of our programming. 

Default Python modules

Python has lots of built in functions that allow us to perform mathematical, web based, and file I/O.  These modules come with python, and learning to use them will help you more from basic scripting to more intermediate complexity as you solve problems. 

External modules: the magic of PIP

Blow your mind with SQLITE

With python, and sqlite package, you can write a python script that will communicate directly with SQLite.  That's pretty powerful stuff!

Blow your mind with SQLITE: spatial!

if you thought connecting to SQLite with python was impressive, wait til you see what comes next: adding spatial capabilities to SQLite with Spatialite.  And, we can write a python script to not only perform impressive spatial analysis with SQLite, but we can also start interacting with the user. 


While python has math capabilities, it doesn't come close to the capabilities of using numpy.  Numpy is one of the most widely used and respected libraries of scientists who program using python. 

Linear Algebra with Numpy (also how to create a function)

Our last lecture introduced some interesting capabilities that numpy performs.  For this lecture, we are going to tackle a very sophisticated mathematical concept: linear algebra.  Don't panic, we aren't going to go deep.  But, you'll see just how easy it is to perform matrix algebra for least squares adjustment - something we do a lot of in geospatial analysis.

Postgres and Python

This is probably what you've been waiting for: connecting to Postgres with python.  And, not only are we going to connect to Postgres, we are going to start issuing PostGIS spatial commands to perform geospatial analysis.  If you can do this, you are going to get noticed for your superior skills!

Access Microsoft Excel with Python

Not only can you connect to different libraries with python, but you can even connect to Microsoft Excel.  And, if you can connect to Excel, you can integrate Excel functions with Postgres functions, with geospatial functions.  It's going to start sounding redundant, but if you can do this, you'll really be seen as an expert in python.

Explicitly Spatial modules with Python

Geocoding modules

Section 6: Python with Desktop QGIS (ArcGIS and QGIS)

A quick intro to Arcpy
Extending Arcpy to run outside of ArcGIS
A quick intro to Qpy
Extending our use of Qpy

Applying what we learned in Qpy

Lab Question 1: How many TRI sites are within .5 miles of the interstate
Lab Question 2: How many schools are within .5 miles of Lindau Chemical
Lab Question 3: What % of white / non white are vulnerable to a TRI spi

Creating forms with Python

Creating forms using formlayout

In this lecture, you will learn how to import the formlayout package and start shaping the structure of a GUI with python.  This is not a sophisticated for editor, but it is really easy to use, and very likely can handle 80% of what we need in the form of a GUI. 

Integrating forms with ArcGIS

In this lecture you'll see how we extend the simple form we previously created to integrate ArcGIS with Arcpy and formlayout.  In this case, you can start creating forms for ArcGIS applications, without the need to use ArcScripts. 

Integrating forms with Postgres and PostGIS

Now we are going to expand our use of forms to Postgres!  In this lecture, you'll learn how to create interactive forms with the user, and connect those forms with Postgres, allowing you to issue SQL and spatial SQL however you feel.  You'll also notice that the codes is short, light weight, but very interactive.  This will prove that you can create a Postgres/PostGIS form in a matter of minutes.

Bonus Lecture: How to keep learning
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.5 out of 5
40 Ratings

Detailed Rating

Stars 5
Stars 4
Stars 3
Stars 2
Stars 1


5 hours on-demand video
Certificate of Completion


AulaGEO is a Ge-engineering specialized academy.

Social Network

Udemy Black Friday Sale! Top Courses From $9.99