将 Excel 中的地址列批量转换为经纬度(百度地图 API)
Project description
地理编码工具 (geocoding-cli)
将 Excel 文件中指定工作表的某一列地址批量转换为经纬度坐标。 使用百度地图api
功能概述
本工具支持从命令行调用,读取 Excel 文件(.xlsx 格式),对指定工作表(sheet)中某一列的地址文本进行地理编码(Geocoding),并自动将经纬度结果写回原文件的新列中。
打包
pip install build
python -m build
...
Successfully built geocoding_cli-1.0.0.tar.gz and geocoding_cli-1.0.0-py3-none-any.whl
# 上传到 PyPI
pip install twine
twine upload dist/*
# 输入pypi token
安装
pip install geocoding-cli
注意:本工具依赖于网络请求调用地理编码 API(如高德、百度、Google 等),需提供有效的 API 密钥。
使用方法
命令行语法
geocoding-cli --key <API_KEY> --sheet <SHEET_INDEX> --column <COLUMN_INDEX> <INPUT_FILE.xlsx>
参数说明
| 参数 | 说明 |
|---|---|
--key 或 -k |
地理编码服务的 API 密钥(例如高德地图 API Key) |
--sheet 或 -s |
工作表索引(从 1 开始计数,即第一个 sheet 为 1) |
--column 或 -c |
地址所在列的列号(从 1 开始计数,即 A 列为 1) |
<INPUT_FILE.xlsx> |
输入的 Excel 文件路径(必须为 .xlsx 格式) |
示例
geocoding-cli --key your_amap_api_key --sheet 1 --column 5 addresses.xlsx
该命令将:
- 读取
addresses.xlsx文件; - 选择第一个工作表(Sheet1);
- 读取第 5 列(E 列)中的地址文本;
- 调用地理编码 API 获取经纬度;
- 在原文件中新增两列(默认为“经度”和“纬度”)写入结果。
⚠️ 注意:工具会输出结果到到原文件名_已加入经纬度.xlsx,建议操作前备份 Excel 文件。
输出格式
工具会在原 Excel 文件中追加两列:
- 经度(Longitude)
- 纬度(Latitude)
若某地址无法解析,对应单元格将留空或标记为 N/A。
支持的地理编码服务
当前默认使用 高德地图地理编码 API。如需支持其他服务(如百度地图、Google Maps),请在 --service 参数中指定(未来版本支持)。
依赖
- Python 3.10+
openpyxlrequests
许可证
MIT License
© 2026 zzhoo8
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geocoding_cli-1.0.3.tar.gz.
File metadata
- Download URL: geocoding_cli-1.0.3.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d09b5dc636b76895fbcdaabc1416f64a1ef139c43bb9286259a87b55138e908
|
|
| MD5 |
0eae15bb7cf67d1133763f06723d06d3
|
|
| BLAKE2b-256 |
18d657ccb1a9809e5652715a91e870150d670cdece88c1549aa42e296d11fee6
|
File details
Details for the file geocoding_cli-1.0.3-py3-none-any.whl.
File metadata
- Download URL: geocoding_cli-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b04fda9cfcf3bd361c31637f7e25f651d5e7c8ffae2a69c60d1dc410c9122588
|
|
| MD5 |
1ffcb638d81881e72123021bd4f19d66
|
|
| BLAKE2b-256 |
cc85f0ee8ef895477015db96d1519b52f30f080c1b68e9cf5ff6073690f3e6d5
|