Arsir Peta

ENID

Notes · · 1 min read

Where a tile lives: z, x and y

Every tile in a web map has an address of three numbers. Two conventions count one of them in opposite directions.

A map app does not ask for a place; it asks for tiles, each named by three numbers: the zoom level z, the column x and the row y. At zoom z the world is a grid of 2z columns by 2z rows.

Columns count from the 180th meridian eastwards. Rows, in the scheme most web maps use, count from the top edge of the map, at about 85.05 degrees north, downwards. Longitude maps to a column directly: x is the longitude plus 180, divided by 360, times 2z. Latitude goes through the Mercator formula first, which is why rows near the poles cover far less ground than rows near the equator.

The older Tile Map Service convention counts rows from the bottom instead. The two are easy to convert, since the row from the bottom is 2z minus 1 minus the row from the top, and just as easy to mix up. A pack built in one convention and read in the other shows every tile the right way up but in the wrong row, so coastlines break at every tile edge.

Before a pack leaves us we open one tile whose contents we know and check it lands where it should. The point where the equator crosses the prime meridian is a handy test: from zoom 1 onwards it sits exactly on the corner where four tiles meet.