跳到主要内容

地图瓦片

栅格瓦片

瓦片分级

坐标起点与方向
  • 左上角为坐标起点;
  • 右下为正方向;
瓦片数量;

row=col=2irow = col = 2^{i}

行列号与经纬度的转换公式

col=lon+180°360°2icol = \lfloor\frac{lon+180\degree}{360\degree}*2^i\rfloor row=(1asinh(tan(lat180π))π)2i1row = \lfloor (1-\frac{asinh(\tan(lat*\frac{180}{\pi}))}{\pi})*2^{i-1}\rfloor lon=col2i360180lon = \frac{col}{2^i}*360-180 lat=arctan(sinh(πy2z2π))180πlat=\arctan(\sinh(\pi-\frac{y}{2^z}*2\pi))*\frac{180}{\pi}

const lonLat2ColRow = (lon: number, lat: number, zoom: number) => {
const size = 2 ** zoom;
const col = Math.floor(((lon + 180) / 360) * size);
const row = Math.floor(
((1 - Math.asinh(Math.tan((lat * Math.PI) / 180)) / Math.PI) * size) / 2
);
return [col, row];
};

const ColRow2LonLat = (col: number, row: number, zoom: number) => {
const size = 2 ** zoom;
const lon = (col / size) * 360 - 180;
const lat =
Math.atan(Math.sinh(Math.PI * (1 - (2 * row) / size))) * (180 / Math.PI);
return [lon, lat];
};

mbtile

mbtile
  • mapbox 创建的存储栅格瓦片的数据格式;
  • 使用 sqlite 数据库;
相关库
  • mbtile 的导入和导出:mbutil

常见数据源