帮助处理平铺金字塔
tilematrix的Python项目详细描述
TileMatrix处理地理网络平铺和平铺金字塔。
模块设计用于在平铺索引(缩放、行、列)和 地图坐标(例如纬度、经度)。
tilematrix支持metatiling和tile缓冲区。而且它使 大量使用shapely,它还可以为每个磁贴生成Affine对象 有助于使用rasterio进行基于平铺的数据读写。
它与mercantile非常相似,但除了支撑球形墨卡托 平铺金字塔,它还支持大地测量(WGS84)平铺金字塔。
安装
使用pip安装最新的稳定版本:
pip install tilematrix
手动安装最新的开发版本
pip install -r requirements.txt python setup.py install
文档
cli
这个包附带了一个命令行工具tmx,它提供了 子命令:
- bounds:打印给定平铺的边界。
- bbox:打印给定平铺的边框几何图形。
- tile:打印瓷砖覆盖指定点。
- tiles:打印覆盖给定边界的平铺。
几何输出可以格式化为WKT或GeoJSON。例如 下面的命令将打印一个有效的GeoJSON,表示所有分幅 对于geodeticwmts网格的缩放级别1:
$ tmx -f GeoJSON tiles -- 1 -180 -90 18090{"type": "FeatureCollection", "features": [{"geometry": {"coordinates": [[[-90.0, 0.0], [-90.0, 90.0], [-180.0, 90.0], [-180.0, 0.0], [-90.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 0, "row": 0, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[0.0, 0.0], [0.0, 90.0], [-90.0, 90.0], [-90.0, 0.0], [0.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 1, "row": 0, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[90.0, 0.0], [90.0, 90.0], [0.0, 90.0], [0.0, 0.0], [90.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 2, "row": 0, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[180.0, 0.0], [180.0, 90.0], [90.0, 90.0], [90.0, 0.0], [180.0, 0.0]]], "type": "Polygon"}, "properties": {"col": 3, "row": 0, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[-90.0, -90.0], [-90.0, 0.0], [-180.0, 0.0], [-180.0, -90.0], [-90.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 0, "row": 1, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[0.0, -90.0], [0.0, 0.0], [-90.0, 0.0], [-90.0, -90.0], [0.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 1, "row": 1, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[90.0, -90.0], [90.0, 0.0], [0.0, 0.0], [0.0, -90.0], [90.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 2, "row": 1, "zoom": 1}, "type": "Feature"}, {"geometry": {"coordinates": [[[180.0, -90.0], [180.0, 0.0], [90.0, 0.0], [90.0, -90.0], [180.0, -90.0]]], "type": "Polygon"}, "properties": {"col": 3, "row": 1, "zoom": 1}, "type": "Feature"}]}
打印WKT平铺表示4 15 23:
$ tmx bbox 41523 POLYGON ((90 -90, 90 -78.75, 78.75 -78.75, 78.75 -90, 90 -90))
此外,tiles周围可以有名为pixelbuffer:
的缓冲区$ tmx --pixelbuffer 10 bbox 41523 POLYGON ((90.439453125 -90, 90.439453125 -78.310546875, 78.310546875 -78.310546875, 78.310546875 -90, 90.439453125 -90))
在mercator平铺上打印GeoJSON平铺表示4 15 23。 棱锥体:
$ tmx -output_format GeoJSON -grid mercator bbox 41515{"type": "Polygon", "coordinates": [[[20037508.342789203, -20037508.3427892], [20037508.342789203, -17532819.799940553], [17532819.799940553, -17532819.799940553], [17532819.799940553, -20037508.3427892], [20037508.342789203, -20037508.3427892]]]}