mercantile
Web mercator XYZ tile utilities
What it is and what it does
Mercantile is a utility library for working with Web Mercator tiles—the standard XYZ grid system used by web mapping platforms. It provides functions to convert between geographic coordinates (longitude/latitude), spherical Mercator coordinates, and tile indices at various zoom levels. It also handles quadkey encoding (Microsoft's tile naming scheme) and lets you traverse tile hierarchies by finding parent and child tiles.
The library is primarily used by GIS developers, map tile servers, and geospatial analysis tools. It includes both a Python API with named tuples for tiles and bounding boxes, and a command-line interface (via click) for batch operations like generating GeoJSON tile shapes or finding tiles that overlap a given region. The package has been stable since 2014 and sees consistent use in the geospatial ecosystem.
Use it for:
- Convert geographic coordinates to tile indices for web map tile servers or slippy map implementations.
- Generate GeoJSON representations of Web Mercator tiles for visualization or analysis.
- Find which tiles intersect a bounding box or geographic region.
- Navigate tile hierarchies to zoom in/out or find neighboring tiles.
- Encode/decode quadkeys for tile identification in mapping APIs.
- Build command-line tools for tile processing using the mercantile CLI.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Mercantile converts between geographic coordinates, Web Mercator tiles (XYZ), and quadkeys, and provides utilities to navigate tile hierarchies and generate GeoJSON tile shapes.
Yes. Mercantile is a stable, well-maintained library with no known vulnerabilities, minimal dependencies, and a clear purpose. It's the standard choice for Web Mercator tile math in Python. Install it if you're working with tile-based maps or need to convert between geographic and tile coordinate systems.
Install
mercantile on PyPI
pip
pip install mercantileuv
uv add mercantilepoetry
poetry add mercantileInstalling mercantile
Before you install
Low friction: pure Python wheel with a single lightweight runtime dependency (click). Repository is active with a recent commit (2026-06-29) and has been maintained since its 2014 release.
License in practice
BSD license is permissive; you can use, modify, and distribute this package with minimal restrictions, provided you include the license notice.
Quickstart
pip install mercantile
import mercantile
# Get upper-left corner of a tile
ul = mercantile.ul(486, 332, 10)
print(ul) # LngLat(lng=-9.140625, lat=53.33087298301705)
# Get bounding box of a tile
bounds = mercantile.bounds(486, 332, 10)
print(bounds)
Verify before relying
- Whether the package actively supports Python 3.10+ or only legacy versions (classifiers list Python 2.7 and generic Python 3, but latest release was 2021-04-21)
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — click |
| Maintenance | actively maintained — 1,941 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,239,491/month — #3,193 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mercantile-1.2.1-py3-none-any.whl
Keywords: mapping, web mercator, tiles
Tags
More GIS packages
Shapely provides Python tools for creating,…
permissive · top 1,000 on PyPI
pyprojpyproj provides a Python interface to PROJ,…
permissive · top 1,000 on PyPI
geopandasGeoPandas extends pandas DataFrames to handle…
permissive · top 1,000 on PyPI
geopygeopy is a Python client for geocoding and…
permissive · top 5,000 on PyPI
pyogrioPyogrio provides fast, bulk-oriented read and…
permissive · top 5,000 on PyPI
h3h3 provides Python bindings to Uber's H3…
permissive · top 5,000 on PyPI
pyGeoTileConverts between geographic coordinate systems…
permissive · top 15,000 on PyPI
morecantileConstruct and work with map tile grids…
permissive · top 15,000 on PyPI
contextilyContextily retrieves tile-based map imagery…
permissive · top 15,000 on PyPI
supermorecadoExtends morecantile with command-line and…
permissive · top 15,000 on PyPI
xyzservicesProvides a Python API and JSON database of XYZ…
permissive · top 5,000 on PyPI
mapbox-vector-tileEncodes and decodes Mapbox Vector Tiles (MVT)…
permissive · top 15,000 on PyPI
polylineEncodes and decodes geographic coordinate…
unclear · top 5,000 on PyPI
tzfpyConverts geographic coordinates…
permissive · top 5,000 on PyPI
staticmapGenerates static map images with geographic…
unclear · top 15,000 on PyPI
pygeohashEncodes latitude/longitude coordinates to…
permissive · top 5,000 on PyPI