S2 Functions

The following functions are available to process S2 indexes in Studio expressions.

Function Return Type Description
s2IsValid(s2) bool Returns true if the given S2 cell is valid.
geoToS2(lat, lng, level) s2 Returns an S2 index at the given lat/lng coordinate at the specified resolution level.
s2ToLat(s2) real Returns the latitude of the S2 point index.
s2ToLng(s2) real Returns the longitude of the S2 point index.
s2ToGeo(s2) geojson Returns a GeoJSON point feature for the S2 index.
s2ToBounds(s2) geojson Returns a GeoJSON polygon feature for the S2 polygon.
s2ToParent(s2, level) s2 Returns the parent S2 index at the given resolution level.