Skip to main content

macrostrat.raster_index

An index of cloud-optimized rasters (COGs), grouped into named layers that a tile server can serve as single mosaics.

Nothing here stores pixels. A row in raster_layers.raster is a reference to a COG in object storage plus the metadata needed to decide whether reading it is worthwhile for a given tile: its footprint, its native zoom range, and its data type. The schema name is raster_layers rather than raster/rasters to stay clear of PostGIS Raster's vocabulary.

Serving these layers is macrostrat.raster_layers.

Usage

from macrostrat.raster_index import RasterIndex, LayerDefinition

index = RasterIndex("postgresql://localhost:5432/macrostrat")
index.create_schema()  # or apply `schema_files()` through your own system

index.register_layer(
    LayerDefinition(slug="emit-minerals", name="EMIT mineral maps", maxzoom=14)
)
index.add_raster(
    "https://storage.example.org/rasters/nevada.tif", layer="emit-minerals"
)

index.assets_for_tile(x=180, y=411, z=10, layers=["emit-minerals"])

Schema

schema_files() returns the SQL defining the schema, in application order, so a host application can fold it into its own schema management rather than calling create_schema(). It is tables and indexes only — the selection logic is query text in queries.py, not stored functions, so it ships and versions with the code that calls it rather than being a second artifact to keep in step:

  • raster_layers.layer — a named mosaic, and the defaults its rasters inherit (zoom range, rescale range, colormap).
  • raster_layers.raster — one COG: href, EPSG:4326 footprint, zoom range, dtype/nbands/nodata, and the full reader metadata as info. queries.selection() is the one query behind every lookup — asset selection ordered by layer priority then resolution — composed by RasterIndex into assets_for_tile/assets_for_bbox, should_generate_tile (whether any asset actually resolves at this zoom, for cache warmers and render short-circuits), layer_bounds, footprints (GeoJSON) and footprint_tile (MVT).

CLI

raster-index reads RASTER_INDEX_DATABASE (or DATABASE_URL):

raster-index define-layer emit-minerals --name "EMIT mineral maps"
raster-index scan https://storage.example.org/remote-sensing-data/emit-mineral-maps/ \
  --layer emit-minerals
raster-index set-colormap emit-minerals --from https://storage.example.org/.../nevada.tif
raster-index assets 10 180 411 --layer emit-minerals

The connection is a parameter of the app itself: --database, or those environment variables. A host application that already knows its own connection (Macrostrat mounts these as macrostrat raster) calls set_default_connection(url_or_callable) once, and its users never pass --database — though it still works, and still wins. Scanning object stores needs the s3 extra (boto3), whichever URL form you use — an https:// bucket URL is rewritten into an endpoint/bucket/prefix and listed through the same S3 API, rather than being a second code path.

Known limitations

  • Footprints are bounding boxes, so rasters crossing the antimeridian are indexed incorrectly. The column is typed geometry, not polygon, so a mask-derived footprint can replace them without a migration.
  • WebMercatorQuad only. Alternate tile grids (and non-Earth bodies, as in mars-tiler) would need a per-grid bounds table.

Download files

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

Source Distribution

macrostrat_raster_index-0.1.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

macrostrat_raster_index-0.1.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file macrostrat_raster_index-0.1.1.tar.gz.

File metadata

  • Download URL: macrostrat_raster_index-0.1.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for macrostrat_raster_index-0.1.1.tar.gz
Algorithm Hash digest
SHA256 df4bd6f392424d5a6b0672b12e280b8f8cd4f8a8f0c9fa5c53e75f59b971086b
MD5 a048243d72377b701cff0c5e35133602
BLAKE2b-256 45278ae75a11c9bd58b3a1fc5d767b2e83ce139048e314a91b863e4361bd80e9

See more details on using hashes here.

File details

Details for the file macrostrat_raster_index-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: macrostrat_raster_index-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for macrostrat_raster_index-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06a38a82d0af3f920e0ceef33b6de098d8f088e2a7c816ad6e70cf0e4e41017d
MD5 f622e954ab18c1330cf756d4c68936ec
BLAKE2b-256 84548d95be8f3d3a96f9cbf363bd61f5c5d959fc9d4f936e19182b2bbf16a317

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.1 This release

2 files

0.1.0

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