Skip to main content

China Coordinate Convertor

Actions Status GitHub stars GitHub forks GitHub license

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

  • ESRI Shapefile

  • GeoJSON

    图片名称

安装

推荐使用: 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程序中调用相应的坐标转换接口

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等文件进行转换,比如

~/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 ./tests/data/polygon/polygon_wgs.shp ~/temp/polygon_gcj.shp 

Metadata

Release files for coord-convert 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coord-convert 0.2.1
File Size Uploaded
coord-convert-0.2.1.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for coord-convert 0.2.1
File Interpreter ABI Platform
coord_convert-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / coord-convert-0.2.1.tar.gz

Download URL coord-convert-0.2.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d7479ed25947327a34841a714964a9c5a1af81b9bcdac4472069fa9aa7ab4d6d
BLAKE2b-256 checksum
How to use checksums
78427ed9adf261475d014012dbdd4831b4034719abf6b811080995fbe710bc40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

Release files / coord_convert-0.2.1-py3-none-any.whl

Download URL coord_convert-0.2.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40cbab8fd5c402bb38e3062370a5ebf1d4e0c167122f4a50d448e0f2a0a826b3
BLAKE2b-256 checksum
How to use checksums
1f976ab0b423924de14329a6a7f231e7712bb2b0c60c5c47efa08d8d65c841fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2

3 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page