# A Comprehensive Guide to S2 Cells and Pokémon GO

Pokémon GO is built on top of S2 cells. This article explains how S2 cells work, what are S2 cells and how S2 cells work in the context of Pokémon GO.

S2 cells are a mathematical mechanism that helps computers translate Earth’s spherical 3D shape into 2D geometry. You can think about them as tiny units of geography that computers understand and developers love to use.

S2 cells were first produced in 2005 by Eric Veach, a Google engineer who used David Hilbert’s “space filling curve” to translate Earth’s shape into 2D space. We will not go into how Hilbert’s curve works, but, in a nutshell, it allows you to fill any 2D space with a single, uninterrupted line. Jeff Dean, a senior Google fellow, has shared the following about the S2 cell system:

Within Google we use a clever library built by Eric Veach to identify regions on the surface of the earth. It internally uses 64 bit numbers to uniquely identify cells, with sizes ranging from millimeters to hundreds of kilometers on a side, using projections of spheres onto the surfaces of cubes, quadtrees, and enumeration of positions on Hilbert space filling curves. This is one of my favorite libraries at Google.

S2 cells are not “magical” in any way, but they do have a few useful properties:

• they come in various sizes called “levels” (higher level = smaller size)
• they are hierarchical, or in other words, a larger cell can be broken down into multiple smaller ones
• they are indexed and each cell has a unique number, which is very handy for software developers

This is how Level 12 cells are organized over Split, a beautiful city in Croatia:

## How S2 Cells Influence Pokémon GO

Up to this date, the Pokémon GO research community has managed to identify several ways in which Niantic uses the S2 cell system to build and enhance our game experience. As you will see from the list below, S2 cells are the secret underpinning of everything you interact with in Pokémon GO.

Trainer Tips has an excellent video on the subject:

Here are how S2 cells influence Pokemon GO:

• Only one PokeStop or one Gym in a Level 17 cell. There can be multiple Ingress portal in an L17 cell, but only one Point of Interest in Pokemon GO.
• Gyms are decided in Level 14 cells. Each level 14 cell contains 64 Level 17 cells, so up to 64 PoI in Pokemon GO. The number of PoIs determines the number of Gyms in Pokemon GO:
PokeStops (PoIs) Gyms
1 0
2-5 1
6-19 2
20-34 3
• EX raids are controlled by Level 13 cells. Only one gym in each Level 13 cell can host an EX raid in any given week.
• Level 20 cells are used to decide whether or not a gym that is on the boundary of a park is eligible for EX raids.

A list of confirmed S2 levels and their role in Pokémon GO:

• Level 10 cells are used to determine Pokémon caught location
• Level 10 and 11 cells are used to determine the current weather conditions
• Level 13 cells are used in the EX Raid system distribution, as explained in our comprehensive guide on how to trigger EX Raids
• Level 14 cells are used to determine the number of gyms in a cell (see above). Once you reach a certain threshold of PokeStops in the L14 cell, the game will convert one of them into a Gym
• Level 15 cells are used to block military zones from the game
• Level 16 cells are used to render the overworld map, rendering Gyms and Stops within a 500-meter radius of your current location
• Level 17 cells are used to determine whether a Wayspot will be imported from the Lightship map into Pokémon GO
• Level 20 cells are used to generate Pokémon spawns. Pokémon always spawn in the center of Level 20 cells.

There are more potential usages for S2 cells which haven’t been confirmed to this date but are very likely: regional Pokémon boundaries, geo-blocking certain countries (China), biome generation and more.

## Further Reading

For those who want to go more in-depth, we recommend reading the following articles and slides:

### Author & tags

Zeroghanhttps://pokemongohub.net/
Zeroghan started the Hub in July 2016 and hasn't had much sleep since. A lover of all things Pokémon, web development, and writing.
Posted in
Tags

### Buy GO Hub merch

Get your very own GO Hub t-shirt, mug, or tote.