s2-geometry-spatial-indexing

Index and query geospatial data using Google's S2 Geometry library.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/copyleftdev/sk1llz --skill s2-geometry-spatial-indexing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: s2-geometry-spatial-indexing
Source: https://github.com/copyleftdev/sk1llz/tree/main/domains/geospatial/s2-geometry
Command: npx skills add https://github.com/copyleftdev/sk1llz --skill s2-geometry-spatial-indexing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of efficiently indexing and querying vast amounts of geospatial data on a sphere, enabling fast location-based searches and analyses.

Core Features & Use Cases

  • Spherical Geometry: Works directly on the sphere without projection distortions.
  • Hierarchical Indexing: Uses a 30-level cell hierarchy for multi-resolution data.
  • Locality Preservation: Employs Hilbert curves to ensure nearby points have nearby index values.
  • Use Case: Building a ride-sharing app that needs to find all available drivers within a 5km radius of a user's current location in real-time.

Quick Start

Use the s2-geometry skill to find all cells within level 16 that cover the bounding box defined by coordinates (37.7, -122.5) and (37.8, -122.4).

Frequently Asked Questions about s2-geometry-spatial-indexing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does S2 geometry spatial indexing work for location-based services?

S2 geometry spatial indexing works by decomposing the sphere into hierarchical cells using Hilbert curves, ensuring nearby points share nearby 64-bit integer cell IDs for efficient range queries. This locality preservation enables fast proximity searches without projection distortions.

When do I need spatial indexing with Hilbert curves for geospatial data?

You need spatial indexing with Hilbert curves for geospatial data when performing real-time proximity searches, such as finding available drivers within a radius. Hilbert curves preserve locality by mapping 2D spherical geometry to 1D values, enabling fast range queries.

How do I index geospatial data to find points within a bounding box using S2 cells?

To index geospatial data within a bounding box, generate S2 cell IDs at a specific hierarchy level that cover the target coordinates. These 64-bit integer cell IDs facilitate efficient range queries to retrieve all indexed points within the specified boundaries.

Can I use spherical geometry for geofencing without map projection distortions?

Yes, you can use spherical geometry for geofencing without projection distortions. S2 geometry operates directly on the sphere, utilizing hierarchical cell decomposition to maintain accuracy for location-based services and geographic sharding across the entire globe.

What is the best way to perform proximity searches on spherical geometry for a ride-sharing app?

The best way to perform proximity searches on spherical geometry is using S2 cell IDs. By leveraging a 30-level cell hierarchy, you can efficiently execute range queries to find nearby points within a specified radius for real-time location-based services.

Does S2 geometry spatial indexing support multi-resolution data queries?

Yes, S2 geometry spatial indexing supports multi-resolution data queries through its 30-level hierarchical cell decomposition. This allows you to query geospatial data at varying levels of detail, optimizing both broad regional searches and highly localized proximity checks.