Index each GPS ping

This view converts coordinates into resolution-9 H3 cells. At this resolution, cells are roughly neighborhood sized.

CREATE OR REPLACE VIEW points_h3 AS
SELECT id,
       device_id,
       event_time,
       lat,
       lng,
       h3_latlng_to_cell(lat, lng, 9) AS h3_cell
FROM fleet_gps_points;
For large datasets, store the H3 cell in the Delta table instead of calculating it on every read.

Convert service regions into cells

Use h3_polyfill to turn each WKT polygon into the same H3 resolution as the GPS points:

CREATE OR REPLACE VIEW region_cells AS
SELECT region_id,
       region_name,
       UNNEST(h3_polyfill(polygon_wkt, 9)) AS h3_cell
FROM service_regions;
H3 polyfill includes cells whose centers fall inside the polygon. Use a finer resolution for narrow regions.

Join points to regions

The spatial lookup is now a SQL equality join:

SELECT r.region_name,
       COUNT(DISTINCT p.id) AS gps_pings,
       COUNT(DISTINCT p.device_id) AS active_vehicles
FROM points_h3 p
JOIN region_cells r ON p.h3_cell = r.h3_cell
GROUP BY r.region_name
ORDER BY gps_pings DESC;
The same model works for depots, delivery zones, geofences, and city operating areas.

What else can you query?

  • Vehicles entering or leaving a service region.
  • GPS activity by neighborhood or operating zone.
  • Nearby cells with h3_hex_disk.
  • Rollups from detailed cells to larger parent cells.
  • Distance and bearing for depot or delivery analysis.

Choose the resolution deliberately

Higher resolutions produce smaller cells and more precise region matching. Lower resolutions reduce the number of cells and work better for broad operational areas. Keep points and regions at the same resolution before joining them.

Know the scope

H3 works well for point-heavy analytics, aggregation, neighborhood search, and region matching. It is not a full polygon-editing GIS or a GeoParquet implementation. Use a dedicated GIS when advanced geometry editing or topology is the main workload.

Run the fleet demo

The DeltaForge demo library includes 10,000 deterministic GPS pings across five cities, H3 indexing, polygon coverage, grid traversal, and region joins. Start with the demo library or read about H3 geospatial SQL on Delta Lake.