Spatial Indexing: Google S2 vs Uber H3 Explained

Picture of Jeffrey Liu

Jeffrey Liu

Geographic Information System (GIS) Engineer
Spatial Index: Google s2 vs Uber h3

Geospatial applications operate at massive scales, requiring efficient ways to analyze relationships across millions of data points.

Finding the nearest point using a naive approach—calculating distances against every point in a dataset—becomes exponentially slow as data grows. Ideally, we want to isolate candidate subgroups before running distance calculations.

Two example sets of points – you can imagine how big of a headache this can become with more data

In market analysis use cases, raw data is rarely uniform. Working with sparse or biased datasets requires standardizing locations so trends can be generalized reliably.

A spatial index solves this by grouping continuous coordinates into distinct spatial ‘folders’ (grid tiles or cells). Instead of querying millions of individual coordinates, search algorithms query specific indexed regions, transforming continuous geospatial data into structured, efficient, and scalable units.

Splitting our nodes into a grid allows us to determine the likelihood of the closest point lying within a certain tile

Google’s S2 Index: The Grid-Based Solution

The most intuitive way to divide the Earth is a grid system aligned with latitude and longitude.

This is the design behind Google’s S2 index, which projects the Earth’s sphere onto a cube and subdivides it into square tiles. The S2 framework is hierarchical: each square recursively divides into four smaller sub-squares down to a resolution of ~1 cm².

While S2 served as an industry standard in the mid-2010s, especially after Google open-sourced it in 2017, it carries inherent structural drawbacks. Notice below the distortion in the latitude lines as they conform to S2’s divisions. This distortion means that even though the area of divisions stay equal, their shapes are not uniform.

A 3D model of the S2 projection
A flattened version showing an additional two resolution layers deeper

Key Characteristics of S2

  • Grid Topology: S2 indexes the map using a grid of squares.
  • Spherical Distortion: Projecting a sphere to a cube alters shape uniformity across geographic regions.
  • Exact Containment: Prioritizes strict parent-child cell boundaries over geometric uniformity.

Uber’s H3 Index: A Hexagonal Refinement

To solve the geometric limitations of square grids, Uber introduced the H3 index in 2018. H3 replaces S2’s grid system with a hexagonal lattice projected onto an icosahedron (a 20-sided polyhedron).

A 3D model of the H3 projection
A flattened version showing one resolution layer deeper

Being a better approximation of the Earth’s geometry, H3 experiences significantly less area and shape distortion. H3 retains the hierarchical design of S2 as each hexagon is subdivided into seven equivalent hexagons.

You may notice the topology is imperfect—subregions clip across parent tile boundaries, making H3 less ideal for strict containment constraints. Additionally, tiling a sphere requires 12 supplementary pentagons alongside hexagons to complete the icosahedron geometry. Strategically placed over oceans (such as off the Horn of Africa), these pentagons minimize real-world impact.

💡 Fun Fact: Locations of pentagonal tiles were inherited from the Dymaxion projection’s joining vertices to ensure none lay over land.

Moreover, hexagonal grids provide a major mathematical advantage: equidistant neighbor traversal. Every hexagonal cell shares an equal-length edge with all 6 surrounding neighbors. Square grids (like S2) have 8 neighbors divided into two classes: edge neighbors and diagonal/vertex neighbors, complicating distance and smoothing algorithms.

Neighbor relationships between S2 and H3

Key Characteristics of H3

  • Hexagonal Lattice: H3 indexes the map using hexagonal tiles.
  • Geometric Uniformity: Minimizes distortion, allowing for faster distance calculations and more accurate comparison between tiles.
  • Approximate Hierarchy: Aperture-7 child hexagons clip parent borders, requiring careful handling during strict bounding queries.

S2 vs. H3 Index Comparison

S2 IndexH3 Index
DeveloperGoogleUber
High-Level GeometryCubeIcosahedron
Tile ShapeSquare tilesHexagonal tiles with a limited few Pentagonal tiles
Subdivision4 Squares7 Hexagons
Smallest Tile~0.7 cm2~0.9 m2
Tile Neighbors8 – Edge neighbors and vertex neighbors6 – Only edge neighbors
Best Use CaseContainment, geometry indexing, and strict bounding box queriesSpatial analytics, data smoothing, mobility modeling, region-to-region comparison and gradient representation

Real-World Application: How We Apply H3 Index in Enterprise Analytics

Spatial indices are fundamental to platform engineering, particularly in tools like MasterScape designed to transform continuous geographic datasets into actionable location intelligence.

By utilizing the H3 spatial index within MasterScape, we address core spatial data challenges through several key optimizations:

  • Fair Geographic Comparisons: Unlike arbitrary postal codes or distorted S2 grid cells, H3’s geometric uniformity ensures every region is directly comparable.
  • Hyper-Local Granularity: MasterScape leverages H3 resolutions down to 24 m² (roughly the size of a single-car garage), unlocking precise local data modeling.
  • Accurate Trend Gradients: Because all neighboring H3 tiles are equidistant, trend models smoothly reflect spatial shifts without the vertex-stretching distortions common to square grids.
  • Site Selection & Opportunity Scoring: MasterScape calculates site suitability—factoring in foot traffic, brand footprint, and competitor density—into a unified Opportunity Score.
  • Multi-Scale Spatial Analysis: High-resolution hexagonal tiling allows developers and analysts to evaluate localized candidate plots (e.g., specific tiles between Wan Chai and Causeway Bay) while preserving macro-level district trends (e.g., broad demand across Tsim Sha Tsui).
Analyzing areas of opportunity within MasterScape (Green indicates strong fits for a new coffee shop location)

Data is only as useful as your representation allows it to be. With H3, we are able to return intuitive, legible, and accurate representations of MasterScape’s analyses.

Frequently Asked Questions (FAQ)

What is a spatial index?

A spatial index is a data structure optimized for geospatial data points, often utilizing location data to group together points to increase access and search efficiency.

What is the S2 spatial index?

The S2 index is a grid-based spatial index that projects the Earth onto a cube, creating a hierarchical system of squares which group together data points according to location within these nested tiles.

What is the H3 spatial index?

The H3 index projects the Earth onto an icosahedron and uses nested hexagonal lattices to store data points dependent on which tiles they are located inside.

What advantages does H3 have over S2?

H3’s tiles are significantly more uniform in shape which allows for more acute comparisons between tiles. Additionally, all neighboring tiles will be the same distance away from the central tile allowing for faster distance-based calculations.

When is S2 used over H3?

S2’s rigid boundaries ensure that a data point’s parent tile will be consistent between all resolution levels making S2 an ideal choice for boundary-sensitive applications.

How is a spatial index used in market analysis?

MasterScape relies on spatial indexing to discretize areas represented by data, revealing trends that can be easily visualized and used to create actionable insights.

Leave Us Your Message
We are ready to talk!

思想科技 Master Concept
微信公众号:Master_Concept

Can't Find What You Need? Join Our Latest Event!

Be the first to learn about
New Trends