Morecantile

7.0.3 · active · verified Wed Apr 15

Morecantile is a Python library for constructing and using map tile grids, also known as TileMatrixSet (TMS). It extends the functionality of libraries like mercantile by supporting a wider range of TileMatrixSet grids beyond just Web Mercator. The library is currently at version 7.0.3 and maintains an active release cadence, providing tools to work with OGC TMS specifications (currently TMS 2.0).

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a predefined TileMatrixSet, create a Tile object, and retrieve its bounding box in both the TMS's native CRS and in a geographic CRS.

import morecantile

# Get a default TileMatrixSet (TMS) like WebMercatorQuad
tms = morecantile.tms.get("WebMercatorQuad")

# Define a tile (Z, X, Y)
tile = morecantile.Tile(x=10, y=10, z=4)

# Get the bounding box of the tile in the TMS's CRS (e.g., EPSG:3857 for WebMercatorQuad)
xy_bounds = tms.xy_bounds(tile)
print(f"Tile {tile} XY Bounds: {xy_bounds}")

# Get the bounding box of the tile in Geographic CRS (e.g., EPSG:4326)
geographic_bounds = tms.bounds(tile)
print(f"Tile {tile} Geographic Bounds: {geographic_bounds}")

# List available default TileMatrixSets
print(f"Available TMS grids: {morecantile.tms.list()[:3]}...")

view raw JSON →