Home

Awesome

FOSS4G UK 2019 Geoprocessing with Jupyter Notebooks

Workshop Overview

The Jupyter notebook has fast become the de-facto environment for data scientists using the so-called "pydata stack" (python packages of numpy, pandas, matplotlib, amongst others). Now, there is increasing crossover between desktop GIS specialists and python developers, as python packages that manipulate geographic data become more feature rich and mature. Jupyter notebooks, often referred to as iPython notebooks, offer a powerful yet easy to use environment to write code to explore, interact with and visualise data. Notebooks allow you to save the steps of your workflow, making them easy to share as a file or publish to the web.

The objectives of this short workshop are to provide GIS users with a hands-on introduction to (a) how to set up a jupyter notebook environment locally using Anaconda and install various required python packages (b) undertake some simple geo-processing tasks using a mixture of "geo" packages within the "pydata" ecosystem, e.g. rasterio, xarray and geopandas, (c) visualise processing outputs.

The workshop is aimed at GIS desktop users with "beginner-level" awareness of python but have not used Jupyter notebooks and want to learn more. If you're familar with python and notebooks, then still free feel to come along as you may pick up some tips on the way.

Prerequisites for Participants - what you need to do beforehand

Introduction/Background

Why this workshop?

Who is the Workshop for?

I want to cater someone with one or all of the following requirements:

If you're sitting here, and you don't fit that profile, DO NOT PANIC you can treat this as a fresher.

There are a bunch of interactive tools similar to notebooks, why jupyter notebooks ?

Some background before we dive in

How this workshop will run

How to build your Environment

This is the key task for a newcomer.

We will use Miniconda together with a requirements.yml file that will provision all the packages with a virtual python environment.

# get the latest MacOS 64-bit installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh
# get the latest linux 64-bit installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh

Download a copy of this repository, either downloading of the zip or via git, with:

git clone git@github.com:samfranklin/foss4guk19-jupyter.git

For Windows users, it's best to use the anaconda terminal app, so open this application from the start menu.
You will need to change the directory to where you downloaded the code repository. If you're using the terminal on Linux or macOS, it's the same synatax to change directory.

cd foss4guk19-jupyter

Check your terminal can use the conda program with:

conda --version

Create the conda environment using the environment yaml file, this can take between 5 - 10 minutes:

conda env create --file requirements.yml

Activate the environment

conda activate jgpenv

Launch a Jupyter Notebook

jupyter notebook

You are ready to go!

Backup Option - in case your environment does not build

In the event your environment doesn't build or the the conference WiFi isn't up to it, you can follow along to the workshop and view the jupyter notebooks via nbviewer using https://nbviewer.jupyter.org/github/samfranklin/foss4guk19-jupyter/tree/master/tutorials/, and select the notebooks with 'nbviewer'.

nbviewer is a simple online tool that allows you to share notebooks. GitHub and GitLab sometimes do not render the outputs of a notebook particularly well, so, https://nbviewer.jupyter.org/ allows you to render a notebook already published on the interview on their server.