Web Mercator (EPSG:3857) Tile Bounds & XYZ Calculator

Convert between Slippy Map tile indices (Z, X, Y) and geographic WGS84 coordinates or projected Web Mercator (EPSG:3857) meters. Supports OpenStreetMap, Mapbox, Google Maps XYZ schemes, OSGeo TMS, and Bing Maps Quadkeys.

Tile Calculation Results Pixel: (234, 81) in tile

Tile Key (Z / X / Y) 15 / 29105 / 12903
TMS Tile Y (Flipped) 19864 (OSGeo TMS format: 15/29105/19864)
Bing Maps Quadkey 133002112310223
Geographic Bounds (WGS84) West: 139.757080°   East: 139.768066°
South: 35.675147°   North: 35.684072°
Projected Bounds (EPSG:3857) Min X: 15,557,686.99 m   Max X: 15,558,909.98 m
Min Y: 4,256,013.73 m   Max Y: 4,257,236.73 m
Tile Center (Lat, Lon) 35.679610° N, 139.762573° E
Ground Resolution at Center 3.87 meters / pixel (Tile dimension: 991.6 × 991.6 m)
Standard Tile URL https://tile.openstreetmap.org/15/29105/12903.png
Open in OpenStreetMap →

Web Mapping Developer Tools

Working with web maps, vector tiles, or spatial indexing? Explore these specialized GIS converters:

EPSG CRS Finder (3857 vs 4326) → GeoJSON Polygon Validator → Interactive Map Coordinate Picker →

How Web Mercator Slippy Map Tiles Work

1. The EPSG:3857 Projection & Why ±85.051129° Latitude?

Web Mercator (also known as Spherical Mercator, EPSG:3857, or legacy EPSG:900913) was popularized by Google Maps in 2005. It treats the Earth as a sphere of radius R = 6,378,137 meters, giving a planar circumference of 2πR = 40,075,016.686 meters.

To produce a perfectly square world map (1:1 aspect ratio) that can be recursively divided into 256 × 256 pixel tiles, the latitude range must be clamped where the Mercator projection y-dimension equals the equator half-circumference:

φlimit = 2 × arctan(eπ) − π/2 ≈ 85.0511287798°

Above ±85.0511° (the polar regions), the Mercator math approaches infinity (ln(tan(pi/4 + φ/2)) to ∞). Therefore, Web Mercator cannot display the North or South Poles.

2. Slippy Map (XYZ) vs OSGeo TMS Tile Schemes

There are two primary tile coordinate indexing conventions:

  • Standard XYZ (Slippy Map): Used by OpenStreetMap, Google Maps, Mapbox, and Leaflet. The top-left corner (North-West) is tile (0, 0). As you move South, Y increases downward.
  • OSGeo TMS (Tile Map Service): Used by QGIS TMS providers and TileCache. The bottom-left corner (South-West) is tile (0, 0). As you move North, Y increases upward: Y_tms = 2^Z - 1 - Y_xyz.

3. Ready-to-Use Developer Code Snippets

JavaScript (Browser / Node.js)

// Convert Longitude / Latitude to Tile XYZ
function latLonToTile(lat, lon, zoom) {
  const n = Math.pow(2, zoom);
  const x = Math.floor(((lon + 180) / 360) * n);
  const latRad = lat * Math.PI / 180;
  const y = Math.floor((1 - Math.log(Math.tan(latRad) + 1 / Math.cos(latRad)) / Math.PI) / 2 * n);
  return { z: zoom, x: x, y: y };
}

// Convert Tile XYZ to WGS84 Bounding Box
function tileToBounds(z, x, y) {
  const n = Math.pow(2, z);
  const west = (x / n) * 360 - 180;
  const east = ((x + 1) / n) * 360 - 180;
  const north = Math.atan(Math.sinh(Math.PI * (1 - 2 * y / n))) * 180 / Math.PI;
  const south = Math.atan(Math.sinh(Math.PI * (1 - 2 * (y + 1) / n))) * 180 / Math.PI;
  return { west, south, east, north };
}

PostGIS (SQL Spatial Query)

-- Generate exact tile polygon envelope in EPSG:3857
SELECT ST_TileEnvelope(15, 29105, 12903);

-- Intersect spatial points within a specific XYZ tile
SELECT id, name, geom
FROM points_table
WHERE ST_Intersects(geom, ST_Transform(ST_TileEnvelope(15, 29105, 12903), 4326));

Frequently Asked Questions (FAQ)

What are Slippy Map XYZ tile coordinates?

Slippy map tiles divide the globe into a quadtree pyramid. At zoom level Z, the world is partitioned into 2^Z × 2^Z square tiles of 256×256 pixels. Tile X ranges from 0 (West, -180°) to 2^Z - 1 (East, +180°), and Tile Y ranges from 0 (North, 85.0511°N) to 2^Z - 1 (South, 85.0511°S).

Why does Web Mercator limit latitude to ±85.051129 degrees?

The Web Mercator projection stretches latitude near the poles. To create a perfectly square world map (1:1 aspect ratio) suitable for binary quadtree tiling, the latitude boundary is mathematically clamped where the Mercator projection y-coordinate equals the equator half-circumference: 2 × arctan(e^π) - π/2 ≈ 85.051129°.

What is the difference between Slippy Map XYZ and OSGeo TMS?

In standard Slippy Map XYZ (OpenStreetMap, Google Maps, Mapbox), the Y origin Y=0 starts at the top-left (North-West) and counts downward to the South. In OSGeo TMS, the Y origin Y=0 starts at the bottom-left (South-West) and counts upward to the North: Y_tms = (2^Z - 1) - Y_xyz.

How is pixel ground resolution calculated at a given zoom level and latitude?

Ground resolution (meters per pixel) is given by: Resolution = (cos(Latitude) × 2 × π × 6378137) / (256 × 2^Zoom). At the Equator at Zoom 0, resolution is ~156,543 meters/pixel; at Zoom 18, resolution reaches ~0.597 meters/pixel.