GRSG Geospatial Python for Beginners – virtual course 13th May 2020

Hello!

These are the joining instructions for the GRSG Geospatial Python for Beginners – 13th May 2020. This is a virtual course, if you have received an email inviting you to this course you will, in May, receive the links to the pre course and course. This is new for me so please be patient as I iron out issues.

GRSG

To attend you need to have registered

for more information email info@acgeospatial.co.uk


Pre-Course

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.

https://m.xkcd.com/1987/

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 download and install from here https://www.anaconda.com/download/ This course is for Python 3.7, however it ‘should’ work on Python 3.5 & 3.6.

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 on a vanilla install.

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

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

Easy Geospatial setup option

Download this zip file and unzip in your base directory and make sure it is called geospatial_python.yml

C:\Users\username

In the anaconda prompt run

conda env update -n base --file geospatial_python.yml

It should take about 10mins

OR

Install the packages as you need. For example 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.

repeat for

rasterio install

conda install -c anaconda rasterio

GeoPandas install

conda install -c conda-forge geopandas

If you get to this stage then you have pretty much everything installed.

Check

Open an anaconda prompt and check that gdal is installed

type

python

then…

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

and

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 ++ https://notepad-plus-plus.org/
  2. OSGeo4W for QGIS https://trac.osgeo.org/osgeo4w/

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:

Firstly:

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

I think that ensures gdal is correctly installed.

Secondly:

gdalinfo –version

To check I had gdal on the system

Thirdly:

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, rasterio and geopandas prior to attending the course, it is not fair on the other attendees if you don’t have a working installation. We will not spend time on the 13th resolving these issues.


Data

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

D:\GRSG_Course_Beginner

Please download (21mb)

The QGIS Sample Data https://qgis.org/downloads/data/qgis_sample_data.zip

Extract this to

D:\GRSG_Course_Beginner\qgis_sample_data

Please download the course data data_package_beg (~17mb)

Extract this to

D:\GRSG_Course_Beginner\data_package_beg

Code

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.

Challenges

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.

Structure

Morning

  • 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

Break

  • Working with directories of data
  • Reading and writing textfiles

Lunch

Afternoon

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

Break

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

We will start at 10am and finish at 4pm (I will leave 30mins until 4:30pm for any questions)

Please contact me with any questions info@acgeospatial.co.uk