跳转到主要内容

Web mercator XYZ瓦片工具

项目描述

Build Status Coverage Status Documentation Status

球面墨卡托坐标和瓦片工具

文档: http://mercantile.readthedocs.io/en/latest/

商业模块提供了 ul(xtile, ytile, zoom)bounds(xtile, ytile, zoom) 函数,分别返回 XYZ 瓦片的左上角和边界经纬度,一个 xy(lng, lat) 函数,返回球面墨卡托 x 和 y 坐标,一个 tile(lng, lat, zoom) 函数,返回包含指定点的瓦片,以及 quadkey 转换函数 quadkey(xtile, ytile, zoom)quadkey_to_tile(quadkey),用于在 quadkey 和瓦片坐标之间进行转换。

>>> import mercantile
>>> mercantile.ul(486, 332, 10)
LngLat(lng=-9.140625, lat=53.33087298301705)
>>> mercantile.bounds(486, 332, 10)
LngLatBbox(west=-9.140625, south=53.12040528310657, east=-8.7890625, north=53.33087298301705)
>>> mercantile.xy(*mercantile.ul(486, 332, 10))
(-1017529.7205322663, 7044436.526761846)
>> mercantile.xy_bounds(486, 332, 10)
Bbox(left=-1017529.7205322663, bottom=7005300.768279833, right=-978393.962050256, top=7044436.526761846)
>>> mercantile.tile(*mercantile.ul(486, 332, 10) + (10,))
Tile(x=486, y=332, z=10)
>>> mercantile.quadkey(486, 332, 10)
'0313102310'
>>> mercantile.quadkey_to_tile('0313102310')
Tile(x=486, y=332, z=10)

商业模块还包括遍历瓦片堆栈的函数。

>>> mercantile.parent(486, 332, 10)
Tile(x=243, y=166, z=9)
>>> mercantile.children(mercantile.parent(486, 332, 10))
[Tile(x=486, y=332, z=10), Tile(x=487, y=332, z=10), Tile(x=487, y=333, z=10), Tile(x=486, y=333, z=10)]

命名元组用于表示瓦片、坐标和边界框。

商业 CLI

商业的命令行界面,名为“商业”,包含获取 Web Mercator 瓦片形状为 GeoJSON 的命令,以及获取与 GeoJSON 边界框相交的瓦片。

$ mercantile --help
Usage: mercantile [OPTIONS] COMMAND [ARGS]...

  Command line interface for the Mercantile Python package.

Options:
  -v, --verbose  Increase verbosity.
  -q, --quiet    Decrease verbosity.
  --version      Show the version and exit.
  --help         Show this message and exit.

Commands:
  bounding-tile  Print the bounding tile of a lng/lat point, bounding box, or
                                 GeoJSON objects.
  children       Print the children of the tile.
  neighbors      Print the neighbors of the tile.
  parent         Print the parent tile.
  quadkey        Convert to/from quadkeys.
  shapes         Print the shapes of tiles as GeoJSON.
  tiles          Print tiles that overlap or contain a lng/lat point, bounding
                                 box, or GeoJSON objects.

另请参阅

supermercado 是另一个带有附加瓦片逻辑功能的 python 库(合并瓦片形状、查找边缘瓦片以及查找复杂几何形状的瓦片交集)。

node-sphericalmercator 为 Node 提供了许多相同的功能。

tilebelt 拥有 mercantile 的一些 GeoJSON 功能以及一些额外的功能(瓦片父级、quadkey)。

morecantile 与 mercantile 类似,但支持其他 TileMatrixSet 网格。

项目详情


下载文件

下载适合您平台的文件。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。

源分布

mercantile-1.2.1.tar.gz (26.4 kB 查看哈希)

上传时间

构建分布

mercantile-1.2.1-py3-none-any.whl (14.8 kB 查看哈希)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面