Spatial indexes are hierarchical grid systems that divide the Earth’s surface into discrete cells, each identified by a unique index value. They combine the advantages of both vector and raster data: like raster, they provide a uniform grid covering the entire planet; like vector, each cell is an individual feature that can be queried and joined.
What are Spatial Indexes?
A spatial index assigns every location on Earth to a cell in a global grid. The grid can be made finer or coarser by choosing different resolution levels. Higher resolutions produce smaller cells with more precision; lower resolutions produce larger cells for faster aggregation.
The most widely used spatial index systems are:
- H3 — A hexagonal grid system developed by Uber. Hexagons have uniform distance to all neighbors, making them ideal for proximity analysis and avoiding edge effects common with square grids.
- Quadbin (Quadkey) — A square grid based on the Mercator projection, using a quadtree subdivision. Each zoom level divides cells into four children. Used by many mapping platforms.
- S2 — A spherical grid developed by Google that projects the Earth onto a cube and subdivides each face. Used in BigQuery’s native spatial functions.
- Geohash — A rectangular grid encoding system that represents locations as base-32 strings. Simple but suffers from edge effects and non-uniform cell sizes at high latitudes.
Why Spatial Indexes Matter
Spatial indexes solve two major challenges in geospatial analysis:
Performance — Traditional spatial operations like point-in-polygon or spatial joins require comparing every pair of features, which scales poorly with large datasets. Spatial indexes pre-assign features to grid cells, turning expensive geometric computations into simple integer comparisons and lookups.
Aggregation — When working with millions or billions of point observations (mobility data, transactions, sensor readings), spatial indexes provide a natural way to aggregate data into consistent geographic units for analysis and visualization.
How Spatial Indexes are Used
- Spatial joins at scale — Joining two large datasets by spatial proximity using index-to-index matching instead of geometry-to-geometry intersection
- Tiling and visualization — Rendering large datasets as aggregated grids for map visualization at any zoom level
- Enrichment — Attaching demographic, environmental, or economic data from one grid level to another
- Mobility analytics — Tracking movement patterns by aggregating GPS traces to index cells
- Privacy preservation — Aggregating individual-level data to grid cells to prevent identification
Spatial Indexes in Cloud Data Warehouses
Spatial indexes are particularly valuable in cloud data warehouses because they reduce the computational cost of spatial operations on large tables. CARTO’s Analytics Toolbox provides native support for H3, Quadbin, and S2 indexes in BigQuery, Snowflake, Databricks, and Redshift — allowing analysts to polyfill geometries into index cells, aggregate data, and perform spatial joins using Spatial SQL.



