This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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:: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
NewerOlder