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).
pip install morecantileVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to version 3.11 or later to use morecantile 7.x.
Update your code to expect WGS84 for GeoJSON outputs, and adjust property access for `tms` and `tms_crs` if you were consuming `grid_name` or `grid_crs`. If you need a different CRS, explicitly set the `geographic_crs` option in the relevant methods.
If your application relies on the previous, more lenient behavior, you can pass `strict=False` to the `is_valid` method: `tms.is_valid(x, y, z, strict=False)`.
If you are defining custom TileMatrixSets using JSON files, update your JSON documents to conform to the TMS 2.0 specification. Alternatively, for older TMS v1 JSONs, use the `TileMatrixSet.from_v1` class method to parse them.
Install the library using pip: `pip install morecantile`
Use a valid TMS identifier from `morecantile.tms.list()` or register a custom TMS. For example: `tms = morecantile.tms.get("WebMercatorQuad")`Ensure the tile coordinates (x, y, z) are within the valid range for the given TileMatrixSet's definition, or use `strict=False` if you want to allow out-of-bounds tiles with a warning instead of an error: `tms.is_valid(x, y, z, strict=False)`.
Adjust the input coordinates to be within the TMS's defined geographic boundaries, or ensure the correct TMS is being used for the given location.