Introducing a new way to review your PRs.

Read the announcement

visgl / luma.gl

High-performance Toolkit for WebGL-based Data Visualization

View on GitHub

30 documents · Updated Nov 20, 2026

docs / gpu-geospatial-workflows

GPU geospatial workflows

The graph module provides GPU workflows for geographic coordinates, discrete global grid systems (DGGS), H3 cells, and raster data. These workflows keep data in graph-owned GPU views and connect projection, query, tile, and analysis stages without requiring a CPU round trip between stages.

System scope

The geospatial part of the graph module turns spatial data into reusable GPU graph work. It covers point and shape relations, coordinate projection, cell-center projection, tiled raster access, and raster analysis. The public entry points are grouped as @luma.gl/graph/geospatial, @luma.gl/graph/gpu-dggs, @luma.gl/graph/gpu-h3, and @luma.gl/graph/gpu-raster.

Capability groups

Each group solves a different spatial problem, but all groups can contribute work to the same GPU command graph.

GroupMain purposeTypical result
GeospatialCompare, measure, and project coordinate rowsDistances, projected positions, or selected point IDs
DGGSTurn packed global-grid cell IDs into geographic positionsLongitude/latitude centers or unit vectors
H3Apply the DGGS workflow to H3 cell IDsValidated H3 cell centers
RasterRead, retain, transform, and measure gridded bandsFiltered bands, regions, statistics, and components

References: modules/…/index.ts• L6-52 modules/…/index.ts• L5-12 modules/…/index.ts• L5-10 modules/…/index.ts• L5-222

Geospatial coordinate workflows

Geospatial coordinate workflows operate on rows of two-dimensional positions. They accept local floating-point positions or longitude/latitude positions and produce row-aligned GPU data that later graph stages can consume.

Coordinate representation and projection

The coordinate layer supports ordinary 32-bit positions and packed 64-bit positions for cases where geographic precision matters. A sinusoidal projection converts longitude/latitude degrees into local x/y distances in kilometres around a chosen origin, so a downstream spatial algorithm can work in a local plane.

The projection is a graph contributor rather than a data owner. It reads one position row and writes one projected row, which makes it suitable as the first stage in a larger graph workflow. Geospatial inputs and outputs must use separate, naturally aligned graph views that belong to the target graph.

References: modules/…/types.ts• L8-29 modules/…/geospatial-utils.ts• L29-47 modules/…/geospatial-utils.ts• L117-180 modules/…/gpu-sinusoidal-projection.ts• L29-47 modules/…/gpu-sinusoidal-projection.ts• L77-139

Spatial measurements and queries

The module provides GPU operations for great-circle distance, pairwise point distance, point-to-segment distance, point-in-polygon tests, and nearest points on linestrings. A point spatial query can select points by bounds, radius, or polygon in two or three dimensions where the predicate supports it.

Queries can use a uniform grid as a broad phase. An indexed query maps the query envelope to a compact cell range, dispatches refinement for those cells, and then applies the exact predicate to each retained row. The range includes adjacent cells so a narrow-phase match on a cell boundary is not lost. Without an index, the query scans the position rows.

Results are written into caller-owned compact ID storage with a count clamped to output capacity and an overflow flag. totalCount records the unclamped number of matches examined. An aligned source-ID column can replace row numbers in the result, while index entries always address position rows. Optional diagnostics report the number of intersected cells and candidate rows; an overflowing index makes the retained candidate set incomplete.

Polygon queries use even/odd ring filling and treat points on a ring boundary as selected. Invalid query values produce no matches. These rules make query output safe for later graph stages, but callers must still check overflow and validity-related diagnostics before treating the result as complete.

References: modules/…/index.ts• L17-52 modules/…/gpu-point-spatial-query.ts• L29-113 modules/…/gpu-point-spatial-query.ts• L177-215 modules/…/gpu-point-spatial-query.ts• L346-567 modules/…/gpu-point-spatial-query.ts• L569-665 modules/…/gpu-spatial-query-types.ts• L8-27

Distance workflows

Distance operations preserve the row relationship between their inputs and output. The Haversine path measures aligned longitude/latitude pairs on a sphere, while the pairwise and point-to-shape paths support local spatial analysis after projection.

This separation lets a workflow choose the right distance model. Use geographic distance for positions on the globe and projected distance for local geometry or planar search.

References: modules/…/gpu-haversine-distance.ts• L25-57 modules/…/index.ts• L17-36

DGGS and H3 workflows

A discrete global grid system (DGGS) represents the globe as indexed cells. The DGGS layer turns indexed cells into positions that can be joined to GPU data, displayed, queried, or passed into later spatial work.

DGGS cell projection

The family-neutral DGGS workflow accepts H3 or A5 cell IDs as split 64-bit values stored in two 32-bit words. It produces either longitude/latitude centers or three-dimensional unit vectors. An optional validity output marks whether each input cell is valid; invalid rows produce zero coordinates rather than plausible geographic values.

The projection is source-aligned. Each cell row maps to one output row, so cell attributes can stay aligned while the workflow changes from indexed cells to coordinates. The output format follows the selected projection, and the cell, output, and validity views must have matching lengths.

References: modules/…/gpu-dggs-cell-projection.ts• L20-38 modules/…/gpu-dggs-cell-projection.ts• L45-99 modules/…/gpu-dggs-cell-projection.ts• L102-147

H3 cell workflow

H3 is the named H3 view of the shared DGGS projection capability. It supplies the H3 family choice while keeping the same output choices: geographic centers or unit vectors.

This path handles H3 cell validity on the GPU. Applications can therefore move from H3 IDs to renderable or queryable positions without a CPU conversion stage.

References: modules/…/gpu-h3-cell-projection.ts• L10-22 modules/…/index.ts• L5-10

Raster workflows

Raster workflows treat a raster as a grid of bands plus explicit spatial metadata. They support tiled data, overview levels, validity and nodata rules, band calibration, neighborhood operations, segmentation, and region measurements.

Raster identity and bands

A raster carries width, height, an affine pixel-to-world transform, pixel interpretation, and optional coordinate reference system (CRS) identity. A band carries its native scalar type, optional validity mask, nodata value, and calibration scale and offset.

The system does not silently reproject or resample raster inputs. Operations that combine rasters require compatible grids and CRS metadata. This keeps the meaning of each pixel explicit as data moves through a workflow.

References: modules/…/types.ts• L8-90 modules/…/gpu-raster.ts• L13-105

Tile acquisition and residency

The tile workflow separates data access from GPU processing. An application-owned tile source supplies decoded CPU tiles. A reader normalizes overview, tile, band, and pixel-window requests. A bounded cache then keeps selected decoded data and uploaded GPU bands resident.

The cache uses leases to keep tiles and compiled tile graphs alive while submitted GPU work can still use them. This makes tile eviction a controlled part of the workflow instead of an implicit resource action.

The tile path supports explicit overview levels. A request can use overview coordinates or level-zero coordinates, and the reader returns the matching pixel bounds and affine metadata.

References: modules/…/gpu-raster-tile-source.ts• L11-104 modules/…/gpu-raster-tile-source.ts• L123-157 modules/…/gpu-raster-tile-cache.ts• L214-375

Tile neighborhoods and halos

Neighborhood operations need source pixels outside a tile's owned core. The halo workflow computes the total receptive field of the planned stages, acquires the intersecting neighbor tiles, assembles their data into an expanded GPU grid, and publishes only the core pixels.

This makes tiled processing match full-grid processing at tile boundaries. The workflow keeps neighboring cores disjoint while allowing a filter, edge operation, or morphology stage to see the pixels it needs.

References: modules/…/gpu-raster-tile-halo.ts• L31-66 modules/…/gpu-raster-tile-halo.ts• L112-189 modules/…/gpu-raster-tile-halo.ts• L225-327

Raster analysis stages

Raster analysis composes source bands, validity masks, and caller-owned outputs into graph stages. The available operations include band arithmetic, neighborhood stencils, blur and convolution, edge detection, morphology, thresholding, contours, histograms, statistics, NDVI, and overview generation.

Most analysis stages preserve a separate validity result. They resolve native nodata and source masks before calibration, then write invalid output as invalid rather than allowing a bad sample to look like a valid measurement.

Analysis needWorkflow role
Combine bandsArithmetic or normalized difference
Use nearby pixelsBordered, nodata-aware neighborhood operation
Find shapesThresholding, contours, or connected components
Summarize valuesLocal or global statistics and histograms
Work at scaleOverview levels, tile cache, and halo assembly

References: modules/…/index.ts• L121-214 modules/…/gpu-raster-band-math.ts• L23-55 modules/…/gpu-raster-neighborhood.ts• L23-65

Regions and connected components

Connected-component analysis turns a binary raster into labeled regions. Region measurement then uses those labels to produce topology counts, intensity summaries, centroids, and affine-coordinate areas.

The workflow keeps topology validity separate from intensity validity. A region can have a valid shape even when some intensity samples are missing. The result is therefore useful for both shape analysis and measurements over incomplete observations.

References: modules/…/gpu-raster-connected-components.ts• L26-67 modules/…/gpu-raster-region-measurements.ts• L33-100

GPU data and projection composition

The common composition unit is a GPU command graph. A stage reads graph data views, writes other graph data views, and declares its resource relationship to the graph. The graph then orders the stages so a projection or spatial result becomes available to the next operation without a CPU readback.

The following flow shows a common path from indexed geographic data to spatial output.

flowchart LR
  A[GPU position or cell IDs] --> B[Projection]
  B --> C[GPU coordinates]
  C --> D[Distance, query, or raster join]
  D --> E[GPU result IDs or measurements]
  E --> F[Render, aggregate, or export]

Shared graph data

Geospatial rows, DGGS cells, raster bands, validity masks, and result columns are all represented as graph-owned GPU data. A workflow can use a projection output as the input to a query or use raster-derived labels as the input to region measurements.

The main boundary is data meaning, not a forced module boundary. Geographic coordinates, projected local coordinates, cell centers, and raster world positions must still use compatible units and spatial reference assumptions before they are combined.

References: modules/…/gpu-sinusoidal-projection.ts• L48-79 modules/…/gpu-dggs-cell-projection.ts• L51-74 modules/…/gpu-raster.ts• L20-57

Spatial workflow selection

Choose the workflow by the input's spatial meaning and the desired downstream result:

  1. Use geographic operations when the input is longitude/latitude and the result must follow the globe.
  2. Project to local x/y when a planar operation is more useful for the working area.
  3. Project DGGS or H3 cells when indexed cells must become positions or vectors.
  4. Use raster workflows when values live on a grid and pixel neighborhoods or regions matter.
  5. Keep validity and coordinate metadata with the result when the next stage depends on them.

For the broader system model, see GPU graph systems. For graph workflow composition, see GPU graph workflows and GPU simple graph. For project-wide projection concerns, see GPU project. For GPU table and data-view context, see GPU data tables. Related execution areas are GPU physics and experimental GPU workflows.

References: modules/…/index.ts• L15-52 modules/…/index.ts• L16-46 modules/…/index.ts• L5-8

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the public subpath exports aligned with the capability groups in modules/…/package.json.
  • When a coordinate or raster operation changes units, update the metadata and downstream assumptions that consume its output.
  • When a query output can overflow, preserve the count, total-count, candidate-count, and overflow contracts for indirect consumers.
  • When query results use application IDs, keep the source-ID alignment separate from the row indices used by the spatial index.
  • When a raster stage changes its receptive field, update halo planning so tile edges receive the same input as full-grid processing.
  • When raster band calibration or validity rules change, check every operation that combines or aggregates that band.

Important failure modes

TriggerConsequenceGuard
DGGS or H3 rows are invalidThe row yields zero coordinates and a failed validity flagConsume the validity output before using projected centers
A spatial query has invalid bounds, radius, or coordinatesThe query produces no matches and zero work diagnosticsValidate query inputs before treating an empty result as meaningful
Spatial query output capacity is too smallThe count is clamped and some matching IDs are not writtenCheck the overflow flag before treating the ID list as complete
A spatial index overflowsIndexed candidate and total counts describe only retained rowsCheck the index overflow state before treating indexed results as complete
Raster inputs have different grid or CRS metadataThe combined operation is rejected instead of silently transforming dataAlign grids explicitly before combining bands
A tiled neighborhood lacks its required haloResults near tile borders differ from full-grid resultsPlan and acquire the cumulative stage halo
Connected-component work does not converge within its round budgetLabels and validity are clearedTreat the convergence result as part of the component output

Key files

FileWhy to read it
modules/…/index.tsPublic surface for coordinate projection, distances, point relations, and spatial queries
modules/…/geospatial-utils.tsShared coordinate formats, graph-view checks, and precise geospatial kernel rules
modules/…/gpu-point-spatial-query.tsPoint selection model, indexed broad phase, source IDs, polygon predicates, and query diagnostics
modules/…/gpu-dggs-cell-projection.tsShared H3/A5 cell-to-position workflow
modules/…/gpu-h3-cell-projection.tsH3-specific entry point for the shared DGGS path
modules/…/gpu-raster-tile-source.tsTile request, overview, coordinate, and decode boundary
modules/…/gpu-raster-tile-cache.tsTile and compiled graph residency model
modules/…/gpu-raster-tile-halo.tsNeighborhood planning across tile boundaries
modules/…/index.tsPublic surface for raster analysis and tile workflows