S2 coverings on a sphere
medium 4 minS2 projects six cube faces onto the sphere and recursively subdivides cells on those faces.
Video lesson · Chapter 1 of 5
A delivery region crosses the date line
How many cells cover a jagged coastline?
1:12Reel
Theory
Read or listen first. About 1 min.
What it is
S2 maps the sphere onto six cube faces and recursively subdivides each face. A geographic region can be approximated by a collection of cells at different levels.
Refine the cells along a service boundary
Why it exists
Large cells can represent broad interiors cheaply. Refining the irregular edge can reduce the number of points that require an exact polygon check.
Words to know
- Boundary cell
- A cell that intersects a region while also containing area outside it.
How it works
Step through the idea, or press Play.
Start at cube faces. Choose S2 faces intersecting the service area.
Understand it
Worked example
S2 coverings on a sphere in practice
Cover a long coastal service area using large cells in the interior and smaller ones along the coast. A point in a boundary cell still needs the original polygon predicate.
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.
Fetch intersecting cells and check candidates.