https://github.com/issue9/cnregion
2009-2023 年中国全国(省、市、县、乡/镇、村/街道)五级行政区域划分数据
https://github.com/issue9/cnregion
cn-location cn-region go golang region
Last synced: 4 months ago
JSON representation
2009-2023 年中国全国(省、市、县、乡/镇、村/街道)五级行政区域划分数据
- Host: GitHub
- URL: https://github.com/issue9/cnregion
- Owner: issue9
- License: mit
- Created: 2021-02-05T03:36:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-16T05:10:54.000Z (over 1 year ago)
- Last Synced: 2024-10-17T17:38:17.404Z (over 1 year ago)
- Topics: cn-location, cn-region, go, golang, region
- Language: Go
- Homepage: https://pkg.go.dev/github.com/issue9/cnregion/v2
- Size: 33.9 MB
- Stars: 188
- Watchers: 7
- Forks: 24
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cnregion
[](https://github.com/issue9/cnregion/actions?query=workflow%3ATest)
[](https://golang.org)
[](https://pkg.go.dev/github.com/issue9/cnregion/v2)
[](https://codecov.io/gh/issue9/cnregion)

历年统计用区域和城乡划分代码,数据来源于 。
符合国家标准 GB/T 2260 与 GB/T 10114。
关于版本号,主版本号代码不兼容性更改,次版本号代码最后一次生成的数据年份,BUG 修正和兼容性的功能增加则增加修订版本号。
```go
v, err := cnregion.LoadFile("./data/regions.db", "-", 2020)
p := v.Provinces() // 返回所有省列表
cities := p[0].Items() // 返回该省下的所有市
counties := cities[0].Items() // 返回该市下的所有县
towns := counties[0].Items() // 返回所有镇
villages := towns[0].Items() // 所有村和街道信息
d := v.Districts() // 按以前的行政大区进行划分
provinces := d[0].Items() // 该大区下的所有省份
list := v.Search(&SearchOptions{Text: "温州"}) // 按索地名中带温州的区域列表
```
对采集的数据进行了一定的加工,以减少文件的体积,文件保存在 `./data/regions.db` 中。
## 安装
```shell
go get github.com/issue9/cnregion/v2
```
## 版权
本项目采用 [MIT](https://opensource.org/licenses/MIT) 开源授权许可证,完整的授权说明可在 [LICENSE](LICENSE) 文件中找到。