# S2

S2, like H3, implements an open source, hierarchical, discrete, and global grid system. The systems share a number of similarities, including the use of 64 bit integers as cell indexes, making it very efficient to use both of them in big data systems.

One of the main differences between S2 and H3 is the choice of cell shape. S2 uses square cells while H3 uses hexagonal cells. This leads to several important differences.

## #

NeighborsSquares have two classes of neighbors: those that they share an edge with, and those that they share a point with. This can complicate analysis of moving things in the real world, because they are very unlikely to move in a way aligned with the grid. Instead, the analyst will need to account for different types of neighbors.

Hexagons have only one class of neighbor, that they share an edge with. This makes running convolutions and smoothing over the data much simpler, since only the grid distance (as opposed to the geographic distance) from a cell needs to be considered.

## #

SubdivisionS2 uses an *aperture 4* system where each cell is subdivided into 4 finer, child cells. Squares subdivide exactly into 4 child squares. This means that when indexing a point to an S2 cell, and then truncating to the parent S2 cell, there is no possibility that the point is not contained in the bounds of the parent cell.

This differs from H3 where the same operation is approximate. This is the case because hexagons do not exactly subdivide into 7 child hexagons.

## #

VisualizationS2 cells are squares in the system's projection. When those cells are visualized on a map using a projection like the Web Mercator projection, the cells can subjectively appear distorted (i.e. as a quadrilateral rather than square).

H3 cells have the same non-alignment with the map projection, but in our experience the effect is less noticeable to viewers for hexagons.

## #

Links## #

S2 vs H3 ComparisonS2 on the left, H3 on the right. Data: San Francisco Street Tree List