s2
s2-postgis · PL/Python functions for converting latitude/longitude to S2 cell IDs and tokens and navigating the S2 cell hierarchy
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100145 | s2 | s2-postgis | 0.0.2 | GIS | MIT | Python |
| Relationships | |
|---|---|
| Requires | plpython3u |
Usage
Sources:
s2 version 0.0.2 is a PL/Python wrapper around the Python s2sphere package. It converts latitude/longitude values to signed bigint S2 cell identifiers or text tokens, converts them back, and exposes validity, level, parent, child, neighbor, containment, and intersection helpers.
Example
Install a PostgreSQL-matched plpython3u package and make s2sphere importable by the server’s Python runtime, then run:
Despite being cataloged as pure SQL, every functional entry point executes untrusted PL/Python and imports a host Python dependency. Only a superuser should install or control plpython3u; pin and audit the exact Python environment. The 2018 repository has no current PostgreSQL, Python, or s2sphere compatibility matrix. S2 cells are hierarchical approximations, so use exact geometry predicates when correctness depends on a true spatial boundary.