A comprehensive guide to S2 cells and 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 an unique number, which is very handy for software developers

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

Level 12 S2 cells
Level 12 S2 cells (visualized over Split, 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.

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

  • Level 10 cells are used to determine Pokémon caught location
    • Average cell size:  81.07 km2
  • Level 10 and 11 cells are used to determine the current weather conditions
    • Average cell size:  81.07 km2 and 20.27 km2
  • Level 12 cells are used in the EX Raid system distribution, as explained in our comprehensive guide on how to trigger EX Raids
    • Average cell size:  5.07 km2
  • Level 15 cells are used to block military zones from the game
    • Average cell size: 0.079172 km2
  • Level 16 cells are used to render the overworld map, rendering Gyms and Stops within a 500 meter radius of your current location
    • Average cell size: 0.01979317 km2
  • Level 17 cells are used to determine whether an Ingress portal will be imported as a Stop/Gym or not
    • Average cell size:  4948.29 m2
  • Level 20 cells are used to generate Pokémon spawns. Pokémon always spawn in the center of Level 20 cells.
    • Average cell size:  77.32 m2

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 following articles and slides:

  • Geometry on the Sphere: Google’s S2 Library presentation — a great technical and mathematical overview of the S2 system and library
  • S2 Region coverer — arguably the best tool to visualize S2 cells of any level over any area
  • “S2 cells and space-filling curves: Keys to building better digital map tools for cities” by Sidewalk Labs
  • “Google’s S2, geometry on the sphere, cells and Hilbert curve” by Christian S. Perone
  • s2-geometry-library source code by yjwong
  • Hilbert’s curve article on Wikipedia

The post A comprehensive guide to S2 cells and Pokémon GO appeared first on Pokemon GO Hub.

Source: pokemongohub



Summary
Review Date
Reviewed Item
A comprehensive guide to S2 cells and Pokémon GO
Author Rating
5

Leave a Reply

Your email address will not be published. Required fields are marked *