S2_CoveringCellIds¶
Returns an array of S2 cell IDs that cover the given geography.
Usage¶
array S2_CoveringCellIds(geog: geography)
Arguments¶
- geog (geography): Input geography
Description¶
Returns an array of 64-bit S2 cell IDs that form a covering of the given geography. A covering is a set of cells that completely contains the geography with minimal overlap. For a point, returns an array with a single cell ID. For empty geometries, returns an empty array.
This is useful for spatial indexing and efficient spatial queries. The returned cells may be at different S2 levels depending on the size and shape of the geography.
Examples¶
SELECT S2_CoveringCellIds(ST_GeogFromWKT('LINESTRING (0 0, 1 1)'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ s2_coveringcellids(st_geogfromwkt(Utf8("LINESTRING (0 0, 1 1)"))) │
│ list │
╞══════════════════════════════════════════════════════════════════════════════╡
│ [384307168202282325, 1152921504606846975, 1152991873351024640, 115322057176… │
└──────────────────────────────────────────────────────────────────────────────┘