{"library":"s2sphere","title":"s2sphere","description":"s2sphere is a Python implementation of a part of Google's C++ S2 Geometry Library. It provides tools for working with spherical geometry, such as mapping points and regions on a sphere to a 1D index, enabling scalable proximity searches on distributed indexes. The current version is 0.2.5, and it maintains an active release cadence, primarily via updates to its GitHub repository and PyPI package. [1, 2, 3]","language":"python","status":"active","last_verified":"Tue May 12","install":{"commands":["pip install s2sphere"],"cli":null},"imports":["import s2sphere","s2sphere.LatLon.from_degrees(latitude, longitude)"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import s2sphere\n\n# Define two points using latitude and longitude\np1 = s2sphere.LatLon.from_degrees(33, -122)\np2 = s2sphere.LatLon.from_degrees(33.1, -122.1)\n\n# Create a region coverer\nr = s2sphere.RegionCoverer()\n\n# Get the S2 cells covering a LatLon rectangle defined by the two points\ncell_ids = r.get_covering(s2sphere.LatLonRect.from_point_pair(p1, p2))\n\n# Print the resulting cell IDs\nprint(f\"S2 Cell IDs covering the region: {cell_ids}\")\n\n# Example: Convert a CellId to LatLon\nif cell_ids:\n    first_cell_id = cell_ids[0]\n    center_latlon = s2sphere.LatLng.from_point(s2sphere.Cell(first_cell_id).get_center())\n    print(f\"Center of the first cell ({first_cell_id.to_token()}): {center_latlon.degrees()}, {center_latlon.lngdegrees()}\")","lang":"python","description":"This quickstart demonstrates how to use `s2sphere` to find S2 cells covering a geographical region defined by two latitude-longitude points. It then shows how to convert one of these cell IDs back to its center latitude and longitude. [1, 3]","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-12","installed_version":null,"pypi_latest":"0.2.5","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.2,"avg_import_s":0.04,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.7,"disk_size":"22.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":2.3,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"22M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.9,"disk_size":"24.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":2.1,"import_time_s":0.04,"mem_mb":1.9,"disk_size":"25M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.7,"disk_size":"16.2M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":2,"import_time_s":0.06,"mem_mb":1.7,"disk_size":"17M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2,"disk_size":"15.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":2.1,"import_time_s":0.05,"mem_mb":1.8,"disk_size":"16M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.6,"disk_size":"21.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"s2sphere","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":null,"install_time_s":2.3,"import_time_s":0.03,"mem_mb":1.6,"disk_size":"22M"}]}}