AlgoViz

Choosing a spatial index

medium 4 min

Start with the query and update pattern.

Video lesson · Chapter 1 of 5

Three maps need different guarantees

0:00 / 4:15

The city dashboard and the dispatcher need different indexes

1:16Reel

Theory

Read or listen first. About 1 min.

What it is

The right geographic index depends on the question. A reporting query assigns locations to buckets. A proximity query compares locations with a moving point and distance threshold.

One set of locations, two different questions

West · 3East · 3Every driver contributes to exactly one zone.
A dispatch dashboard assigns every driver to a stable bucket. The two zones contain three drivers each.

Why it exists

One crossing of a zone edge can change a bucket ID while hardly changing travel distance. Testing points near boundaries reveals whether a design answers the intended question.

Words to know

Candidate set
The locations selected by the index for a later exact check.

How it works

Step through the idea, or press Play.

Step 1 of 3

Describe the query. A dashboard counts trips while dispatch needs nearby drivers.

Understand it

Worked example

Choosing a spatial index in practice

Compare a dashboard counting trips per cell with a dispatcher looking for every driver within 800 metres. The dashboard needs repeatable buckets; the dispatcher needs boundary recall and fresh positions.

Related case

Find every charger across a cell boundary

A driver near the edge of a grid cell requests chargers within 800 metres. The closest charger sits across the street in another cell.

Across the street, across the cell
Chargers on both sides of the streetABCOne cell misses charger B

Fetch intersecting cells and check candidates.

Sources