Skip to content

Instantly share code, notes, and snippets.

View calebrob6's full-sized avatar

Caleb Robinson calebrob6

View GitHub Profile
@calebrob6
calebrob6 / download_s2.py
Created May 9, 2026 05:47
S2 super-resolution with gaussian splats
#!/usr/bin/env python3
"""Download a Sentinel-2 time series from the Microsoft Planetary Computer.
Companion script for the blog post "Super-Resolving Sentinel-2 with Gaussian
Splats" (https://geospatialml.com/posts/sentinel2-superresolution/).
Pulls N cloud-free Sentinel-2 L2A scenes over a configurable AOI, crops to a
common pixel window, and writes one 4-band GeoTIFF per scene (B02 Blue,
B03 Green, B04 Red, B08 NIR; uint16 reflectance in 0..10000).
@calebrob6
calebrob6 / torchgeo_iobench.py
Created May 8, 2026 18:39
Tests IO throughput with torchgeo over different datasets.
#!/usr/bin/env python3
"""Benchmark iteration over the IOBench dataset.
For each requested split (``raw`` and/or ``preprocessed``), this script builds
an :class:`~torchgeo.datasets.IOBench` dataset, wraps it in a
:class:`~torchgeo.samplers.GridGeoSampler` (non-overlapping patches), feeds it
through a :class:`torch.utils.data.DataLoader`, and reports timing information
for one full epoch.
Example usage::
@calebrob6
calebrob6 / load_aef_with_xarray.ipynb
Created March 11, 2026 16:58
How to load parts of the AEF embeddings via xarray
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / compute_aef_block_stats.py
Created February 28, 2026 03:56
Compute per-block AEF embedding stats and PCA rasterization
#!/usr/bin/env python3
"""Compute mean and stdev of Alpha Earth Foundation embeddings per census block.
Required input data
-------------------
1. Census block shapefiles:
- Go to https://www.census.gov/cgi-bin/geo/shapefiles/index.php
- Select year "2025" (or desired year) and layer type "Blocks (2020)"
- Choose a state (e.g. "Washington") and download the ZIP
- Unzip to get tl_2025_53_tabblock20.shp (and companion files)
@calebrob6
calebrob6 / ftw-test.ipynb
Created November 18, 2025 06:23
Example running Fields of The World model with TorchGeo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / dinov3_and_anyup.ipynb
Created November 14, 2025 21:22
Notebook showing how to use the AnyUp model to upsample low (spatial) resolution embeddings.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / size_of_embeddings.ipynb
Created November 13, 2025 00:36
Size of embeddings
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / embed.py
Last active September 22, 2025 19:09
Create embeddings from an input GeoTIFF using DINOv3 and save results as an output GeoTIFF.
import argparse
import math
import os
import time
from typing import List, Optional, Sequence, Tuple
import numpy as np
import rasterio
import rasterio.windows
import torch
@calebrob6
calebrob6 / FTW demo application.ipynb
Created August 12, 2025 23:29
Notebook that shows end-to-end example of running a Fields of the World model on Sentinel-2 imagery and joining with CDL labels and MOSAIKS embeddings.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calebrob6
calebrob6 / lbp.py
Created August 3, 2025 02:07
PyTorch local binary pattern histograms
def batch_histogram(data_tensor, num_classes=-1):
"""
From https://discuss.pytorch.org/t/batched-torch-histc/179741
Computes histograms of integral values, even if in batches (as opposed to torch.histc and torch.histogram).
Arguments:
data_tensor: a D1 x ... x D_n torch.LongTensor
num_classes (optional): the number of classes present in data.
If not provided, tensor.max() + 1 is used (an error is thrown if tensor is empty).
Returns: