中国火星坐标变换器。

coord-convert的Python项目详细描述


# China Coordinate Convertor


[中国火星坐标](https://en.wikipedia.org/wiki/Restrictions_on_geographic_data_in_China)转换命令行工具,用于`WGS-84`(未偏移坐标), `GCJ-02`(国家测绘局、高德、谷歌中国地图), `BD-09`(百度坐标系)三者之间的互相转换,支持文件格式:
- ESRI Shapefile
- GeoJSON

<img src="./assets/all.jpg" width = "100%" height = "100%" alt="图片名称" align=center />

## 安装
推荐使用:
`pip install coord-convert`

或者也可以从源码安装:
```
git clone https://github.com/sshuair/coord-convert.git
pip install -r requirements.txt
python setup.py install
```

## 依赖
- python3
- fiona
- tqdm
- click

## 使用方法
>注意:火星坐标转换是针对经纬度的转换,因此在进行转换前需要将坐标转换成经纬度;比如web墨卡托(3857)等投影坐标系需要先转成经纬度坐标(4326)

### Python API调用
在python程序中调用相应的坐标转换接口

```python
from coord_convert.transform import wgs2gcj, wgs2bd, gcj2wgs, gcj2bd, bd2wgs, bd2gcj
lon, lat = 120, 40
gcj_lon, gcj_lat = wgs2gcj(lon, lat)
bd_lon, bd_lat = wgs2bd(lon, lat)
print(gcj_lon, gcj_lat) # the result should be: 120.00567568355486 40.0013047896019

```


### 命令行调用
火星坐标转换还支持命令行直接对shp、geojson等文件进行转换,比如

```bash
~/temp > coord_covert gcj2wgs tests/data/Polyline/polyline.geojson aa.geojson
100%|██████████████████████████████████████████████████████| 219/219 [00:00<00:00, 550.93it/s]
```

更详细的用法:
```
convert input china coordinate to another.

Arguments:
convert_type {string} -- [coordinate convert type, e.g. wgs2bd]

wgs2gcj : convert WGS-84 to GCJ-02
wgs2bd : convert WGS-84 to DB-09
gcj2wgs : convert GCJ-02 to WGS-84
gcj2bd : convert GCJ-02 to BD-09
bd2wgs : convert BD-09 to WGS-84
bd2gcj : convert BD-09 to GCJ-02

src_path {string} -- [source file path]
dst_path {string} -- [destination file path]


Example:
coord_covert wgs2gcj ./examples/data/polygon/polygon_wgs.shp ~/temp/polygon_gcj.shp

```




欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Android工具栏中的java内容编辑   eclipse Java WS仅在tcp/ip监视器打开时响应   java JUnit在Linux上安装失败   jvm如何获得内存堆中java对象占用的空间?   java@Transactional注释不适用于方法   最佳选择?编译前编辑字节码(asm)或编辑java文件   java Foursquare Api函数VenueShotos返回null   javascript Java EE servlet页面重定向+向控制器发送数据   java只读事务在我的AOP配置中不起作用   java代码在试图查找同时为星形和三角形的数字时不打印   java导航视图e引发异常#第11行充气机错误   java在hibernate中将值从DTO对象保存到实体   java随机访问文件。seek()在Linux上不工作   多线程处理期间更新方法上的java MongoDB错误   java无法获取该文件   单击AndId Back按钮后包含两个片段的java销毁活动   热键JIntellitype与java   静态实用程序类、单元测试和Java。时间   java如何执行CompletableFuture函数并得到结果,或者先执行哪一个?