• Stars
    star
    2,284
  • Rank 19,682 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🇨🇳最全最新中国【省、市、区县、乡镇街道】json,csv,sql数据

中华人民共和国行政区划代码

Github Issues Github Forks Github Stars Github Release no dependencies npm package

中华人民共和国行政区划(五级):省级、地级、县级、乡级和村级。来自中华人民共和国民政部,用于查询中国省,市和区数据的网站。

数据更新时间:2021/03/22 15:39:04 GMT+0800 (中国标准时间)

数据更新 Diff

安装

npm install province-city-china --save-dev
包名 说明 版本 大小
province-city-china 包含所有包内容 npm package -
@province-city-china/country 国家和地区代码列表 npm package
@province-city-china/data 总数据(省/地/县/乡) npm package
@province-city-china/province 省级(省/直辖市/特别行政区) npm package
@province-city-china/city 地级(城市) npm package
@province-city-china/area 县级(区县) npm package
@province-city-china/town 乡级(乡镇/街) npm package
@province-city-china/level 总数据(省/地/县/乡)层级数据 npm package
@province-city-china/utils 提供使用数据方法 npm package
@province-city-china/types 类型文件 npm package -
@province-city-china/district-code 国内长途电话区号 npm package -

使用

const { data, province, city, area, town } = require('province-city-china/data');
  • data - 总数据(省/地/县/乡)
  • province - 省级(省/直辖市/特别行政区)
  • city - 地级(城市)
  • area - 县级(区县)
  • town - 乡级(乡镇/街)

所有数据

const provinces = require('province-city-china/dist/data.json');
// provinces 输出 ===>
[
  {"code":"110000","name":"北京市","province":"11","city":0,"area":0,"town":0},
  {"code":"110101","name":"东城区","province":"11","city":"01","area":"01","town":0},
  {"code":"110102","name":"西城区","province":"11","city":"01","area":"02","town":0},
  {"code":"110105","name":"朝阳区","province":"11","city":"01","area":"05","town":0},
  ....
]

规则:

  • province - 省级(省/直辖市/特别行政区) - city=0, area=0, town=0
  • city - 地级(城市) - area=0, town=0
  • area - 县级(区县) - town=0 其它不为 0
  • town - 乡级(乡镇/街) - 所有值不为 0

province 第一位表示:华北区1,东北区2,华东区3,中南区4,西南区5,西北区6。 如 湖北省 -> 424 开头,表示为 中南区

获取城市数据

const city = require('province-city-china/dist/city.json');
// city 输出 ===>
[
  {"code":"01","name":"石家庄市","province":"13"},
  {"code":"02","name":"唐山市","province":"13"},
  {"code":"03","name":"秦皇岛市","province":"13"},
  {"code":"04","name":"邯郸市","province":"13"},
  {"code":"05","name":"邢台市","province":"13"},
  ....
]

说明:

  • code - 城市代码
  • name - 城市名称
  • province - 省/直辖市/特别行政区代码

更多数据

可以通过 UNPKG 下载使用 CDN 资源: https://unpkg.com/province-city-china/dist/

文件列表 JSON CSV SQL CDN
国家和地区代码列表(#13) country.json (min) country.csv - csv / json
总数据(省/地/县/乡) data.json (min) data.csv data.sql data.sql / csv / json
总数据(省/地/县/乡)层级数据 level.json (min) - - level.json
省级(省/直辖市/特别行政区) province.json (min) province.csv - province.json / csv
地级(城市) city.json (min) city.csv - city.json / csv
县级(区县) area.json (min) area.csv - area.json / csv
乡级(乡镇/街) town.json (min) town.csv - town.json / csv
县市区没有乡级数据 not-found-town.json (min) - - not-found-town.json
香港澳门<区>数据 hongkong.json
macau.json
hongkong.csv / macau.csv - hongkong.json (csv)
macau.json (csv)
国内长途电话区号 district-code.json district-code.csv - district-code.json / csv

更多 CDN 数据访问

> <>数据:34
  ✔ 数据保存: data/province.json
  ✔ 数据保存: data/province.csv
  ✔ 数据保存: data/province.min.json
✅ > <>数据:337
  ✔ 数据保存: data/city.json
  ✔ 数据保存: data/city.csv
  ✔ 数据保存: data/city.min.json
✅ > <>数据:2846
  ✔ 数据保存: data/area.json
  ✔ 数据保存: data/area.csv
  ✔ 数据保存: data/area.min.json
✅ > <省><市><区>总数据:3217
  ✔ 数据保存: data/data.json
  ✔ 数据保存: data/data.min.json
  ✔ 数据保存: data/data.csv
✅ > <省市区>层级数据:
  ✔ 数据保存: data/level.json
  ✔ 数据保存: data/level.min.json

国家和地区代码列表

country.json | country.min.json | country.csv

id=序号cnname=中文简称name=英文简称fullname=英文全称alpha2=两字母代码alpha3=三字母代码numeric=数字代码

[
  {
    "id": 1,
    "cnname": "阿富汗",
    "name": "Afghanistan",
    "fullname": "the Islamic Republic of Afghanistan",
    "alpha2": "AF",
    "alpha3": "AFG",
    "town": 4
  },
  {
    "id": 45,
    "cnname": "中国",
    "name": "China",
    "fullname": "the People's Republic of China",
    "alpha2": "CN",
    "alpha3": "CHN",
    "town": 156
  }
  // ...
]

压缩数据说明 country.min.json

id: 'i'
cnname: 'c'
name: 'n'
fullname: 'f'
alpha2: 'a2'
alpha3: 'a3'
numeric: 'r'

总数据(省/地/县/乡)

data.json | data.min.json | data.csv | data.sql

包含香港澳门<区>数据

[
  {
    "code": "110000",
    "name": "北京市",
    "province": "11",
    "city": 0,
    "area": 0,
    "town": 0
  },
  // ...
]

压缩数据说明 data.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'
area: 'a'
town: 't'

省/地/县/乡层级数据

level.json | level.min.json

包含香港澳门<区>数据

[
  {
    "code": "420000",
    "name": "湖北省",
    "province": "42",
    "children": [
      {
        "code": "420100",
        "name": "武汉市",
        "province": "42",
        "city": "01",
        "children": [
          {
            "code": "420102",
            "name": "江岸区",
            "province": "42",
            "city": "01",
            "area": "02"
          },
          // ...
        ]
      }
      // ...
    ]
  }
  // ...
]

压缩数据说明 level.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'
area: 'a'
children: 'd'

省级(省/直辖市/特别行政区)

province.json | province.min.json | province.csv

[
  {
    "code": "110000",
    "name": "北京市",
    "province": "11"
  },
  {
    "code": "120000",
    "name": "天津市",
    "province": "12"
  },
  // ...
]

压缩数据说明 level.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'
area: 'a'
children: 'd'

地级(城市)

city.json | city.min.json | city.csv

[
  {
    "code": "130100",
    "name": "石家庄市",
    "province": "13",
    "city": "01"
  },
  // ...
]

压缩数据说明 city.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'

县级(区县)

area.json | area.min.json | area.csv

[
  {
    "code": "110101",
    "name": "东城区",
    "province": "11",
    "city": "01",
    "area": "01"
  },
  // ...
]

压缩数据说明 city.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'
area: 'a'

乡级(乡镇/街)

town.json | town.min.json | town.csv

[
  {
    "code": "110101001000",
    "name": "东华门街道",
    "province": "11",
    "city": "01",
    "area": "01",
    "town": "001000"
  },
  // ...
]

压缩数据说明 city.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'
area: 'a'
town: 't'

县市区没有乡级数据

not-found-town.json | not-found-town.min.json

[
  {
    "code": "659010",
    "name": "胡杨河市",
    "province": "65",
    "city": "90",
    "area": "10",
    "town": 0
  },
  // ...
]

压缩数据说明 not-found-town.min.json

code: 'c'
name: 'n'
province: 'p'
city: 'y'
area: 'a'
town: 't'

香港澳门<区>数据

hongkong.json | hongkong.csv | macau.json | macau.csv

[
  {
    "code": "810002",
    "name": "湾仔区",
    "province": "81",
    "city": "00",
    "area": "02"
  },
  // ...
]

国内长途电话区号

district-code.json | district-code.csv

[
  { "name": "北京市", "code": "010" },
  // ...
]

脚本获取数据说明

① 获取<省><市>数据

中华人民共和国民政部-总省市区数据 上有完整的公开省市区数据。

获取省数据: http://www.mca.gov.cn/article/sj/xzqh/2020/20201201.html

② 校验四个<自治区直辖县级行政区划> & 以及其它数据

省市区数据来源于 中华人民共和国民政部-总省市区数据,数据太老,自治区直辖县级行政区划 中有数据不存在,校验此数据。

🚧 注意:部分省份下面有 省直辖县级行政区划 如(湖北省河南省等),需要将此部分数据重新爬下来进行校验数据,如 [新疆维吾尔自治区-自治区直辖县级行政区划] 缺 新星市

为提升速度,通过 标记 校验哪些特殊省份有这类数据。

http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2021/<>/<省><自治区直辖县级行政区划>.html

- 42 湖北省         -> # 自治区直辖县级行政区划
- 46 海南省         -> # 自治区直辖县级行政区划
- 65 新疆维吾尔自治区 -> # 自治区直辖县级行政区划
- 41 河南省         -> # 省直辖县级行政区划
# - 46 重庆市 -> 🚧 县
# - 23 黑龙江省 -> 🚧 大兴安岭地区

上面 4 个省区比较特殊的 自治区直辖县级行政区划,都有独立的 城市 代码,里面的数据拥有 代码,所以放到 数据中,例如:湖北省的 自治区直辖县级行政区划 编码为 90

[
  { code: '429004', name: '仙桃市', province: '42', city: '90' },
  { code: '429005', name: '潜江市', province: '42', city: '90' },
  { code: '429006', name: '天门市', province: '42', city: '90' },
  { code: '429021', name: '神农架林区', province: '42', city: '90' }
]

③ 处理四个<北京市|上海市|天津市|重庆市>直辖市数据

在 ① 步已获取直辖市数据:http://www.mca.gov.cn/article/sj/xzqh/2020/20201201.html

🚧 这里只是在生成层级数据的时候,需要特殊处理,因为它只有市区数据。

④ 分别存储<省><市><区>数据

分别存储 <省><市><区> 提供 csv, min.json, level.json, level.min.json 等数据。

⑤ 缓存<区>数据

此数据用于<街道>数据获取,避免中断从头爬数据。

⑥ 通过<街道>数据获取街道数据

□□□□□□  □□□  □□□
┈┈┬┈┈┈  ┈┬┈  ┈┬┈
  ╰┈┈┈┈┈┈┆┈┈┈┈┆┈┈┈┈→ ¹<省市区>代码
         ╰┈┈┈┈┆┈┈┈┈→ ²<乡镇街道>代码
              ╰┈┈┈┈→ ³<居民委员会><村民委员会>的代码

第²二段代码

  1. 001—099 表示街道的代码,应在本地区的范围内由小到大顺序编写;
  2. 100—199 表示镇的代码,应在本地区的范围内由小到大顺序编写;
  3. 200—399 表示乡的代码,应在本地区的范围内由小到大顺序编写;
  4. 400—599 表示政企合一单位的代码,应在本地区的范围内由小到大顺序编写。

第³三段代码

  1. 居民委员会的代码从001—199由小到大顺序编写;
  2. 村民委员会的代码从200-399由小到大顺序编写。

参考链接

Contributors

License

MIT

More Repositories

1

react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
TypeScript
2,003
star
2

react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
TypeScript
1,484
star
3

uiw

⚛️ @uiwjs A high quality UI Toolkit, A Component Library for React 16+.
TypeScript
702
star
4

react-login-page

Some `react` login pages, which can be used quickly after installation.
TypeScript
533
star
5

react-textarea-code-editor

A simple code editor with syntax highlighting.
TypeScript
459
star
6

react-amap

基于 React 封装的高德地图组件,帮助你轻松的接入地图到 React 项目中。
TypeScript
393
star
7

react-markdown-editor

A markdown editor with preview, implemented with React.js and TypeScript.
TypeScript
299
star
8

react-monacoeditor

Monaco Editor component for React.
TypeScript
284
star
9

react-markdown-preview

React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style. Support dark-mode/night mode.
TypeScript
248
star
10

react-color

🎨 Is a tiny color picker widget component for React apps.
TypeScript
238
star
11

react-baidu-map

基于 React 封装的百度地图组件,支持 React Hook,帮助你轻松的接入地图到 React 项目中。
TypeScript
216
star
12

react-native-alipay

基于 React Native 的宝支付包,已更新到最新的支付宝 SDK 版本,支持Android/iOS。
Java
199
star
13

react-heat-map

A lightweight calendar heatmap react component built on SVG, customizable version of GitHub's contribution graph.
TypeScript
178
star
14

react-json-view

A React component for displaying and editing javascript arrays and JSON objects.
TypeScript
154
star
15

icons

The premium icon font for @uiwjs Component Library. https://uiwjs.github.io/icons
HTML
138
star
16

npm-unpkg

A web application to view npm package files, Based on unpkg.
TypeScript
99
star
17

react-split

A piece of view can be divided into areas where the width or height can be adjusted by dragging.
TypeScript
60
star
18

react-code-preview

Code edit preview for React.
TypeScript
58
star
19

react-native-uiw

A UI component library based on React Native (Android & iOS).
TypeScript
44
star
20

json-viewer

Online JSON Viewer, JSON Beautifier to beautify and tree view of JSON data - It works as JSON Pretty Print to pretty print JSON data.
TypeScript
42
star
21

react-native-amap-geolocation

React Native 高德地图定位模块,支持 Android/iOS。
Java
41
star
22

react-signature

A signature board component for react.
TypeScript
34
star
23

react-watermark

A react component that adds a watermark to an area of a web page.
TypeScript
31
star
24

react-native-wechat

React Native 包使用微信分享、登录、收藏、支付等功能,支持Android/iOS。
Java
30
star
25

file-icons

File icons in the file tree.
HTML
29
star
26

uiw-admin

UIW-Admin Panel Framework, Powered by React and @uiwjs.
TypeScript
22
star
27

babel-plugin-transform-remove-imports

Remove the specified import declaration when you use the babel transform to build the package.
JavaScript
21
star
28

react-run-web

Online Code Editor for Rapid Web Development.
TypeScript
20
star
29

react-native-template

React Native template for react-native-uiw.
JavaScript
17
star
30

react-mac-keyboard

Macbook computer keyboard style for react component.
TypeScript
17
star
31

next-remove-imports

The default behavior is to remove all .less/.css/.scss/.sass/.styl imports from all packages in node_modules.
JavaScript
17
star
32

ui-color

Converting HEX & RGB colors to UIColor/NSColor/Color for both Objective C & Swift.
TypeScript
16
star
33

copy-to-clipboard

Copy text to the clipboard in modern browsers
JavaScript
16
star
34

react-use-online

useOnline is a tiny, zero-dependency hook for responding to online/offline changes.
TypeScript
16
star
35

reset-css

A tiny modern CSS reset.
CSS
14
star
36

keycode-info

A simple web page that responds to the pressed key and returns information about the JavaScript'on-key press' key.
TypeScript
14
star
37

react-iframe

This component allows you to wrap your entire React application or each component in an <iframe>.
TypeScript
12
star
38

react-codesandbox

A React component is provided that allows you to programmatically generate codesandbox projects from code samples on the fly.
TypeScript
11
star
39

react-github-corners

Add a Github corner to your project page, This GitHub corner for react component/web component.
TypeScript
11
star
40

react-only-when

A declarative component for conditional rendering.
TypeScript
9
star
41

bootstrap-icons

Official open source SVG icon library for Bootstrap.
8
star
42

uiwjs.github.io

The official documentation site for @uiwjs. https://uiwjs.github.io
8
star
43

react-clock

An analog clock for your React app.
TypeScript
7
star
44

vscode-uiw

Preview uiw document in vscode.
TypeScript
7
star
45

react-layout

Layout component for React. Handling the overall layout of a page.
TypeScript
7
star
46

react-csv-reader

React component that handles csv file input and its parsing.
TypeScript
7
star
47

react-use-colorscheme

useColorScheme() provides access to the devices color scheme.
TypeScript
7
star
48

react-native-transport-location

Objective-C
6
star
49

react-code-preview-layout

A react component showing the layout of `code` and `code preview example`.
TypeScript
6
star
50

date-formatter

Get a formatted date.
TypeScript
6
star
51

react-prismjs

React Component for prismjs.
TypeScript
6
star
52

react-tabs-draggable

Draggable tabs for React.
TypeScript
5
star
53

react-markdown-preview-example

Preview the markdown files and run the React examples in the documentation.
TypeScript
5
star
54

react-head

React components will manage your changes to the document head
TypeScript
4
star
55

react-shields

Shields.io for react component, Quality metadata badges for open source projects.
TypeScript
4
star
56

react-codepen

A React component is provided that allows you to programmatically generate codepen projects from code samples on the fly.
TypeScript
4
star
57

react-stackblitz

A React component is provided that allows you to programmatically generate stackblitz projects from code samples on the fly.
TypeScript
4
star
58

react-back-to-top

A minimal lightweight react component for adding a nice scroll up (back to top) button with onScroll progress.
TypeScript
4
star
59

react-monorepo-template

Simple React package development project example template.
TypeScript
3
star
60

auto-gitee-mirror

Use GitHub Actions to sync from GitHub to Gitee
3
star
61

react-keywords

Highlight a keyword in a piece of text and return a React element.
TypeScript
3
star
62

css-filter

A filter CSS generator that helps you quickly generate filter CSS declarations for your website. It comes with many options and it demonstrates instantly.
TypeScript
3
star
63

babel-plugin-transform-uiw-import

Modular import plugin for babel.
JavaScript
2
star
64

react-xml-reader

React component that handles xml file input and its parsing.
TypeScript
2
star
65

rematch-loading

Loading indicator plugin for @rematch.
TypeScript
1
star
66

logo

Source files of uiw's logo.
1
star
67

.github

Welcome to the uiwjs organization.
1
star