Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

An interactive workspace for exploratory data analysis

1. Introduction

JupyterLab is the main working environment in this course. It is not just a place to run code, but a space where thinking, coding, and documentation come together.

In spatial data science, work is rarely linear. You load data, inspect it, try something, visualize the result, adjust your approach, and document what you learned. JupyterLab is designed for exactly this kind of exploratory and iterative work.

A Jupyter notebook combines executable code, text explanations, figures, and maps in one place. This makes it easier to:

This is especially important when working with spatial data, where data sources, projections, and processing steps can strongly influence results. By keeping code and explanation together, notebooks support reproducibility, transparency, and a clear analysis narrative.

In this section, you will learn how to use JupyterLab as a structured workspace for spatial data science. The focus is not on learning every feature, but on developing good working habits that you will use throughout the course and beyond.

This section focuses on how we work, not just what we run.


2. Learning Objectives

After working through this section, you should be able to:

These objectives focus on using JupyterLab as a practical working environment for exploration, documentation, and analysis. You will use these skills throughout the course when developing and refining your own spatial data workflows.


3. Getting Started

Before using JupyterLab, it is important to think about where it is installed and which environment it belongs to. Most problems with JupyterLab do not come from the tool itself, but from using the wrong Python environment.

In this course, JupyterLab is always part of a project specific environment. This keeps your setup clean, avoids version conflicts, and makes your work easier to reproduce.

JupyterLab should not be installed system wide. Instead, you install it inside a dedicated conda environment.

The basic idea is simple:

If this is new to you, revisit the Conda section before continuing. Environment activation is a required habit for this course.

Installing JupyterLab

The recommended way to install JupyterLab for spatial data science is with conda, as it handles geospatial dependencies reliably. Install JupyterLab into the currently active conda environment (-c = --channel).

conda install -c conda-forge jupyterlab

If you are working in a pip based environment, you can install JupyterLab with:

pip install jupyterlab

Only use one package manager per environment. Mixing conda and pip without care is a common source of errors.

Verifying the installation

After installation, always check that JupyterLab is available in the active environment.

Run the following command in your terminal:

jupyter lab --version

You should see a version number printed in the terminal. If you get an error, check the following first:

Taking a minute to verify your setup now will save you a lot of time later.


4. Launching JupyterLab

Before working with notebooks, it helps to understand what actually happens when you start JupyterLab. This section focuses on building a mental model of how JupyterLab works, rather than on clicking through menus.

Run jupyter lab

When you run jupyter lab, you are not opening a normal desktop application. Instead, JupyterLab starts a local server on your computer.

Here is what is happening in the background:

If you close the terminal, the server stops and JupyterLab shuts down. Understanding this connection between terminal, server, and browser helps explain many common issues students run into later.

The JupyterLab interface

The JupyterLab interface is designed as a flexible workspace. A useful way to remember its structure is the following mental model:

Command – Canvas – Context – Status

The main interface components of JupyterLab IDE.

The main interface components of JupyterLab IDE (source: python-gis-book).

Each part has a clear role:

Keeping this structure in mind makes it easier to navigate JupyterLab and transfer these skills to other development environments later in the course.


5. Notebooks as Scientific Documents

In this course, notebooks are not temporary scratchpads. They are scientific documents that combine code, explanation, and results. A good notebook tells the story of your analysis in a way that others and your future self can understand.

Creating a notebook

When JupyterLab starts, you will see the Launcher. This is the entry point for creating new files.

The basic components of a Jupyter Notebook opened in JupyterLab.

The basic components of a Jupyter Notebook opened in JupyterLab (source: python-gis-book).

To create a notebook:

Good naming matters. A notebook called analysis.ipynb tells you very little. A name like snow_cover_exploration_v1.ipynb makes the purpose clear even months later.

Cells, execution, and state

Notebooks run code in cells, and these cells are executed sequentially. This means the order in which you run cells matters.

A common source of confusion is hidden state. Variables can exist in memory even if the cell that created them is no longer visible or was changed later.

To avoid problems:

This habit is essential for reproducibility and for submitting reliable work.

The geospatial output

To see how notebooks behave, start with a minimal geospatial example. The goal here is not to understand the mapping library, but to observe the notebook workflow.

You typically go through three steps:

When you run a cell that produces visual output, JupyterLab automatically renders it below the cell. This tight link between code and output is what makes notebooks so powerful for exploration and communication in spatial data science.


6. Productivity Fundamentals

Working efficiently in JupyterLab is less about speed and more about reducing cognitive load. Using the keyboard helps you stay focused on your analysis instead of constantly switching between mouse and menus.

This section introduces only the essential concepts and shortcuts you need to work fluently. You do not need to memorize everything at once.

Notebook modes

Jupyter notebooks operate in two distinct modes. Many beginner mistakes happen because these modes are confused.

Edit mode

Command mode

Always be aware of which mode you are in. If something does not behave as expected, mode confusion is often the reason.

Core shortcuts

You only need a small set of shortcuts to work productively. These are the ones you will use constantly:

Most keyboard shortcuts depend on the current notebook mode. Shortcuts that act on the structure of the notebook, such as creating, deleting, or moving cells, only work in command mode. If they do nothing, you are usually still in edit mode. Shortcuts that run cells, such as Shift Enter or Ctrl Enter, work in both modes. Shortcuts that edit text only work in edit mode. Mastering these shortcuts already gives you most of the productivity benefits.

Editing vs Structuring

A useful way to think about notebook work is to separate two activities:

Being aware of this distinction helps you work more deliberately. You edit when you think about code and text. You structure when you think about the story your analysis is telling.


7. Working Without a Local Setup

Not everyone can or wants to install software locally right away. For this reason, most parts of the course material can also be run using Binder and Colab.

Both services allow you to work with notebooks directly in your browser, without setting up a local Python environment.

What Binder and Colab are

Binder starts a temporary JupyterLab environment that is linked to a course repository.
Colab provides hosted Jupyter notebooks that run on Google infrastructure.

Both options:

When to use them

Binder and Colab are useful when:

They help lower entry barriers and ensure everyone can participate.

Limitations to keep in mind

Both Binder and Colab have limitations:

Because of this, they are best used for short tasks and exploration.

Binder and Colab are for learning, not for long term projects.


8. Exercises

These exercises help you practice using JupyterLab as a working environment for spatial data science. The goal is not to learn every feature, but to build confidence with the core workflows you will use throughout the course.

Work through the exercises at your own pace. If something breaks, that is part of the learning process.


Exercise 1: Setting Up Your JupyterLab Environment

Objective
Set up and verify a working JupyterLab environment for spatial data analysis.

What you practice

Tasks

  1. Create and activate a dedicated environment:

conda create -n geolab python=3.12
conda activate geolab
  1. Install JupyterLab and basic geospatial packages:

conda install -c conda-forge jupyterlab geopandas matplotlib ipyleaflet
  1. Launch JupyterLab:

jupyter lab
  1. Explore the interface:

  1. Verify your setup:

import geopandas as gpd
import matplotlib.pyplot as plt
import ipyleaflet
print("Geospatial environment ready")

What to verify


Exercise 2: Keyboard Shortcuts and Efficient Workflow

Objective Develop fluency with keyboard driven notebook work.

What you practice

Tasks

  1. Practice essential shortcuts:

  1. Create a practice notebook using only the keyboard:

  1. Practice editing and restructuring:

  1. Check notebook state:

What to verify


Optional Challenge: Workflow Efficiency

Objective Improve speed and confidence when working in notebooks.

What you practice

Tasks

What to verify

These exercises prepare you to use JupyterLab naturally in later labs and projects, where the focus will be on spatial data analysis, not on tool mechanics.