Learn to build geospatial foundation models from scratch through hands-on implementation
π View Course Website | π Installation Guide | π€ Contributing
- Browse the course: https://kcaylor.github.io/GEOG-288KC-geospatial-foundation-models
- Set up your environment: Follow installation/README.md
- Start learning: Begin with Week 1: Geospatial Data Foundations
- Get the code:
git clone https://github.com/kcaylor/GEOG-288KC-geospatial-foundation-models.git && cd GEOG-288KC-geospatial-foundation-models - Install dev env:
make install-dev(creates/updates the conda env and installs in editable mode) - Register kernel:
make kernelspec(once, to add thegeoaiJupyter kernel) - Edit content: Modify
.qmdfiles inbook/chapters/, preview withmake preview - See our guides: AUTHORING_GUIDE.md and CONTRIBUTING.md
git clone https://github.com/kcaylor/GEOG-288KC-geospatial-foundation-models.git
cd GEOG-288KC-geospatial-foundation-models
make install-dev # Create/update env and install package
make kernelspec # Register Jupyter kernel (one time)
make preview # Build and serve locallyNeed help? Check installation/TROUBLESHOOTING.md or course Slack.
Running on HPC?
- Students: See HPC_QUICKSTART.md for quick fixes
- Instructors: See SEND_TO_ADMIN_README.md for shared kernel setup
- Complete guide: GDAL_PROJ_HPC_TROUBLESHOOTING.md
Build geospatial foundation models from scratch in 10 weeks - from raw satellite data to deployable ML models.
ποΈ Weeks 1-3: Build the Architecture
- Week 1: Handle geospatial data (STAC, normalization, patches)
- Week 2: Implement attention mechanisms for satellite imagery
- Week 3: Assemble complete Vision Transformer for geospatial data
π₯ Weeks 4-7: Train Foundation Models
- Week 4: Masked autoencoder pretraining (like MAE, but for Earth data)
- Week 5: Optimize training loops and hyperparameters
- Week 6: Evaluate and visualize model performance
- Week 7: Load and fine-tune existing models (Prithvi, SatMAE)
π Weeks 8-10: Deploy and Apply
- Week 8: Fine-tune for specific tasks (classification, segmentation)
- Week 9: Build inference pipelines and deployment tools
- Week 10: Present final projects
- Python package (
geogfm/) with complete GFM implementation - Working models trained on real satellite data
- Deployment tools for running inference at scale
- Course website with all materials and examples
We use Quarto + tangle filter to create both educational content AND working code from the same source.
book/chapters/c01-*.qmd β [Build Process] β π Course Website (docs/)
β β π Python Package (geogfm/)
Why this is awesome:
- Students get: Beautiful course website + working Python package
- Instructors get: One source of truth (no copy-paste hell)
- Everyone wins: Content and code always stay in sync
geoAI/
βββ book/ # π Course content (.qmd files)
β βββ chapters/ # π» Weekly sessions (c01-c10)
β βββ extras/ # π Cheatsheets, examples, projects
βββ geogfm/ # π§ Generated Python package
βββ docs/ # π Generated website
βββ data/ # π Sample datasets
βββ installation/ # π§ Setup scripts
What to edit: book/ directory (.qmd files)
What gets generated: geogfm/ and docs/ (don't edit these!)
# First time setup
make install-dev # Create/update env and install package
make kernelspec # Register Jupyter kernel
# Daily workflow (instructors)
make preview # Edit content + preview in browser
make docs # Quick build (changed files only)
make docs-full # Complete rebuild (when things break)
# Troubleshooting
make clean # Clear cache and temp files
make kernelspec # Fix Jupyter kernel issuesMost useful: make preview rebuilds automatically as you edit!
---
title: "Session Title"
subtitle: "Week N: Specific Topic"
jupyter: geoai
---
## Overview
What students will learn...
### Data Loader β `geogfm/data/loaders.py`
```{python}
#| tangle: geogfm/data/loaders.py
# This code gets extracted to the Python package!
def create_dataloader(dataset, batch_size=32):
return DataLoader(dataset, batch_size=batch_size)Explanation of the code...
### The Tangle System
- **`#| tangle: path/to/file.py`** β Code block gets written to that file
- **`#| mode: overwrite`** β Replace file contents
- **`#| mode: append`** β Add to existing file
- **Section headings** should include file paths for clarity
### Example Code Block
````markdown
### Attention Module β `geogfm/modules/attention.py`
```{python}
#| tangle: geogfm/modules/attention.py
import torch.nn as nn
class MultiHeadAttention(nn.Module):
def __init__(self, embed_dim, num_heads):
super().__init__()
self.embed_dim = embed_dim
self.num_heads = num_heads
Students see this content in the course website AND get working code in the `geogfm` package!
---
## π§ͺ Course Data Pipeline
We include a powerful system for building reproducible satellite datasets:
```bash
# Quick dataset for course (120 scenes)
make data-course COURSE_TARGET=120
# Preview what would be downloaded
make data-course-dryrun COURSE_TARGET=120
# Full dataset (no limits)
make data-course
```
**Features:**
- Queries STAC APIs (Microsoft Planetary Computer, etc.)
- Filters by area, date, cloud cover
- Creates balanced train/val/test splits
- Reproducible with fixed random seeds
---
## π Common Issues & Solutions
| Problem | Solution |
|---------|----------|
| Build fails | `make clean && make docs-full` |
| "Kernel not found" | `make kernelspec` |
| Import errors | `pip install -e .` |
| Preview not updating | Check syntax errors in `.qmd` files |
| Environment issues | `conda activate geoAI` |
**Pro tip:** Most problems are solved with `make clean && make install-dev`
---
## π For Different Audiences
### Students
- **Start here**: [Course website](https://kcaylor.github.io/GEOG-288KC-geospatial-foundation-models)
- **Get help**: [Installation guide](installation/README.md) and [Troubleshooting](installation/TROUBLESHOOTING.md)
- **Ask questions**: Course Slack or office hours
### Instructors/TAs
- **Content editing**: [AUTHORING_GUIDE.md](AUTHORING_GUIDE.md)
- **Code quality philosophy**: [.claude/PRODUCTION_READY_CODE_PHILOSOPHY.md](.claude/PRODUCTION_READY_CODE_PHILOSOPHY.md)
- **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md)
- **Technical issues**: [installation/TROUBLESHOOTING.md](installation/TROUBLESHOOTING.md)
### Developers
- **Package code**: Browse `geogfm/` for ML implementations
- **Build system**: Check `book/build_docs.py` and `Makefile`
- **Data pipeline**: See `data/build_from_stac.py`
---
## π€ Contributing
We welcome contributions! Whether you're:
- π **Fixing bugs** in content or code
- β¨ **Adding examples** or explanations
- π **Improving documentation**
- π― **Creating new exercises**
**Process:**
1. Fork the repo and create a branch
2. Make your changes in `book/` directory
3. Test with `make preview` and `make docs-full`
4. Submit PR with clear description
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
---
## π Deployment
### GitHub Pages (Automatic)
1. Push changes to `main` branch
2. GitHub Actions builds the site automatically
3. Site available at: `https://kcaylor.github.io/GEOG-288KC-geospatial-foundation-models`
### Manual Build
```bash
cd book
python build_docs.py --full # Build everything
git add docs/ && git commit -m "Update site"
git push origin main # Deploy
```
---
## π§ Technologies Used
- **[Quarto](https://quarto.org/)**: Reproducible publishing system
- **[PyTorch](https://pytorch.org/)**: Deep learning framework
- **[TorchGeo](https://github.com/microsoft/torchgeo)**: Geospatial ML utilities
- **[STAC](https://stacspec.org/)**: SpatioTemporal Asset Catalog for data discovery
- **Custom tangle filter**: Exports code from course content to Python package
---
## π License & Acknowledgments
**License:** MIT License - see [LICENSE](LICENSE) file
**Inspired by:**
- [Prithvi](https://github.com/NASA-IMPACT/Prithvi-100M) - NASA's geospatial foundation model
- [SatMAE](https://github.com/microsoft/SatMAE) - Microsoft's satellite masked autoencoder
- [timm](https://github.com/huggingface/pytorch-image-models) - PyTorch image models
**Course:** GEOG 288KC at UC Santa Barbara, Fall 2025
---
**π Ready to build your own geospatial foundation model? [Get started now!](https://kcaylor.github.io/GEOG-288KC-geospatial-foundation-models)**
---
## π Branching Strategy
We are re-architecting the course materials for the upcoming term, while preserving the current βfrom scratchβ book and package implementation.
- **Archive branch**: `from_scratch_book`
- Snapshot of the current end-to-end book and `geogfm/` package built during spring/summer development
- Safe place to cherry-pick examples and utilities as the new architecture evolves
- CI and the site can be built from this branch if needed
- **Active development**: `main`
- All work for the Fall course runs on `main`
- Feel free to copy or cherry-pick small, self-contained edits from `from_scratch_book`
Common flows:
```bash
# Switch to archived implementation
git fetch origin
git switch from_scratch_book
# Cherry-pick a specific commit back into main
git switch main
git cherry-pick <commit_sha>
# Create a PR comparing the archive to main
git switch -c compare-archive
git merge --no-ff origin/from_scratch_book # or use GitHub's compare UI
```
Notes:
- Keep new work on `main` focused on the revised structure and APIs.
- When migrating lessons, prefer incremental PRs and ensure `make docs` and tests pass.
- If you need to rebuild the archived site: `git switch from_scratch_book && make docs-full`.