Skip to main content

freezebase

Lightweight geospatial helpers for reproducible MGRS grids and S3-backed raster workflows.

freezebase grew out of large-scale glacier mapping, where scattered areas of interest require several local projections and large raster collections live in object storage.

The centrepiece of freezebase is MGRSGrid: a 10 km grid for the UTM-covered world that gives every MGRS code a dataset-independent target backed by an odc.geo.GeoBox. Rasters resampled to the same code and resolution share their CRS, transform, and shape. See The MGRS grid for the reasoning.

Installation

Requires Python 3.12 or newer, and uv or pip.

freezebase is on PyPI:

# uv
uv add freezebase

# pip
pip install freezebase

S3 support is optional; see Raster and S3 helpers below.

MGRS quick start

Build the 10 km grid covering an area of interest:

from shapely import box

from freezebase.mgrs import MGRSGrid

grid = MGRSGrid(box(8.4, 47.3, 8.6, 47.5))  # Zürich, WGS84
gdf = grid.to_geodataframe()                # mgrs_code, zone, epsg, geometry, ...
square = grid[0]                            # an odc.geo GeoBox per grid square

Each square is an MGRSGeoBox — a subclass of odc.geo.GeoBox carrying the CRS, affine transform, and shape needed to resample any raster onto it. Reconstruct one from its code alone, without building a grid:

from freezebase.mgrs import MGRSGeoBox

square = MGRSGeoBox.from_mgrs("32TMS35", resolution=10.0)  # 1000 x 1000 px, EPSG:32632

Raster and S3 helpers

The raster helpers use Rasterio for local I/O. For object storage, freezebase bridges Rasterio/GDAL with Universal Pathlib, so filesystem operations and raster I/O use the same per-path credentials and endpoint configuration.

Rewrite a local GeoTIFF as a Cloud-Optimized GeoTIFF:

from freezebase.raster import COG_PROFILE, rewrite_tiff

rewrite_tiff("in.tif", "out.tif", profile=COG_PROFILE)             # copy
rewrite_tiff("in.tif", "out.tif", profile=COG_PROFILE, move=True)  # move

The s3 extra

S3 support needs the optional s3fs, fsspec, and boto3 dependencies:

uv add "freezebase[s3]"

Credentials and endpoint configuration travel with each path. Named profiles make it possible to select different stores without attaching raw credential values:

from freezebase.s3 import make_s3_upath

aws_path = make_s3_upath("s3://aws-bucket/data", profile="research")
ceph_path = make_s3_upath(
    "s3://ceph-bucket/data",
    profile="ceph-research",
    endpoint_url="https://objects.example.org",
)

An explicitly selected profile also prevents boto from falling back to ambient AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY values from the shell.

The same configured path works for pathlib-style discovery and Rasterio reads:

from freezebase.raster import rasterio_open

scene = aws_path / "scene.tif"
if scene.exists():
    with rasterio_open(scene) as src:
        data = src.read(1)

Public buckets use anon=True. See Rasters on S3 for authentication patterns, custom endpoints, and S3-to-S3 copies.

Other helpers

Download a file with retries and a progress bar:

from freezebase.download import HTTPDownloader

download = HTTPDownloader(auth=("user", "pass"))
path = download("https://example.org/data.zip", "cache/")  # -> Path

Documentation

Full documentation, including the MGRS grid guide and the S3 raster guide, is at https://lqgentner.github.io/freezebase/.

Support

This is a small internal core library maintained on a best-effort basis. Please file bugs and questions on the issue tracker.

Contributing

git clone https://github.com/lqgentner/freezebase.git
cd freezebase
uv sync --all-extras
uv run pytest

See the contributing guide for the full checks, the S3 integration tests, and how to build these docs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freezebase-0.3.0.tar.gz (64.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freezebase-0.3.0-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

Details for the file freezebase-0.3.0.tar.gz.

File metadata

  • Download URL: freezebase-0.3.0.tar.gz
  • Upload date:
  • Size: 64.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for freezebase-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6ec07fee195d2abc480f9cffd6198a153fb1ee7e13e344f73df9d4336993c260
MD5 d8b7551b724980d7d38aba44f5f38241
BLAKE2b-256 96686ea08be5e9bd6642ee0eb2d69ae577c0879929d787171a66f373876ac5d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for freezebase-0.3.0.tar.gz:

Publisher: publish.yml on lqgentner/freezebase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file freezebase-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: freezebase-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 46.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for freezebase-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9b1371af1f194fd3910336e5781dec9bb7e3b2408794630c3eec73d6205d78b
MD5 837c5bc86e895f33ce60014ee33bf5d1
BLAKE2b-256 2f212e3dd62ce3b1bca4bdfb49c32b4f3c9d390ed8ee4bdb108ea8815c792b83

See more details on using hashes here.

Provenance

The following attestation bundles were made for freezebase-0.3.0-py3-none-any.whl:

Publisher: publish.yml on lqgentner/freezebase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

This release

0.3.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page