Skip to main content

Python library to resolve overlapping issues found in the Sentinel tiling grid.

Project description

s2tiling: Sentinel-2 Tile ID Lookup

This library resolves the overlapping issues found in the Sentinel tiling grid, which is based on MGRS but utilizes 110x110km tiles.

Data Source & Attribution

This software utilizes data from the Copernicus Sentinel-2 mission, produced by the European Space Agency (ESA) and the Copernicus program.

ChangeLog

0.1.0

  • Initial release.
  • Implemented coordinate to tile ID lookup functionality, properly handling areas with overlapping tiles.
  • Supports retrieval of rich metadata, including raw KML descriptions and Shapely geometries (Polygon Z).
  • Includes an optimized internal database based on the official ESA KML grid for offline use.

Installation

You can install the package via pip:

pip install s2tiling

Usage

The library accepts coordinates in WGS84 (Decimal Degrees) format.

Note: On the very first run, the library will extract the grid database to your user cache directory (e.g., ~/.cache/s2tiling). This may take a few seconds. Subsequent runs will be instant.

import s2tiling

# Initialize the locator
s2t = s2tiling.S2TILING()

# Example coordinates (Felcsút, Hungary)
latitude = 47.454442
longitude = 18.585869

# 1. Get the first matching Tile ID
# Returns the first ID from the alphabetically sorted list of matches
first_tile_id = s2t.getFirstTile(latitude, longitude)
print(first_tile_id)
# Output: '33TYN'

# 2. Get the last matching Tile ID
# Returns the last ID from the alphabetically sorted list
last_tile_id = s2t.getLastTile(latitude, longitude)
print(last_tile_id)
# Output: '34TCT'

# 3. Get ALL matching Tile IDs as a list
all_tiles_id = s2t.getAllTiles(latitude, longitude)
print(all_tiles_id)
# Output: ['33TYN', '34TCT']

# 4. Get specific metadata ('name', 'description', 'geometry')
# The default return value is the Tile ID ('name'), but you can query 
# other attributes (e.g., 'geometry', 'description') or a list of them.
first_tile_geometry = s2t.getFirstTile(latitude, longitude, 'geometry')
print(first_tile_geometry)
# Output: GEOMETRYCOLLECTION Z (POLYGON Z ((17.6715394264 47.8226075595 0, 19.1352584753 47.7791570714 0, 19.059029865 46.7936706873 0, 17.6221956555 46.8356557267 0, 17.6715394264 47.8226075595 0)), POINT Z (18.3787270654 47.30813912339999 0))

all_tiles_data = s2t.getAllTiles(latitude, longitude, ['name', 'geometry'])
print(all_tiles_data)
# [{'name': '33TYN', 'geometry': <GEOMETRYCOLLECTION Z (POLYGON Z ((17.672 47.823 0, 19.135 47.779 0, 19.059 ...>}, {'name': '34TCT', 'geometry': <GEOMETRYCOLLECTION Z (POLYGON Z ((18.328 47.823 0, 19.794 47.847 0, 19.817 ...>}]

Features

Offline: Works entirely offline after installation (data is bundled).
Fast: Uses geopandas and spatial indexing for quick lookups.
Simple: No API keys or external services required.

Requirements

Python 3.9 +
geopandas
shapely

License

The source code of this library is licensed under the MIT License.

However, the data contained within (MGRS grid definitions) belongs to the Copernicus program. Please refer to the NOTICE file for full data attribution details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s2tiling-0.1.1.tar.gz (10.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s2tiling-0.1.1-py3-none-any.whl (10.0 MB view details)

Uploaded Python 3

File details

Details for the file s2tiling-0.1.1.tar.gz.

File metadata

  • Download URL: s2tiling-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for s2tiling-0.1.1.tar.gz
Algorithm Hash digest
SHA256 845f330917f5fb9df4f9700bfa6814ba563b114a0f9d2fb77c0090287969151e
MD5 7555bd6af59e938a6d9e890ef32d7f70
BLAKE2b-256 b84a0d79e74828e18a4ec6f7a940b3bb49c5b23245ef86e4853c995794f0cd9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2tiling-0.1.1.tar.gz:

Publisher: deploy.yml on baloghk/s2tiling

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file s2tiling-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: s2tiling-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for s2tiling-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f88e59b3e333ba158eb33369d3fdf9249931adfcd0938172b589551ebae7cffe
MD5 91976e77a90162208804d133b1e96be9
BLAKE2b-256 b52b40656adef3babef0ecc5a22848d731843449ff28b7818fed2895da386dc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2tiling-0.1.1-py3-none-any.whl:

Publisher: deploy.yml on baloghk/s2tiling

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page