超轻量离线中国行政区划逆地理编码(仅依赖 shapely)
Project description
Fast-GeoCN
超轻量离线中国行政区划逆地理编码 — 仅依赖 shapely,开箱即用。
特性
- ⚡ 极致轻量 — 仅依赖
shapely,无 pandas/geopandas,安装体积约 15 MB - 🚀 极速查询 — 运行时自动生成 pickle 缓存 + STRtree 空间索引 + PreparedGeometry 精确匹配,二次查询 亚毫秒级
- 🔌 兼容 — 兼容
regeo(lng, lat)函数签名 - 📦 开箱即用 — 内置中国省市县三级 GeoJSON 数据,pip install 即可使用
- 🛠 自动缓存 — 首次查询自动转为 pickle 缓存,后续秒级响应
快速开始
1. 安装
pip install fast-geocn
2. 查询
from fast_geocn import regeo
result = regeo(114.0579, 22.5431) # (经度, 纬度)
print(result)
# {'status': 1, 'Info': 'Successfully retrieved address.',
# 'address': {'province': '广东省', 'province_code': '440000',
# 'city': '深圳市', 'city_code': '440300',
# 'district': '南山区', 'district_code': '440305'}}
API 文档
regeo(lng, lat)
逆地理编码函数。
| 参数 | 类型 | 说明 |
|---|---|---|
lng |
float |
经度 (WGS-84) |
lat |
float |
纬度 (WGS-84) |
返回:包含 status、Info、address 的字典。
reverse_geocode(lat, lon, data_dir=None)
增强版逆地理编码函数,支持指定数据目录。
fast-geocn-prepare <geojson_dir> <output_dir>
CLI 工具,将 GeoJSON 目录转为 pickle 缓存。
性能
| 指标 | 耗时 |
|---|---|
| 首次查询(含 GeoJSON 解析 + 缓存生成) | ~3.6 s |
| 二次查询(直接读 pickle 缓存) | ~1.7 ms |
| 内存常驻后单次查询 | ~0.2 ms |
数据源推荐
| 数据源 | 说明 |
|---|---|
| DataV.GeoAtlas | 阿里云开源中国行政区划数据 |
| geojson.cn | 天地图省市县 GeoJSON,带审图号 |
| cn-atlas | 基于高德地图 API 的 TopoJSON/GeoJSON |
依赖
shapely >= 2.0
许可证
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fast_geocn-1.0.0.tar.gz
(5.6 MB
view details)
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 fast_geocn-1.0.0.tar.gz.
File metadata
- Download URL: fast_geocn-1.0.0.tar.gz
- Upload date:
- Size: 5.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7cbbf2d2e3a0655903043296da7efc9baf1de51ea2785461d3a75a11f8920e6
|
|
| MD5 |
6a8c9b33026638167991220a83bfbeac
|
|
| BLAKE2b-256 |
ee4e5e1e3ec42e34e32b995b9fdae47ef71b4b2b9e1c348037a823a22a740a47
|
File details
Details for the file fast_geocn-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fast_geocn-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd0655c48e9f02e7997177cc3825eead80e7e35d76bc0cb3a9b9450d67d6e336
|
|
| MD5 |
e8f4d3daba560af11982497481c06204
|
|
| BLAKE2b-256 |
dd2851e6699252a65857415e774678caffb234f83275c41d2da30f82713e3555
|