# tile-cutter
**Repository Path**: dungang/tile-cutter
## Basic Information
- **Project Name**: tile-cutter
- **Description**: 瓦片切图工具,方便下载,感谢1993hzw贡献的工具
- **Primary Language**: Python
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 5
- **Forks**: 1
- **Created**: 2023-12-06
- **Last Updated**: 2025-05-12
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Tile cutter ***瓦片切割工具***
本仓库是fork的https://github.com/1993hzw/tile-cutter
调整了一下瓦片切图工具,同时方便国内用户方便下载,感谢1993hzw贡献的工具
本人增加了 瓦片效果展示的页面,增加天地图如何切图的说明
可以加原作者的群功能在最下面,也可以加入到本人的沟通群
QQ Group ID: 680621200
## 指南
```PowerShell
python tilecutter.py -h
```
Cut the picture into small pieces (tiles) according to the pyramid model; support for cutting images, cutting maps, display in tiled maps for Web Mercator projection and latitude and longitude projection.
***瓦片切割工具,按照金字塔模型把图片切成小片;支持图片切割,地图切割,可用于Web墨卡托投影和经纬度投影的瓦片地图中显示。***
For example:
* Cut map ***地图切割***
```PowerShell
python tilecutter.py ./test_res/china.png -wm -t 512 -lv 4 -max 5 -ul "67.5000000,55.77657301866757"
```
The parameter `-wm` indicates that the Web Mercator projection is used for cutting tile. If you need to use the longitude and latitude projection, modify the parameter to `-ll`.
***参数`-wm`表示采用Web墨卡托平面进行切图,如果需要使用经纬度直投的切图方式则修改参数为`-ll`***
[View results 查看生成的瓦片](https://github.com/1993hzw/tile-cutter/tree/master/test_res/china)
* ***天地图切割***
> 默认瓦片大小是256
http://www.addondev.cn/maptile/tianditu 下载的地图绘制的手绘图地图,获取到相关的参数,下载底图的时候无比保存好相关参数,
目的是配合如下命令,切图。
> 获得如下参数:
选择区域信息[经/lng,纬/lat]
```txt
中心坐标: [116.4068,39.95172]
西南角坐标: [116.40427,39.95038]
东北角坐标: [116.40933,39.95306]
左上角坐标: [116.40427,39.95306]
右下角坐标: [116.40933,39.95038]
```
>得到如下命令
```PowerShell
python tilecutter.py ./test_res/test.png -wm -lv 16 -max 16 -min 15 -gcj -ul "116.40427,39.95306"
```
- lv: 设计图的层级,
- max: 切割的最大层级
- min: 切割的最下层级
- gcj: 国内是火星坐标
- ul: 右上角坐标
验证切割的瓦片是否完整
> 修改`test_res/idnex.html`
```js
//修改对应的生成目录和中心坐标,显示层级即可
//1,修改中心坐标
var center = new T.LngLat(120.45961, 29.38972);
//2,修改查看的瓦片目录test
var imageURL = "./test/{z}/{x}_{y}.png";
//打开的默认层级
var zoom = 16;
```
* Cut image ***图片切割***
```PowerShell
python tilecutter.py ./test_res/lol_crop.jpg -lv 6 -ul 4575,3840
```
[View results 查看生成的瓦片](https://github.com/1993hzw/tile-cutter/tree/master/test_res/lol_crop)
## Geo Util
```python
import geoutil # geoutil.py
```
Commonly used projection coordinate system conversion, including wgs84 (GPS coordinates), gcj02 (Mars coordinates), bd09 (Baidu coordinates) coordinate conversion.
***常用的投影坐标系转换,包括wgs84(GPS坐标),gcj02(火星坐标),bd09(百度坐标)之间的坐标转换。***
## Download map ***地图下载***
```PowerShell
python downloadmap.py -h
```
Download tiles for a specific area under a specified level and combine them into a map.
***下载指定级别下特定区域的瓦片,并合成一张区域地图。***
For example:
```PowerShell
python downloadmap.py 4 5,11 7,14
```
表示下载级别4下,瓦片索引从(5,11)到(7,14)的区域地图。默认地图源为谷歌地图,加上参数`-t`表示切换到经纬度投影的天地图。
After the download is completed, the starting point (ie, upper left corner) of the tile index will be output, which can be referenced when cutting the map.
***下载完成后会输出瓦片索引的起点(即左上角)经纬度坐标,可在切割地图时进行参考:***
```
The upper left lng/lat is [67.50000000000001, 55.7765730186677]
```
[View results 查看合成的地图](https://github.com/1993hzw/tile-cutter/blob/master/test_res/wm-4-5_11-7_14.png)
## [TiledMapView for Android](https://github.com/1993hzw/TiledMapView)
Tiled map loader for Android , supports a variety of projections, including Web Mercator projection, latitude and longitude projection and custom projection; supports locating, adding layers and overlays.
***Android瓦片地图加载,支持多种投影,包括Web墨卡托投影,经纬度直投及自定义投影等;支持定位,添加图层和覆盖物。***
Tiles generated using the tile cutter cut above can be displayed directly in [TiledMapView](https://github.com/1993hzw/TiledMapView). For more information, please go to [TiledMapView](https://github.com/1993hzw/TiledMapView).
***上面使用瓦片切割器生成的瓦片可以直接在[TiledMapView](https://github.com/1993hzw/TiledMapView)中显示。想要了解更多请前往[TiledMapView](https://github.com/1993hzw/TiledMapView)。***
## The developer 开发者
154330138@qq.com hzw19933@gmail.com
Q&A
QQ Group ID: 885437848