Skip to main content

Notebook 1: Python for Geospatial Data

Hands-on with GeoPandas and Rasterio

Date

November 11, 2026

Session 3 Hands-On Notebook

This notebook accompanies Session 3: Python for Geospatial Data. You’ll learn to work with vector data using GeoPandas and raster data using Rasterio.

Learning Objectives

By completing this notebook, you will:

  • Load, filter and map Philippine administrative boundaries with GeoPandas
  • Use projected coordinate systems for areas, buffers and dissolves
  • Search a STAC catalogue and stream a Sentinel-2 L2A subset (Cloud-Optimized GeoTIFF) with Rasterio
  • Convert Sentinel-2 digital numbers to reflectance (including the post-2022 offset)
  • Compute and interpret NDVI and NDWI
  • Clip rasters to boundaries and compute zonal statistics
  • Save results as GeoTIFF and GeoPackage

Getting Started

Option 2: Download Notebook

Download the Jupyter notebook to run locally or upload to your own Colab:

Download .ipynb File

Requirements for local use:

pip install numpy pandas matplotlib geopandas rasterio pystac-client planetary-computer contextily

Option 3: View Online

You can also view the notebook content below without running any code.


Notebook Preview

NoteInteractive Execution Required

This is a hands-on exercise notebook. For the best learning experience, open it in Google Colab or Jupyter to run the code cells interactively.

Topics Covered

  1. Environment setup (Colab or local) and a short Python recap
  2. GeoPandas with Natural Earth boundaries: inspect, filter, dissolve Metro Manila, 50 km buffer, maps with a basemap
  3. Rasterio + STAC: Sentinel-2 L2A over Puerto Princesa, Palawan from Microsoft Planetary Computer; reflectance conversion, band statistics, true/false colour composites, NDVI
  4. Vector + raster: reprojection, clipping to the Palawan boundary, overlay, zonal statistics, saving results
  5. Best practices (memory, CRS, nodata) and a recap

Prerequisites

Before starting this notebook, ensure you have:

  • Completed the Setup Guide
  • Google account (for Colab)
  • Basic Python knowledge
  • Understanding of Session 3 concepts

Notebook Contents

The full interactive notebook includes:

  • About 30 code cells, all runnable without an account
  • Two exercises (home province map; NDWI water index) with hidden solutions
  • A table of common errors and fixes

Support

During the Training

  • Ask questions in the live session (instructor-led cohorts)
  • Work through the exercises at your own pace

After the Training


Next Steps

After completing this notebook:

  1. ✅ Practice with your own Philippine data
  2. ✅ Move on to Session 4: Google Earth Engine
  3. ✅ Try Notebook 2: Google Earth Engine

Ready to code? Open the notebook in Colab and start learning!