Skip to content

Commit

Permalink
update data at 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
adyliu committed Mar 7, 2019
1 parent 328239b commit 057c616
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dat/
dat/
~*
94 changes: 49 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# 2018年中国全国5级行政区划(省、市、县、镇、村)
# 2019年中国全国5级行政区划(省、市、县、镇、村)

* 数据来源 中华人民共和国国家统计局 http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2017/
* 最新数据量 719625`2017年10月31日, 比前一年度更新7891条`
* 数据来源 中华人民共和国国家统计局 http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/
* 最新数据量 713479 (`2018年10月31日
* CSV格式 area_code.csv.gz
* SQL格式 area_code.sql.gz
* JSON格式 单JSON格式太大就不生成了
* 建议级联操作,数据量确实太大了
* 级别
* 1级:省、直辖市、自治区 31个
* 2级:地级市 343个 (`比2017年减少1个`)
* 3级:市辖区、县(旗)、县级市、自治县(自治旗)、特区、林区 3287个 (`比2017年增加154个`
* 4级:镇、乡、民族乡、县辖区、街道 43523个(`比2017年增加1233个`
* 5级:村、居委会 673738个 (`比2017年增加?个`
* 1级:省、直辖市、自治区
* 2级:地级市
* 3级:市辖区、县(旗)、县级市、自治县(自治旗)、特区、林区
* 4级:镇、乡、民族乡、县辖区、街道
* 5级:村、居委会


![summary](summary.png "汇总")

## CSV格式

Expand All @@ -23,37 +26,38 @@
文本内容

```bash
$ gzcat area_code_2018.csv.gz |wc -l
720922

$ gzcat area_code_2018.csv.gz |head
110000000000,北京市,1,0
110100000000,市辖区,2,110000000000
110101000000,东城区,3,110100000000
110101001000,东华门街道办事处,4,110101000000
$ gzcat area_code_2019.csv.gz |wc -l
713479

$ gzcat area_code_2019.csv.gz |head
110101001001,多福巷社区居委会,5,110101001000
110101001002,银闸社区居委会,5,110101001000
110101001005,东厂社区居委会,5,110101001000
110101001006,智德社区居委会,5,110101001000
110101001007,南池子社区居委会,5,110101001000
110101001008,黄图岗社区居委会,5,110101001000
110101001009,灯市口社区居委会,5,110101001000
110101001010,正义路社区居委会,5,110101001000
110101001011,甘雨社区居委会,5,110101001000
110101001013,台基厂社区居委会,5,110101001000
```

## SQL 格式

> $ gzcat area_code_2018.sql.gz |head -n 38
> $ gzcat area_code_2019.sql.gz |head -n 38
```sql
$ gzcat area_code_2019.sql.gz |head -n 38
# ************************************************************
# Sequel Pro SQL dump
# Version 5086
# Version 5428
#
# https://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.7.9-log)
# Host: 127.0.0.1 (MySQL 8.0.13)
# Database: china_area
# Generation Time: 2018-11-13 07:49:09 +0000
# Generation Time: 2019-03-07 10:27:09 +0000
# ************************************************************


Expand All @@ -67,12 +71,12 @@ SET NAMES utf8mb4;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


# Dump of table area_code_2018
# Dump of table area_code_2019
# ------------------------------------------------------------

DROP TABLE IF EXISTS `area_code_2018`;
DROP TABLE IF EXISTS `area_code_2019`;

CREATE TABLE `area_code_2018` (
CREATE TABLE `area_code_2019` (
`code` bigint(12) unsigned NOT NULL COMMENT '区划代码',
`name` varchar(128) NOT NULL DEFAULT '' COMMENT '名称',
`level` tinyint(1) NOT NULL COMMENT '级别1-5,省市县镇村',
Expand All @@ -81,38 +85,38 @@ CREATE TABLE `area_code_2018` (
KEY `name` (`name`),
KEY `level` (`level`),
KEY `pcode` (`pcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
```

> 创建视图area_index
```sql
CREATE VIEW area_index AS
CREATE VIEW area_index_2019 AS
SELECT a.code,e.name AS province,d.name AS city ,c.name AS county,b.name AS town,a.name AS villagetr
FROM area_code_2018 a
JOIN area_code_2018 b ON a.level=5 AND b.level=4 AND a.pcode=b.code
JOIN area_code_2018 c ON b.pcode=c.code
JOIN area_code_2018 d ON c.pcode=d.code
JOIN area_code_2018 e ON d.pcode=e.code
FROM area_code_2019 a
JOIN area_code_2019 b ON a.level=5 AND b.level=4 AND a.pcode=b.code
JOIN area_code_2019 c ON b.pcode=c.code
JOIN area_code_2019 d ON c.pcode=d.code
JOIN area_code_2019 e ON d.pcode=e.code
ORDER BY a.code
```

查询几条记录

> SELECT * FROM area_index LIMIT 10
> SELECT * FROM area_index_2019 LIMIT 10
```text
code province city county town villagetr
110101001001 北京市 市辖区 东城区 东华门街道办事处 多福巷社区居委会
110101001002 北京市 市辖区 东城区 东华门街道办事处 银闸社区居委会
110101001005 北京市 市辖区 东城区 东华门街道办事处 东厂社区居委会
110101001006 北京市 市辖区 东城区 东华门街道办事处 智德社区居委会
110101001007 北京市 市辖区 东城区 东华门街道办事处 南池子社区居委会
110101001008 北京市 市辖区 东城区 东华门街道办事处 黄图岗社区居委会
110101001009 北京市 市辖区 东城区 东华门街道办事处 灯市口社区居委会
110101001010 北京市 市辖区 东城区 东华门街道办事处 正义路社区居委会
110101001011 北京市 市辖区 东城区 东华门街道办事处 甘雨社区居委会
110101001013 北京市 市辖区 东城区 东华门街道办事处 台基厂社区居委会
code province city county town villagetr
110101001001 北京市 市辖区 东城区 东华门街道办事处 多福巷社区居委会
110101001002 北京市 市辖区 东城区 东华门街道办事处 银闸社区居委会
110101001005 北京市 市辖区 东城区 东华门街道办事处 东厂社区居委会
110101001006 北京市 市辖区 东城区 东华门街道办事处 智德社区居委会
110101001007 北京市 市辖区 东城区 东华门街道办事处 南池子社区居委会
110101001008 北京市 市辖区 东城区 东华门街道办事处 黄图岗社区居委会
110101001009 北京市 市辖区 东城区 东华门街道办事处 灯市口社区居委会
110101001010 北京市 市辖区 东城区 东华门街道办事处 正义路社区居委会
110101001011 北京市 市辖区 东城区 东华门街道办事处 甘雨社区居委会
110101001013 北京市 市辖区 东城区 东华门街道办事处 台基厂社区居委会
```

## 三级区划的JSON格式
Expand Down Expand Up @@ -155,6 +159,6 @@ JSON格式,适合web端js加载。

## 文件列表

- area_code_2018.csv.gz
- area_code_2018.sql.gz
- area_code_2018.json
- area_code_2019.csv.gz
- area_code_2019.sql.gz
- area_code_2019.json
Binary file added area_code_2019.csv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions area_code_2019.csv.gz.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MD5 (area_code_2019.csv.gz) = 9d2d3dcfbb20b240e13dd4a2aabec687
1 change: 1 addition & 0 deletions area_code_2019.json

Large diffs are not rendered by default.

Binary file added area_code_2019.sql.gz
Binary file not shown.
1 change: 1 addition & 0 deletions area_code_2019.sql.gz.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MD5 (area_code_2019.sql.gz) = 0813873410253ff483e11beef32b05b8
Binary file added summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added summary.xlsx
Binary file not shown.

0 comments on commit 057c616

Please sign in to comment.