Skip to main content

Examples Overview

This section provides practical examples of using GeoBrix for common geospatial workflows — short copy-paste snippets below, plus end-to-end notebook series and app examples.

Notebook Series

End-to-end, runnable notebook walkthroughs. Each links to the notebook source on GitHub.

SeriesWhat it covers
EO SeriesSTAC discovery → band download → gridded (H3) raster tables → multi-band stacking, with Sentinel-2 over Alaska.
Clipping — xViewLoad high-resolution aerial GeoTIFFs and clip rasters per labeled object from the xView dataset.
H3 RasterizeConvert polygon isobands (elevation contours) into a pixel-aligned, multi-band H3 raster stack.
Helios — Tiling to PMTilesFour-notebook San Francisco series: vector, raster basemap, terrain scoring, and a sharded PMTiles mosaic.
Vapor-Eyes — Permian MethaneScreen a satellite methane signal over the Permian Basin down to the leaking operator.

Apps

AppWhat it does
Genie MapDatabricks App (React + kepler.gl) that turns Vapor-Eyes methane gold data into an interactive map you can query by natural language.

Quick Examples

Example 1: Read and Catalog Rasters

from databricks.labs.gbx.rasterx import functions as rx

rx.register(spark)

# Read rasters
rasters = spark.read.format("gdal").load("/data/satellite")

# Build catalog
catalog = rasters.select(
"path",
rx.rst_boundingbox("tile").alias("bounds"),
rx.rst_width("tile").alias("width"),
rx.rst_height("tile").alias("height"),
rx.rst_metadata("tile").alias("metadata")
)

catalog.write.mode("overwrite").saveAsTable("raster_catalog")

Example 2: Spatial Aggregation with BNG

from databricks.labs.gbx.gridx.bng import functions as bx

bx.register(spark)

# Aggregate points by BNG cell
result = spark.sql("""
SELECT
gbx_bng_pointtocell(st_point(longitude, latitude), 1000) as bng_cell,
COUNT(*) as count,
AVG(value) as avg_value
FROM measurements
WHERE country = 'GB'
GROUP BY bng_cell
""")

result.write.mode("overwrite").saveAsTable("bng_aggregated")

Example 3: Migrate from Mosaic

from databricks.labs.gbx.vectorx.jts.legacy import functions as vx

vx.register(spark)

# Convert legacy geometries
legacy = spark.table("legacy_mosaic_table")

migrated = legacy.select(
"*",
expr("st_geomfromwkb(gbx_st_legacyaswkb(mosaic_geom))").alias("geometry")
).drop("mosaic_geom")

migrated.write.mode("overwrite").saveAsTable("migrated_table")
return migrated


if __name__ == "__main__":
print("GeoBrix Examples Overview")
print("=" * 50)
print(f"Total functions: {len([name for name in dir() if callable(globals()[name]) and not name.startswith('_')])}")

Next Steps