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.

The libraries you may use in SDS320

1. Why this ecosystem matters

You do not need to memorize every package on this page today. You do need to recognize the names when they appear in later lessons, and understand roughly what job each one does, so that when something breaks you know which layer of the stack to look at.


2. Core idea

A GeoAI pipeline is built from four rough layers: deep learning frameworks, geospatial data libraries, visualization tools, and higher-level packages that tie the others together. Python has a mature library for each layer, and most GeoAI workflows combine various tools.


3. Main tool families

A. Deep learning frameworks

PyTorch is the most widely used deep learning framework in research and provides the low-level building blocks for defining and training neural networks. torchvision extends it with pre-trained models and image transforms for computer vision. TorchGeo is a PyTorch domain library built specifically for geospatial data: it provides datasets, samplers, and pre-trained models that understand multi-spectral inputs and irregularly-shaped satellite scenes, rather than assuming every image is a fixed-size RGB photo the way general computer vision datasets do.

B. Geospatial data libraries

Rasterio reads and writes raster formats such as GeoTIFF, giving you pixel values as NumPy arrays while preserving CRS and other metadata. GeoPandas extends Pandas with geometric operations for vector data, and Shapely handles the underlying geometry operations (buffering, intersection, union). Underneath most of these sits GDAL/OGR, the C/C++ library that actually reads and writes the file formats. A typical workflow uses Rasterio to load imagery and GeoPandas to load vector labels, then combines the two into training data for a model.

C. Interactive visualization

Leafmap provides a high-level API for interactive maps inside Jupyter, built on backends such as folium and ipyleaflet. It is well-suited to GeoAI work because it can overlay model predictions directly on satellite basemaps and supports side-by-side comparisons, which is useful for visually checking whether a model’s output actually makes sense.

D. High-level, unified packages

The geoai Python package is the central library used throughout this book. It wraps PyTorch, TorchGeo, Rasterio, and GeoPandas into a consistent, higher-level interface for tasks such as object detection, semantic segmentation, and change detection, so you are not stitching together low-level training loops and data loaders by hand for every lesson.

E. Segment Anything for geospatial data

The segment-geospatial package (also called samgeo) adapts Meta’s Segment Anything Model (SAM) for georeferenced imagery, producing vector outputs such as GeoJSON with a proper CRS, rather than plain image masks with no spatial reference. It supports both interactive segmentation (clicking on objects) and automatic mask generation, and is particularly useful for tasks like building or tree-canopy extraction where you have not trained a task-specific model of your own. You will use it directly in L12 – Segment Anything.


4. A typical workflow stack

A simple project might use the tools like this:

Workflow stepPossible tool
Search or download imagerySTAC tools, data APIs, provider portals
Read raster dataRasterio
Read vector dataGeoPandas
Process geometriesGeoPandas, Shapely
Build model-ready chipsRasterio, NumPy, TorchGeo or GeoAI
Train or run a modelPyTorch, GeoAI, samgeo
Visualise inputs and outputsLeafmap, Matplotlib
Save outputsGeoTIFF, GeoPackage, GeoParquet, CSV
Document workflowJupyter Notebook, README, repository

This stack may change from project to project. The important part is that each tool has a clear role.

:caption: A preview of what a geoai workflow can look like (not runnable yet)

# This is illustrative only, no coding is required in this lesson.
# You will write real versions of this starting in later lessons.
import geoai

model = geoai.train_segmentation_model(
    images="path/to/image_chips",
    labels="path/to/masks",
    architecture="unet",
)
predictions = model.predict("path/to/new_area.tif")

5. Common pitfalls


6. Mini task

Match each tool below to the layer of the pipeline it belongs to: data I/O, modeling, visualization, or high-level orchestration.

PyTorch · Rasterio · Leafmap · TorchGeo · geoai · GeoPandas · samgeo


7. Further reading


8. Key takeaways