├── 出行分布
├── 点坐标信息.csv
├── 示范路网小区
│ ├── 路网.dbf
│ ├── 路网.sbn
│ ├── 路网.sbx
│ ├── 路网.shp
│ ├── 路网.shx
│ ├── cube小区.sbn
│ ├── cube小区.sbx
│ ├── cube小区.shp
│ ├── cube小区.shx
│ ├── 交通小区.sbn
│ ├── 交通小区.sbx
│ ├── 交通小区.shp
│ ├── 交通小区.shx
│ ├── 对着的版本
│ │ ├── 路网.dbf
│ │ ├── 路网.sbn
│ │ ├── 路网.sbx
│ │ ├── 路网.shp
│ │ ├── 路网.shx
│ │ ├── cube小区.sbn
│ │ ├── cube小区.sbx
│ │ ├── cube小区.shp
│ │ ├── cube小区.shx
│ │ ├── 路网.prj
│ │ ├── cube小区.prj
│ │ ├── cube小区.dbf
│ │ ├── cube小区.shp.xml
│ │ └── 路网.shp.xml
│ ├── 交通小区.prj
│ ├── 路网.prj
│ ├── cube小区.prj
│ ├── cube小区.dbf
│ ├── 交通小区.dbf
│ ├── cube小区.shp.xml
│ ├── 交通小区.shp.xml
│ └── 路网.shp.xml
├── 出行成本.csv
├── 分布矩阵.csv
├── read_zonal_data.py
├── 阻抗.csv
├── 路网信息.csv
├── 方式划分矩阵.csv
├── read_networkl_data.py
├── 路段流量表.csv
├── 路径.csv
├── distribution_3.py
├── distribution_2.py
└── distribution.py
├── 示范路网小区
├── 路网.dbf
├── 路网.sbn
├── 路网.sbx
├── 路网.shp
├── 路网.shx
├── 交通小区.sbn
├── 交通小区.sbx
├── 交通小区.shp
├── 交通小区.shx
├── 交通小区.prj
├── 路网.prj
├── 路网.dbf.csv
├── 路网.dbf信息.csv
├── 输出.dbf
├── 交通小区.shp.xml
├── 输出.dbf.xml
└── 路网.shp.xml
├── 出行生成
├── 预测PA矩阵.csv
├── 总表-变换数据-第三组_2020年预测用数据.dbf
├── generation_3.py
├── generation.py
└── generation_2.py
├── README.md
├── 出行方式划分
├── model split.py
└── modle.py
└── 可视化出图
├── 路段流量表.csv
├── supposed_line.py
├── 数据.csv
└── visual.py
/出行分布/点坐标信息.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/点坐标信息.csv
--------------------------------------------------------------------------------
/示范路网小区/路网.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/路网.dbf
--------------------------------------------------------------------------------
/示范路网小区/路网.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/路网.sbn
--------------------------------------------------------------------------------
/示范路网小区/路网.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/路网.sbx
--------------------------------------------------------------------------------
/示范路网小区/路网.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/路网.shp
--------------------------------------------------------------------------------
/示范路网小区/路网.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/路网.shx
--------------------------------------------------------------------------------
/示范路网小区/交通小区.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/交通小区.sbn
--------------------------------------------------------------------------------
/示范路网小区/交通小区.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/交通小区.sbx
--------------------------------------------------------------------------------
/示范路网小区/交通小区.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/交通小区.shp
--------------------------------------------------------------------------------
/示范路网小区/交通小区.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/示范路网小区/交通小区.shx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/路网.dbf
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/路网.sbn
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/路网.sbx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/路网.shp
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/路网.shx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/cube小区.sbn
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/cube小区.sbx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/cube小区.shp
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/cube小区.shx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/交通小区.sbn
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/交通小区.sbx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/交通小区.shp
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/交通小区.shx
--------------------------------------------------------------------------------
/出行生成/预测PA矩阵.csv:
--------------------------------------------------------------------------------
1 | index,P1,A1
2 | 1,7883,7812
3 | 2,7826,7576
4 | 3,7896,7867
5 | 4,7839,7629
6 | 5,8097,8702
7 | 6,7890,7842
8 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/路网.dbf
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/路网.sbn
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/路网.sbx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/路网.shp
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/路网.shx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.sbn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/cube小区.sbn
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.sbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/cube小区.sbx
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/cube小区.shp
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行分布/示范路网小区/对着的版本/cube小区.shx
--------------------------------------------------------------------------------
/出行生成/总表-变换数据-第三组_2020年预测用数据.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ruantiancheng/four-steps-model-for-transportation-planning/HEAD/出行生成/总表-变换数据-第三组_2020年预测用数据.dbf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # four-steps-model-for-transportation-planning
2 | 交通规划交通量预测的四步模型代码化
3 | 本科毕业设计的成果,本来还有个前端网页涉及别人所做的内容就不放了,毕业一年了突发奇想放上来,但是技术有限做的比较简陋,现在也没空完善了,全当给想做宏观交通规划的朋友一个看看的玩具
4 |
--------------------------------------------------------------------------------
/出行分布/出行成本.csv:
--------------------------------------------------------------------------------
1 | ,1,2,3,4,5,6
2 | 1,0.0,90.0,84.5,89.5,102.0,158.0
3 | 2,87.0,0.0,87.5,91.5,90.0,88.0
4 | 3,84.0,90.0,0.0,89.5,164.0,97.0
5 | 4,87.0,92.0,87.5,0.0,92.0,87.0
6 | 5,100.0,91.0,162.5,92.5,0.0,78.0
7 | 6,160.0,93.0,99.5,91.5,82.0,0.0
8 |
--------------------------------------------------------------------------------
/出行分布/分布矩阵.csv:
--------------------------------------------------------------------------------
1 | ,index,1,2,3,4,5,6
2 | 1,1,0,1518,1429,1520,1681,1860
3 | 2,2,1435,0,1462,1601,1501,1444
4 | 3,3,1490,1613,0,1618,1932,1775
5 | 4,4,1445,1607,1473,0,1554,1412
6 | 5,5,1740,1645,1913,1693,0,1384
7 | 6,6,1789,1482,1638,1442,1304,0
8 |
--------------------------------------------------------------------------------
/示范路网小区/交通小区.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/示范路网小区/路网.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.prj:
--------------------------------------------------------------------------------
1 | PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/出行分布/read_zonal_data.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import pandas as pd
3 | import dbfread as dbf
4 | import csv
5 | import shapefile
6 |
7 | file_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
8 | sf = shapefile.Reader(file_name)
9 | shapes = sf.shapes()
10 | print(len(shapes.points))
11 | point_list = {}
12 | for i in range(len(shapes)):
13 | for j in range(len(shapes[i].points)):
14 | pass
--------------------------------------------------------------------------------
/出行分布/阻抗.csv:
--------------------------------------------------------------------------------
1 | 1,2,3,4,5,6,7,8,9
2 | 0,1921,3862,1981,3902,5843,3909,5836,7778
3 | 1921,0,1941,3902,1981,3922,5830,3915,5857
4 | 3862,1941,0,5843,3922,1981,7771,5856,3916
5 | 1981,3902,5843,0,1954,3902,1928,3888,5837
6 | 3902,1981,3922,1954,0,1948,3882,1934,3883
7 | 5843,3922,1981,3902,1948,0,5830,3882,1935
8 | 3909,5830,7771,1928,3882,5830,0,1961,3935
9 | 5836,3915,5856,3888,1934,3882,1961,0,1974
10 | 7778,5857,3916,5837,3883,1935,3935,1974,0
11 |
--------------------------------------------------------------------------------
/出行分布/路网信息.csv:
--------------------------------------------------------------------------------
1 | RoadID,Name,Linktype,A,B,One_way,Length,Speed,Lanes,Capacity,Roadscr,SHAPE_Leng
2 | 1,1,1,1,2,0,932.658100002,60,6,2400,0,932.658100002
3 | 2,2,1,2,3,0,952.501899999,60,6,2400,0,952.501899999
4 | 3,3,1,1,4,0,992.1895,60,6,2400,0,992.1895
5 | 4,4,1,4,5,0,965.7311,60,6,2400,0,965.7311
6 | 5,5,1,2,5,0,992.740563914,60,6,2400,0,992.740563914
7 | 6,6,1,5,6,0,959.1165,60,6,2400,0,959.1165
8 | 7,7,1,3,6,0,992.982935153,60,6,2400,0,992.982935153
9 | 8,8,1,4,7,0,939.2727,60,6,2400,0,939.2727
10 | 9,9,1,7,8,0,972.345700001,60,6,2400,0,972.345700001
11 | 10,10,1,5,8,0,945.910427701,60,6,2400,0,945.910427701
12 | 11,11,1,8,9,0,985.5748,60,6,2400,0,985.5748
13 | 12,12,1,6,9,0,946.465319499,60,6,2400,0,946.465319499
14 |
--------------------------------------------------------------------------------
/示范路网小区/路网.dbf.csv:
--------------------------------------------------------------------------------
1 | RoadID,Name,Linktype,A,B,One_way,Length,Speed,Lanes,Capacity,Roadscr,SHAPE_Leng
2 | 1,1,1,1,2,0,932.658100002,60,6,2400,0,932.658100002
3 | 2,2,1,2,3,0,952.501899999,60,6,2400,0,952.501899999
4 | 3,3,1,1,4,0,992.1895,60,6,2400,0,992.1895
5 | 4,4,1,4,5,0,965.7311,60,6,2400,0,965.7311
6 | 5,5,1,2,5,0,992.740563914,60,6,2400,0,992.740563914
7 | 6,6,1,5,6,0,959.1165,60,6,2400,0,959.1165
8 | 7,7,1,3,6,0,992.982935153,60,6,2400,0,992.982935153
9 | 8,8,1,4,7,0,939.2727,60,6,2400,0,939.2727
10 | 9,9,1,7,8,0,972.345700001,60,6,2400,0,972.345700001
11 | 10,10,1,5,8,0,945.910427701,60,6,2400,0,945.910427701
12 | 11,11,1,8,9,0,985.5748,60,6,2400,0,985.5748
13 | 12,12,1,6,9,0,946.465319499,60,6,2400,0,946.465319499
14 |
--------------------------------------------------------------------------------
/示范路网小区/路网.dbf信息.csv:
--------------------------------------------------------------------------------
1 | RoadID,Name,Linktype,A,B,One_way,Length,Speed,Lanes,Capacity,Roadscr,SHAPE_Leng
2 | 1,1,1,1,2,0,932.658100002,60,6,2400,0,932.658100002
3 | 2,2,1,2,3,0,952.501899999,60,6,2400,0,952.501899999
4 | 3,3,1,1,4,0,992.1895,60,6,2400,0,992.1895
5 | 4,4,1,4,5,0,965.7311,60,6,2400,0,965.7311
6 | 5,5,1,2,5,0,992.740563914,60,6,2400,0,992.740563914
7 | 6,6,1,5,6,0,959.1165,60,6,2400,0,959.1165
8 | 7,7,1,3,6,0,992.982935153,60,6,2400,0,992.982935153
9 | 8,8,1,4,7,0,939.2727,60,6,2400,0,939.2727
10 | 9,9,1,7,8,0,972.345700001,60,6,2400,0,972.345700001
11 | 10,10,1,5,8,0,945.910427701,60,6,2400,0,945.910427701
12 | 11,11,1,8,9,0,985.5748,60,6,2400,0,985.5748
13 | 12,12,1,6,9,0,946.465319499,60,6,2400,0,946.465319499
14 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.dbf:
--------------------------------------------------------------------------------
1 | w !N M ID N Pop N Stu N Area F Car_owned N Job N SHAPE_Leng F SHAPE_Area F
120002000 9.41774305612e+00560001800 3.88330550738e+003 9.41774305612e+005 220002000 9.10102313759e+00560001800 3.81645524037e+003 9.10102359496e+005 320002000 1.04898877039e+00660001800 4.11059488796e+003 1.04898861760e+006 420002000 9.48350847178e+00560001800 3.89735554252e+003 9.48350847178e+005 520002000 9.16526814484e+00560001800 3.83064122302e+003 9.16526792792e+005 620002000 9.45287374798e+00560001800 3.90598624067e+003 9.45287308765e+005
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.dbf:
--------------------------------------------------------------------------------
1 | w !N M ID N Pop N Stu N Area F Car_owned N Job N SHAPE_Leng F SHAPE_Area F
120002000 9.41774305612e+00560001800 3.88330550738e+003 9.41774305612e+005 220002000 9.10102313759e+00560001800 3.81645524037e+003 9.10102359496e+005 320002000 1.04898877039e+00660001800 4.11059488796e+003 1.04898861760e+006 420002000 9.48350847178e+00560001800 3.89735554252e+003 9.48350847178e+005 520002000 9.16526814484e+00560001800 3.83064122302e+003 9.16526792792e+005 620002000 9.45287374798e+00560001800 3.90598624067e+003 9.45287308765e+005
--------------------------------------------------------------------------------
/示范路网小区/输出.dbf:
--------------------------------------------------------------------------------
1 | w !l M Area F Pop N Stu N Car_owned N Job F Zones_ID N SHAPE_Leng F SHAPE_Area F
9.41774305612e+005 20000 20000 6000 1.80000000000e+004 1 3.88330550738e+003 9.41774305612e+005 9.13322713126e+005 20000 20000 6000 1.80000000000e+004 2 3.82326948311e+003 9.13322713126e+005 9.48350847178e+005 20000 20000 6000 1.80000000000e+004 3 3.89735554252e+003 9.48350847178e+005 9.19791580288e+005 20000 20000 6000 1.80000000000e+004 4 3.83708150421e+003 9.19791580288e+005 1.04898878567e+006 20000 20000 6000 1.80000000000e+004 5 4.11059491938e+003 1.04898878567e+006 9.45287391904e+005 20000 20000 6000 1.80000000000e+004 6 3.90598628036e+003 9.45287391904e+005
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.dbf:
--------------------------------------------------------------------------------
1 | w A M Area F Pop N Stu N Car_owned N Job F Zones_ID N SHAPE_Leng F Shape_Le_1 F Shape_Area F
9.41774305612e+005 20000 20000 6000 1.80000000000e+004 1 3.88330550738e+003 3.88330562336e+003 9.41780183451e+005 9.13322713126e+005 20000 20000 6000 1.80000000000e+004 2 3.82326948311e+003 3.82369557125e+003 9.13851553870e+005 9.48350847178e+005 20000 20000 6000 1.80000000000e+004 3 3.89735554252e+003 3.89735565587e+003 9.48357435815e+005 9.19791580288e+005 20000 20000 6000 1.80000000000e+004 4 3.83708150421e+003 3.83628407328e+003 9.19364337911e+005 1.04898878567e+006 20000 20000 6000 1.80000000000e+004 5 4.11059491938e+003 4.10498895591e+003 1.04548514762e+006 9.45287391904e+005 20000 20000 6000 1.80000000000e+004 6 3.90598628036e+003 3.89875431121e+003 9.42253230798e+005
--------------------------------------------------------------------------------
/出行分布/方式划分矩阵.csv:
--------------------------------------------------------------------------------
1 | ,car1,car2,car3,car4,car5,car6,bus1,bus2,bus3,bus4,bus5,bus6
2 | 1,0.0,875.9231794782546,874.4055019585113,877.6262057507334,914.2222082062284,941.803260149007,-0.0,667.0768205217454,650.5944980414887,668.3737942492666,728.7777917937716,652.196739850993
3 | 2,870.3918373593574,0.0,854.8430051146094,851.5131362393921,886.4004733247242,913.442810658949,647.6081626406426,-0.0,666.1569948853906,648.4868637606079,706.5995266752758,632.557189341051
4 | 3,896.7493745419553,882.1676091440102,0.0,883.870635416489,920.3429898801593,948.3025298238119,636.2506254580447,671.8323908559898,-0.0,673.129364583511,733.6570101198407,656.6974701761881
5 | 4,876.6990245865992,855.4868642085092,861.025301667049,0.0,892.5212549986551,919.942080333754,652.3009754134008,651.5131357914908,670.974698332951,-0.0,711.4787450013449,637.057919666246
6 | 5,872.2094089195465,851.1521853942356,856.4091565674652,852.6376167823582,0.0,882.6297254330179,871.7905910804535,867.8478146057644,890.5908434325349,869.3623832176418,-0.0,698.3702745669821
7 | 6,295.7361401184712,288.6932888850461,290.43373076496516,289.2524108131643,291.702682449248,0.0,1275.2638598815288,1260.306711114954,1283.5662692350347,1262.7475891868357,1182.297317550752,0.0
8 |
--------------------------------------------------------------------------------
/出行方式划分/model split.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | '''
3 | 输入:分布交通量矩阵
4 | 路网gis.shp文件
5 | 输出:各方式划分交通量
6 | '''
7 |
8 | import numpy as np
9 | import pandas as pd
10 | import dbfread as dbf
11 | import csv
12 | import shapefile
13 | import matplotlib.pyplot as plt
14 | import geopandas as gdf
15 | import math
16 | import time
17 |
18 |
19 | def logit(dataframe):
20 | #logit 模型算法
21 | split_choice = []
22 | for item in dataframe.items:
23 | sum_list = []
24 | for item in dataframe.items:
25 | real_resist = math.e ** item
26 | sum_list.append(real_resist)
27 | split_choice.append( math.e ** item / sum(sum_list))
28 | return split_choice
29 |
30 | def main():
31 | netshape_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
32 | zonal_shape_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
33 | nsf = shapefile.Reader(netshape_path, encoding='gbk')
34 | zsf = shapefile.Reader(zonal_shape_path, encoding='gbk')
35 |
36 | split_choice = logit(nsf)
37 |
38 |
39 |
40 | if __name__ == '__main__':
41 | time1 = time.time()
42 | main()
43 | time2 = time.time()
44 | #输出执行时间
45 | print(f'耗时:{time2 - time1}秒')
46 |
--------------------------------------------------------------------------------
/出行分布/read_networkl_data.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import pandas as pd
3 | import dbfread as dbf
4 | import csv
5 | import shapefile
6 |
7 | file_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
8 | def read_info(file_name):
9 | sf = shapefile.Reader(file_name)
10 | shapes = sf.shapes()
11 | fields = sf.fields
12 | records = sf.records()
13 | fields_name = []
14 | for field in fields:
15 | fields_name.append(field[0])
16 | del fields_name[0]
17 | table = []
18 | for record in records:
19 | table.append(record[:])
20 | net_info = pd.DataFrame(table, columns=fields_name)
21 | point_dict = {}
22 | for i in range(len(shapes)):
23 | # for j in range(len(shapes[i].points)):
24 | point_dict[net_info['A'][i]] = shapes[i].points[0]
25 | point_dict[net_info['B'][i]] = shapes[i].points[1]
26 | point_info = pd.DataFrame(list(point_dict.items()), columns=['点','坐标'])
27 | print(point_info)
28 | net_info.to_csv("{}信息.csv".format(file_name), encoding="gbk", index=False)
29 | return net_info
30 | net_info = read_info(file_name)
31 |
32 |
33 | # def Shp2dataframe(file_name):
34 | # '''将arcpy表单变为pandas表单输出'''
35 | # sf = shapefile.Reader(file_name)
36 | # fields = sf.shapeRecords()
37 | # print(len(fields))
38 | # table = []
39 | # fieldname = [field.record[0] for field in fields]
40 | # # 游标集合,用for 循环一次后没办法循环第二次!一个游标实例只能循环一次
41 | # data = shapefile.Reader(file_name)
42 | # for row in data:
43 | # # Shape字段中的要数是一个几何类
44 | # r = []
45 | # for field in fields:
46 | # r.append(row.fieldname)
47 | # table.append(r)
48 | # return pd.DataFrame(table, columns=fieldname)
49 | # df = Shp2dataframe(file_name)
50 | # print(df)
51 |
--------------------------------------------------------------------------------
/出行分布/路段流量表.csv:
--------------------------------------------------------------------------------
1 | ,A,A_point,B,B_point,c,lw_time,opposite_v,v
2 | 0,1,"(585429.2928999998, 3794373.4152000006)",2,"(585429.2928999998, 3793440.757099999)",2400,85.98750473,0,9902
3 | 0,2,"(585429.2928999998, 3793440.757099999)",3,"(585429.2928999998, 3792488.2552000005)",2400,61.87580729,0,6204
4 | 0,1,"(585429.2928999998, 3794373.4152000006)",4,"(586421.4824000001, 3794373.4152000006)",2400,59.53137,0,0
5 | 0,4,"(586421.4824000001, 3794373.4152000006)",5,"(586421.4828000003, 3793407.6977999993)",2400,59.01921396,0,4271
6 | 0,2,"(585429.2928999998, 3793440.757099999)",5,"(586421.4828000003, 3793407.6977999993)",2400,113.1608305,0,11268
7 | 0,5,"(586421.4828000003, 3793407.6977999993)",6,"(586421.4824000001, 3792448.5676000006)",2400,62.78356236,0,6354
8 | 0,3,"(585429.2928999998, 3792488.2552000005)",6,"(586421.4824000001, 3792448.5676000006)",2400,60.8401937,0,4413
9 | 0,4,"(586421.4824000001, 3794373.4152000006)",7,"(587360.7550999997, 3794373.4152000006)",2400,71.69920469,0,8357
10 | 0,7,"(587360.7550999997, 3794373.4152000006)",8,"(587367.1527000004, 3793400.432)",2400,59.24104779,0,4089
11 | 0,5,"(586421.4828000003, 3793407.6977999993)",8,"(587367.1527000004, 3793400.432)",2400,56.35704242,0,0
12 | 0,8,"(587367.1527000004, 3793400.432)",9,"(587367.3825000003, 3792415.4562999997)",2400,59.14569979,0,0
13 | 0,6,"(586421.4824000001, 3792448.5676000006)",9,"(587367.3825000003, 3792415.4562999997)",2400,57.48722004,0,3854
14 | 0,7,"(587360.7550999997, 3794373.4152000006)",10,"(588363.1847000001, 3794349.872300001)",2400,60.1623631,0,0
15 | 0,10,"(588363.1847000001, 3794349.872300001)",11,"(588384.3514, 3793249.203400001)",2400,66.05234251,0,0
16 | 0,8,"(587367.1527000004, 3793400.432)",11,"(588384.3514, 3793249.203400001)",2400,62.09012355,0,0
17 | 0,9,"(587367.3825000003, 3792415.4562999997)",12,"(588384.3514, 3792381.3683)",2400,61.05324934,0,0
18 | 0,11,"(588384.3514, 3793249.203400001)",12,"(588384.3514, 3792381.3683)",2400,52.60777112,0,3688
19 |
--------------------------------------------------------------------------------
/出行分布/路径.csv:
--------------------------------------------------------------------------------
1 | 1,2,3,4,5,6,7,8,9,10,11,12
2 | "[1, 1]","[1, 2]","[1, 2, 3]","[1, 4]","[1, 2, 5]","[1, 2, 3, 6]","[1, 4, 7]","[1, 4, 7, 8]","[1, 2, 3, 6, 9]","[1, 4, 7, 10]","[1, 4, 7, 8, 11]","[1, 2, 6, 9, 12]"
3 | "[2, 1]","[2, 2]","[2, 3]","[2, 1, 4]","[2, 5]","[2, 3, 6]","[2, 1, 4, 7]","[2, 5, 8]","[2, 3, 6, 9]","[2, 1, 4, 7, 10]","[2, 5, 8, 11]","[2, 3, 6, 9, 12]"
4 | "[3, 2, 1]","[3, 2]","[3, 3]","[3, 2, 1, 4]","[3, 2, 5]","[3, 6]","[3, 2, 1, 4, 7]","[3, 2, 5, 8]","[3, 6, 9]","[3, 2, 1, 4, 7, 10]","[3, 2, 5, 8, 11]","[3, 6, 9, 12]"
5 | "[4, 1]","[4, 1, 2]","[4, 1, 2, 3]","[4, 4]","[4, 5]","[4, 5, 6]","[4, 7]","[4, 7, 8]","[4, 5, 6, 9]","[4, 7, 10]","[4, 7, 8, 11]","[4, 7, 8, 11, 12]"
6 | "[5, 2, 1]","[5, 2]","[5, 2, 3]","[5, 4]","[5, 5]","[5, 6]","[5, 4, 7]","[5, 8]","[5, 6, 9]","[5, 4, 7, 10]","[5, 8, 11]","[5, 6, 9, 12]"
7 | "[6, 3, 2, 1]","[6, 3, 2]","[6, 3]","[6, 5, 4]","[6, 5]","[6, 6]","[6, 5, 4, 7]","[6, 9, 8]","[6, 9]","[6, 5, 4, 7, 10]","[6, 9, 8, 11]","[6, 9, 12]"
8 | "[7, 4, 1]","[7, 4, 1, 2]","[7, 4, 1, 2, 3]","[7, 4]","[7, 4, 5]","[7, 4, 5, 6]","[7, 7]","[7, 8]","[7, 8, 9]","[7, 10]","[7, 8, 11]","[7, 8, 11, 12]"
9 | "[8, 7, 4, 1]","[8, 5, 2]","[8, 5, 2, 3]","[8, 7, 4]","[8, 5]","[8, 9, 6]","[8, 7]","[8, 8]","[8, 9]","[8, 7, 10]","[8, 11]","[8, 11, 12]"
10 | "[9, 6, 3, 2, 1]","[9, 6, 3, 2]","[9, 6, 3]","[9, 6, 5, 4]","[9, 6, 5]","[9, 6]","[9, 8, 7]","[9, 8]","[9, 9]","[9, 8, 7, 10]","[9, 12, 11]","[9, 12]"
11 | "[10, 7, 4, 1]","[10, 7, 4, 1, 2]","[10, 7, 4, 1, 2, 3]","[10, 7, 4]","[10, 7, 4, 5]","[10, 7, 4, 5, 6]","[10, 7]","[10, 7, 8]","[10, 7, 8, 9]","[10, 10]","[10, 11]","[10, 11, 12]"
12 | "[11, 8, 7, 4, 1]","[11, 8, 5, 2]","[11, 8, 5, 2, 3]","[11, 8, 7, 4]","[11, 8, 5]","[11, 8, 9, 6]","[11, 8, 7]","[11, 8]","[11, 12, 9]","[11, 10]","[11, 11]","[11, 12]"
13 | "[12, 9, 6, 3, 2, 1]","[12, 9, 6, 3, 2]","[12, 9, 6, 3]","[12, 11, 8, 7, 4]","[12, 9, 6, 5]","[12, 9, 6]","[12, 11, 8, 7]","[12, 11, 8]","[12, 9]","[12, 11, 10]","[12, 11]","[12, 12]"
14 |
--------------------------------------------------------------------------------
/可视化出图/路段流量表.csv:
--------------------------------------------------------------------------------
1 | ,A,A_point,B,B_point,c,lw_time,opposite_v,v
2 | 0,1,"(585429.2928999998, 3794373.4152000006)",2,"(585429.2928999998, 3793440.757099999)",2400,85.98750473,0,0
3 | 0,2,"(585429.2928999998, 3793440.757099999)",3,"(585429.2928999998, 3792488.2552000005)",2400,61.87580729,0,2161
4 | 0,1,"(585429.2928999998, 3794373.4152000006)",4,"(586421.4824000001, 3794373.4152000006)",2400,59.53137,0,2696
5 | 0,4,"(586421.4824000001, 3794373.4152000006)",5,"(586421.4828000003, 3793407.6977999993)",2400,59.01921396,0,6890
6 | 0,2,"(585429.2928999998, 3793440.757099999)",5,"(586421.4828000003, 3793407.6977999993)",2400,113.1608305,0,9614
7 | 0,5,"(586421.4828000003, 3793407.6977999993)",6,"(586421.4824000001, 3792448.5676000006)",2400,62.78356236,0,4230
8 | 0,3,"(585429.2928999998, 3792488.2552000005)",6,"(586421.4824000001, 3792448.5676000006)",2400,60.8401937,0,1188
9 | 0,4,"(586421.4824000001, 3794373.4152000006)",7,"(587360.7550999997, 3794373.4152000006)",2400,71.69920469,0,0
10 | 0,7,"(587360.7550999997, 3794373.4152000006)",8,"(587367.1527000004, 3793400.432)",2400,59.24104779,0,8754
11 | 0,5,"(586421.4828000003, 3793407.6977999993)",8,"(587367.1527000004, 3793400.432)",2400,56.35704242,0,11534
12 | 0,8,"(587367.1527000004, 3793400.432)",9,"(587367.3825000003, 3792415.4562999997)",2400,59.14569979,0,1833
13 | 0,6,"(586421.4824000001, 3792448.5676000006)",9,"(587367.3825000003, 3792415.4562999997)",2400,57.48722004,0,1339
14 | 0,7,"(587360.7550999997, 3794373.4152000006)",10,"(588363.1847000001, 3794349.872300001)",2400,60.1623631,0,1869
15 | 0,10,"(588363.1847000001, 3794349.872300001)",11,"(588384.3514, 3793249.203400001)",2400,66.05234251,0,0
16 | 0,8,"(587367.1527000004, 3793400.432)",11,"(588384.3514, 3793249.203400001)",2400,62.09012355,0,2534
17 | 0,9,"(587367.3825000003, 3792415.4562999997)",12,"(588384.3514, 3792381.3683)",2400,61.05324934,0,2458
18 | 0,11,"(588384.3514, 3793249.203400001)",12,"(588384.3514, 3792381.3683)",2400,52.60777112,0,1300
19 |
--------------------------------------------------------------------------------
/出行方式划分/modle.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import math
3 | import pandas as pd
4 | import matplotlib.pyplot as plt
5 |
6 | arr = np.array(range(1, 17))
7 | dataframe = pd.DataFrame(arr.reshape(8, 2), columns=['gongjiao', 'xiaoqiche'])
8 | arr = np.ones((6, 6)) * 85
9 | traffic_cost = pd.DataFrame(arr, columns=range(1, 7), index=range(1, 7))
10 | print(traffic_cost)
11 |
12 |
13 | def curel_fit(traffic_cost, exp_cartime=[75, 80, 85, 90, 100], exp_bustime=[85, 95, 110, 130, 160]):
14 | exp_cartime = np.array(exp_cartime)
15 | exp_bustime = np.array(exp_bustime)
16 | fit_fuc = np.polyfit(exp_cartime, exp_bustime, 3)
17 | bustime_cal = np.poly1d(fit_fuc)
18 | exp_bustimevals = bustime_cal(exp_cartime)
19 | bus_traffic_cost = traffic_cost.apply(lambda x: bustime_cal(x))
20 | index_list = []
21 | for i in range(1, 1 + len(traffic_cost)):
22 | index_list.append('bus%i' % i)
23 | bus_traffic_cost.columns = index_list
24 | new_traffic_cost = pd.concat([traffic_cost, bus_traffic_cost], axis=1)
25 | return new_traffic_cost
26 |
27 |
28 | newtraffic_cost = curel_fit(traffic_cost)
29 |
30 |
31 | # 曲线可视化部分
32 | # plot1 = plt.plot(exp_cartime, exp_bustimevals, 'r', label='original values')
33 | # plt.title('polyfitting')
34 | # plt.show()
35 |
36 | def logit(dataframe):
37 | # logit 模型算法
38 |
39 | split_choice = []
40 | lens = len(dataframe)
41 | columns = len(dataframe.columns)
42 |
43 |
44 | for i in range(lens):
45 | for j in range(int(columns/2)):
46 | sum_list = []
47 | for k in range(1,1+int(columns/lens)):
48 | real_resist = math.e ** -(dataframe.iloc[i,k*lens-1]/50)
49 | sum_list.append(real_resist)
50 |
51 | split_choice.append(math.e ** -(dataframe.iloc[i,j]/50 )/ sum(sum_list))
52 | split_choice = np.array(split_choice)
53 | split_choice = pd.DataFrame(split_choice.reshape(lens, int(columns / 2)))
54 | bus_split_choice = split_choice.apply(lambda x:1-x)
55 | split_choice = pd.concat([split_choice,bus_split_choice],axis=1)
56 | index_list = []
57 | for k in range(1,lens+1):
58 | index_list.insert(k-1,'car%i'%k)
59 | index_list.append('bus%i'%k)
60 | split_choice.columns=index_list
61 | split_choice.index = range(1,lens+1)
62 |
63 |
64 | return split_choice
65 |
66 |
67 | print(logit(newtraffic_cost))
68 |
--------------------------------------------------------------------------------
/可视化出图/supposed_line.py:
--------------------------------------------------------------------------------
1 | import geopandas as gdf
2 | import matplotlib.pyplot as plt
3 | import pandas as pd
4 |
5 | plt.rcParams['font.sans-serif'] = ['SimHei']
6 | plt.rcParams['axes.unicode_minus'] = False
7 |
8 | #底图绘制
9 | nybb_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
10 | g = gdf.GeoDataFrame.from_file(nybb_path, encoding='gb18030')
11 |
12 | nybb2_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
13 | r = gdf.GeoDataFrame.from_file(nybb2_path, encoding='gb18030')
14 |
15 | ax1 = g.plot(color='w')
16 | r.plot(ax=ax1,color='black')
17 |
18 |
19 | file_path1 = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\可视化出图\\数据.csv'
20 | df1 = pd.read_csv(file_path1, low_memory=False) # 防止弹出警告
21 | file_path2 = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\分布矩阵.csv'
22 | df2 = pd.read_csv(file_path2, low_memory=False) # 防止弹出警告
23 | df3 = pd.DataFrame(df1['centroid_column'])
24 | file_path = 'C:\\Users\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\点坐标信息.csv'
25 | df = pd.read_csv(file_path, low_memory=False, encoding='ISO-8859-1') # 防止弹出警告
26 |
27 | x_coor = []
28 | y_coor = []
29 | for g in range(6):
30 | coor_list = df3.iloc[g, 0].split(' ')
31 | a_coor = eval(coor_list[1][1:])
32 | b_coor = eval(coor_list[2][:-1])
33 | x_coor.append(a_coor)
34 | y_coor.append(b_coor)
35 |
36 |
37 | zonal_point_info = {0: [1, 2, 4, 5], 1: [4, 5, 7, 8], 2: [2, 3, 5, 6], 3: [5, 6, 8, 9], 4: [7, 8, 10, 11],
38 | 5: [8, 9, 11, 12]}
39 | for g in range(6):
40 | px_list = []
41 | py_list = []
42 | for i in zonal_point_info[g]:
43 | # print(type(df.iloc[i-1][1]))
44 | zonal_coor_list = df.iloc[i - 1][1].split(',')
45 | # print(zonal_coor_list)
46 | px_list.append(eval(zonal_coor_list[0][1:]))
47 | py_list.append(eval(zonal_coor_list[1][1:-1]))
48 | plt.plot(px_list, py_list, "ro", linewidth=1, color='gray')
49 |
50 | for k in range(len(px_list)):
51 | draw_x_coor = [px_list[k], x_coor[g]]
52 | draw_y_coor = [py_list[k], y_coor[g]]
53 | plt.plot(draw_x_coor, draw_y_coor, linewidth=1, color='gray')
54 |
55 | plt.plot(x_coor, y_coor,"ro",linewidth=1, color='yellow')
56 |
57 | for i in range(6):
58 | for g in range(2,8):
59 | # print(df2.loc[i][g])
60 | if i+2>g:
61 | offset_instance = 13
62 | color = 'r'
63 | else:
64 | offset_instance = -13
65 | color = 'b'
66 | sup_xcoor_list =[x_coor[i]+offset_instance,x_coor[g-2]+offset_instance]
67 | sup_ycoor_list =[y_coor[i]+offset_instance,y_coor[g-2]+offset_instance]
68 | # print(sup_xcoor_list,sup_ycoor_list)
69 | plt.plot(sup_xcoor_list, sup_ycoor_list, linewidth=3,color = color)
70 |
71 | plt.title('期望线图',fontsize = 20)
72 | plt.axis('off')
73 | plt.show()
74 |
--------------------------------------------------------------------------------
/可视化出图/数据.csv:
--------------------------------------------------------------------------------
1 | ,Area,Pop,Stu,Car_owned,Job,Zones_ID,SHAPE_Leng,Shape_Le_1,Shape_Area,geometry,centroid_column
2 | 0,941774.305612,20000,20000,6000,18000.0,1,3883.30550738,3883.30562336,941780.183451,"POLYGON ((586421.4962999998 3794372.544199999, 586421.4828000003 3793407.697799999, 586421.2001 3793407.708900001, 585429.2928999998 3793440.757099999, 585429.2928999998 3794373.415200001, 586421.4824000001 3794373.415200001, 586421.4962999998 3794372.544199999))",POINT (585928.270871976 3793898.774829058)
3 | 1,913322.713126,20000,20000,6000,18000.0,2,3823.26948311,3823.69557125,913851.55387,"POLYGON ((587367.3742000004 3793448.6248, 587367.1527000004 3793400.432, 587360.8126999997 3793400.4374, 586421.8174000001 3793407.6952, 586421.4828000003 3793407.697799999, 586421.4962999998 3794372.544199999, 586421.4824000001 3794373.415200001, 587360.7550999997 3794373.415200001, 587360.7620000001 3794372.4485, 587367.1478000004 3793481.0725, 587367.1563999997 3793479.462200001, 587367.3742000004 3793448.6248))",POINT (586893.4503119552 3793888.136880249)
4 | 2,948350.847178,20000,20000,6000,18000.0,3,3897.35554252,3897.35565587,948357.435815,"POLYGON ((586421.2001 3793407.708900001, 586421.4828000003 3793407.697799999, 586421.4948000005 3793407.0329, 586421.4824000001 3792448.567600001, 585429.2928999998 3792488.2552, 585429.2928999998 3793440.757099999, 586421.2001 3793407.708900001))",POINT (585925.9642814196 3792946.299710817)
5 | 3,919791.580288,20000,20000,6000,18000.0,4,3837.08150421,3836.28407328,919364.337911,"POLYGON ((587367.1527000004 3793400.432, 587367.1703000003 3793399.935000001, 587367.1810999997 3793349.6209, 587367.3825000003 3792415.4563, 586428.4219000004 3792448.2587, 586421.4824000001 3792448.567600001, 586421.4948000005 3793407.0329, 586421.4828000003 3793407.697799999, 586421.8174000001 3793407.6952, 587360.8126999997 3793400.4374, 587367.1527000004 3793400.432))",POINT (586896.4689130469 3792917.947506484)
6 | 4,1048988.78567,20000,20000,6000,18000.0,5,4110.59491938,4104.98895591,1045485.14762,"POLYGON ((588363.2015000004 3794349.000399999, 588384.3448999999 3793249.486300001, 588384.3514 3793249.203400001, 587374.4840000002 3793399.435900001, 587373.8892999999 3793399.3946, 587371.1957999999 3793399.77, 587367.5700000003 3793400.2754, 587367.1527000004 3793400.432, 587367.3742000004 3793448.6248, 587367.1563999997 3793479.462200001, 587367.1478000004 3793481.0725, 587360.7620000001 3794372.4485, 587360.7550999997 3794373.415200001, 588363.1847000001 3794349.872300001, 588363.2015000004 3794349.000399999))",POINT (587879.284437077 3793841.26971333)
7 | 5,945287.391904,20000,20000,6000,18000.0,6,3905.98628036,3898.75431121,942253.230798,"POLYGON ((587371.1957999999 3793399.77, 587373.8892999999 3793399.3946, 587374.4840000002 3793399.435900001, 588384.3514 3793249.203400001, 588384.3514 3792381.3683, 587374.3084000004 3792415.2368, 587373.8881999999 3792415.2509, 587367.3825000003 3792415.4563, 587367.1810999997 3793349.6209, 587367.1703000003 3793399.935000001, 587367.1527000004 3793400.432, 587367.5700000003 3793400.2754, 587371.1957999999 3793399.77))",POINT (587865.0921595446 3792862.633002419)
8 |
--------------------------------------------------------------------------------
/可视化出图/visual.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 | import matplotlib.pyplot as plt
3 | from sympy import *
4 | import geopandas as gdf
5 | #底图绘制
6 | nybb_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
7 | g = gdf.GeoDataFrame.from_file(nybb_path, encoding='gb18030')
8 |
9 | nybb2_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
10 | r = gdf.GeoDataFrame.from_file(nybb2_path, encoding='gb18030')
11 |
12 | ax1 = g.plot(color='w')
13 | r.plot(ax=ax1,color='red')
14 |
15 |
16 | file_path1 = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\可视化出图\\数据.csv'
17 | df1 = pd.read_csv(file_path1, low_memory=False) # 防止弹出警告
18 | file_path2 = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\分布矩阵.csv'
19 | df2 = pd.read_csv(file_path2, low_memory=False) # 防止弹出警告
20 | df3 = pd.DataFrame(df1['centroid_column'])
21 | file_path = 'C:\\Users\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\点坐标信息.csv'
22 | df = pd.read_csv(file_path, low_memory=False, encoding='ISO-8859-1') # 防止弹出警告
23 |
24 | x_coor = []
25 | y_coor = []
26 | for g in range(6):
27 | coor_list = df3.iloc[g, 0].split(' ')
28 | a_coor = eval(coor_list[1][1:])
29 | b_coor = eval(coor_list[2][:-1])
30 | x_coor.append(a_coor)
31 | y_coor.append(b_coor)
32 |
33 |
34 | zonal_point_info = {0: [1, 2, 4, 5], 1: [4, 5, 7, 8], 2: [2, 3, 5, 6], 3: [5, 6, 8, 9], 4: [7, 8, 10, 11],
35 | 5: [8, 9, 11, 12]}
36 | for g in range(6):
37 | px_list = []
38 | py_list = []
39 | for i in zonal_point_info[g]:
40 | # print(type(df.iloc[i-1][1]))
41 | zonal_coor_list = df.iloc[i - 1][1].split(',')
42 | # print(zonal_coor_list)
43 | px_list.append(eval(zonal_coor_list[0][1:]))
44 | py_list.append(eval(zonal_coor_list[1][1:-1]))
45 | plt.plot(px_list, py_list, "ro", linewidth=1, color='gray')
46 |
47 | for k in range(len(px_list)):
48 | draw_x_coor = [px_list[k], x_coor[g]]
49 | draw_y_coor = [py_list[k], y_coor[g]]
50 | plt.plot(draw_x_coor, draw_y_coor, linewidth=1, color='gray')
51 |
52 | plt.plot(x_coor, y_coor,"ro",linewidth=1, color='yellow')
53 |
54 |
55 | file_path = 'C:\\Users\Administrator\\Desktop\\python_work\\毕业设计\\可视化出图\\路段流量表.csv'
56 | df = pd.read_csv(file_path, low_memory = False)#防止弹出警告
57 |
58 | plt.rcParams['font.sans-serif'] = ['SimHei']
59 | plt.rcParams['axes.unicode_minus'] = False
60 | color_choice = 'y'
61 | for i in range(len(df)):
62 | x_coor = []
63 | y_coor = []
64 | a_coor = eval(df.iloc[i, 2])
65 | b_coor = eval(df.iloc[i, 4])
66 | print(type(a_coor[0]))
67 | volumn = df.iloc[i, 8]
68 | lw_choice = 12 * volumn / 7200
69 | if volumn < 1400:
70 | color_choice = 'g'
71 | lw_choice = 1
72 | elif 1400 <= volumn < 3600:
73 | color_choice = '#ADFF2F'
74 | elif 3600 <= volumn < 5760:
75 | color_choice = '#FFA500'
76 | else:
77 | color_choice = 'r'
78 | print(a_coor[0])
79 | x_coor.append(a_coor[0])
80 | x_coor.append(b_coor[0])
81 | y_coor.append(a_coor[1])
82 | y_coor.append(b_coor[1])
83 |
84 | plt.plot(x_coor, y_coor, linewidth=lw_choice, color=color_choice)
85 | # 出vc比图
86 |
87 | plt.text((a_coor[0] + b_coor[0]) / 2, (a_coor[1] + b_coor[1]) / 2, s='{:.2%}'.format(volumn / 7200), ha='center',
88 | va='bottom', fontsize=20)
89 | plt.title('路段流量图',fontsize = 20)
90 | #出流量图
91 | # plt.text((a_coor[0]+b_coor[0])/2,(a_coor[1]+b_coor[1])/2,s=volumn, ha='center', va= 'bottom',fontsize=20)
92 |
93 |
94 | plt.axis('off')
95 | plt.show()
--------------------------------------------------------------------------------
/出行生成/generation_3.py:
--------------------------------------------------------------------------------
1 | '''
2 | 出行生成模块
3 | 输入:file_name:人口及预测数据;PA计算回归公式
4 | 输出:预测PA矩阵
5 | 追加功能:对p2a ,a2p功能进行封装
6 | '''
7 |
8 | import numpy as np
9 | import pandas as pd
10 | import dbfread as dbf
11 | import csv
12 | import xlwt
13 | import datetime
14 | import os
15 | import shapefile
16 | import time
17 |
18 |
19 |
20 | class Generation:
21 | def __init__(self, file_name):
22 | self.file_name = file_name
23 |
24 | def read_file(self):
25 | '''
26 | 读取输入文件
27 | '''
28 | table = dbf.DBF(self.file_name, load=True)
29 | return table
30 |
31 | def calculation_model(self, table):
32 | # 回归所得pa矩阵输入
33 | df = pd.DataFrame(columns=(
34 | 'index', 'P1', 'A1'))
35 |
36 | for i in range(len(table)):
37 | P1 = int(0.002*table.records[i]['Area']+0.3*table.records[i]['Stu'])
38 | A1 = int(0.005*table.records[i]['Area']-0.0003*table.records[i]['Pop'])
39 | df = df.append(pd.DataFrame(
40 | {'index': [i + 1], 'P1': [P1], 'A1': [A1]}))
41 | return df
42 |
43 | def p2a(self, df):
44 | # p2a 过程
45 | behave_number = int((df.shape[1]-1)/2)
46 | for i in range(behave_number):
47 | rate = pd.DataFrame(columns=['A{}rate'.format(i+behave_number)])
48 | productsum = []
49 | for i in df.columns:
50 | productsum.append(df[i].sum())
51 | for j in range(1+behave_number,1+behave_number*2):
52 | origin_rate = []
53 | for i in range(len(df)):
54 | origin_rate.append(df.iloc[i, j] / productsum[j])
55 | rate['A{}rate'.format(j-1 )] = origin_rate
56 | actually_attractive = []
57 | for i in range(behave_number,behave_number*2):
58 | if productsum[i] != productsum[i + behave_number]:
59 | for j in range(df.shape[0]):
60 | actually_attractive.append(int(productsum[i] * rate['A{}rate'.format(i)][j]))
61 | df['A{}'.format(i)] =actually_attractive
62 | return df
63 |
64 | def a2p(self, df):
65 | # a2p 过程
66 | rate = pd.DataFrame(columns=('P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10'))
67 | attractive_sum = []
68 | for i in df.columns:
69 | # print(df[i].sum())
70 | attractive_sum.append(df[i].sum())
71 | # print(product)
72 | for j in range(11):
73 | origin_rate = []
74 | for i in range(50):
75 | origin_rate.append(df.iloc[i, j] / attractive_sum[j])
76 | # print(sum(origin_rate))
77 | # print(origin_rate)
78 | # rate = rate.append(pd.DataFrame([{'A{}'.format(j-10):origin_rate}]), ignore_index=True,sort=False)
79 | rate['P{}'.format(j)] = origin_rate
80 |
81 | for i in range(1, 11):
82 | if attractive_sum[i] != attractive_sum[i + 10]:
83 | # for j in range(50):\\\\\\\\
84 | df['P{}'.format(i)] = attractive_sum[i] * rate['P{}'.format(i)]
85 | # print(product)
86 | return df
87 |
88 | def nml(self, df):
89 | # nml 过程
90 | rate = pd.DataFrame(columns=('P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10'))
91 | attractive_sum = []
92 | for i in df.columns:
93 | # print(df[i].sum())
94 | attractive_sum.append(df[i].sum())
95 | # print(product)
96 | for j in range(11):
97 | origin_rate = []
98 | for i in range(50):
99 | origin_rate.append(df.iloc[i, j] / attractive_sum[j])
100 | # print(sum(origin_rate))
101 | # print(origin_rate)
102 | # rate = rate.append(pd.DataFrame([{'A{}'.format(j-10):origin_rate}]), ignore_index=True,sort=False)
103 | rate['P{}'.format(j)] = origin_rate
104 |
105 | for i in range(1, 11):
106 | if attractive_sum[i] != attractive_sum[i + 10]:
107 | # for j in range(50):\\\\\\\\
108 | df['P{}'.format(i)] = attractive_sum[i] * rate['P{}'.format(i)]
109 | # print(product)
110 | return df
111 |
112 |
113 | def main():
114 | file_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
115 | generation = Generation(file_name)
116 | table = generation.read_file()
117 | df = generation.calculation_model(table)
118 | balance_df = generation.p2a(df)
119 | # print(df)
120 | # print(balance_df)
121 | balance_df.to_csv("预测PA矩阵.csv", encoding="gbk", index=False) # 不传递index
122 |
123 |
124 | if __name__ == '__main__':
125 | time1 = time.time()
126 | main()
127 | time2 = time.time()
128 | print(f'耗时:{time2 - time1}秒')
129 | os.system('预测PA矩阵.csv')
130 |
--------------------------------------------------------------------------------
/示范路网小区/交通小区.shp.xml:
--------------------------------------------------------------------------------
1 | 20190409163059001.0FALSECalculateField 交通小区 Area [SHAPE_Area] VB #CalculateField 交通小区 Pop 20000 VB #CalculateField 交通小区 Stu 3000 VB #CalculateField 交通小区 Car_owned 6000 VB #CalculateField 交通小区 Job 18000 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区 C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区 交通小区.shp # "Area "Area" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Area,-1,-1;Pop "Pop" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Pop,-1,-1;Stu "Stu" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Stu,-1,-1;Car_owned "Car_owned" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Car_owned,-1,-1;Job "Job" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Job,-1,-1;Zones_ID "Zones_ID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Zones_ID,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,SHAPE_Length,-1,-1;SHAPE_Area "SHAPE_Area" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,SHAPE_Area,-1,-1" #交通小区0020.000file://\\小承故事多\C\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shpLocal Area NetworkProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190409164309002019040916430900 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414交通小区002Shapefile0.000datasetEPSG7.4.1Simple4FALSE0FALSEFALSE0交通小区Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.AreaAreaDouble1900PopPopInteger990StuStuInteger990Car_ownedCar_ownedInteger990JobJobDouble1900Zones_IDZones_IDSmallInteger440SHAPE_LengSHAPE_LengDouble1900SHAPE_AreaSHAPE_AreaDouble1900Area of feature in internal units squared.ESRIPositive real numbers that are automatically generated.20190409
2 |
--------------------------------------------------------------------------------
/出行生成/generation.py:
--------------------------------------------------------------------------------
1 | '''
2 | 出行生成模块
3 | 输入:file_name:人口及预测数据;PA计算回归公式
4 | 输出:预测PA矩阵
5 | '''
6 |
7 | import numpy as np
8 | import pandas as pd
9 | import dbfread as dbf
10 | import csv
11 | import xlwt
12 | import datetime
13 | import os
14 |
15 |
16 | class Generation:
17 | def __init__(self, file_name):
18 | self.file_name = file_name
19 |
20 | def read_file(self):
21 | '''
22 | 读取输入文件
23 | '''
24 | table = dbf.DBF(self.file_name, load=True)
25 | return table
26 |
27 | def calculation_model(self, table):
28 | df = pd.DataFrame(columns=(
29 | 'index', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6',
30 | 'A7',
31 | 'A8', 'A9', 'A10'))
32 |
33 | for i in range(50):
34 | P1 = int(23.968 * table.records[i]['TEMP_POP'] + 13.492 * table.records[i]['NAGR_STU'] - 55647.229 *
35 | table.records[i]['DUIS_33'] + 234682.728 * table.records[i]['CYZQCS_1'] - 33178.606 *
36 | table.records[i][
37 | 'DAOS_42'] + 10549.388 * table.records[i]['DSB_412'] + 0.654 * table.records[i]['TECHNICAL'])
38 | P2 = int(3398.607 * table.records[i]['FZX_1'] + 0.091 * table.records[i]['TECHNICAL'] + 558.268)
39 | P3 = int(
40 | 31.441 * table.records[i]['NCA_NAGR_P'] - 1.654 * table.records[i]['CA_POP'] + 4.122 * table.records[i][
41 | 'YDS_25'] + 5.122 * table.records[i]['YDS_33'] + 33.095 * table.records[i]['TOTAL_STU'] + 35.636 * \
42 | table.records[i]['DUIS_41'] + 64.763 * table.records[i]['DAOS_42'] - 5167.338 * table.records[i][
43 | 'DSH_412'] + 5.447 * table.records[i]['C_AGR'] + 0.275 * table.records[i]['TECHNICAL'] - 2.57 * \
44 | table.records[i]['VCS'])
45 | P4 = int(3.516 * table.records[i]['TEMP_POP'] - 11.318 * table.records[i]['TEMT_STU'])
46 | P5 = int(
47 | 38.911 * table.records[i]['DSB_12'] - 792.465 * table.records[i]['PFGFZX_5'] - 76.852 *
48 | table.records[i][
49 | 'DSB_56'] + 7.581 * table.records[i]['DAOS_7'] + 1.806 * table.records[i]['DSB_212'] + 6.396 *
50 | table.records[i]['CYZGZRK_3'] + 81 * table.records[i]['CA_WORKER'] - 26.923 * table.records[i][
51 | 'NCA_AGR_ST'] + 2.209 * table.records[i]['CA_STU'] - 16.317 * table.records[i]['YDS_34'] - 84.809 *
52 | table.records[i]['DAOS_34'] - 3.2 * table.records[i]['PRIV_CAR'] + 4.192 * table.records[i][
53 | 'CYZQCS_1'] + 4.536 * table.records[i]['YDS_41'] - 0.234 * table.records[i]['UNIT_CAR'] - 19.737 *
54 | table.records[i]['DAOS_42'] - 304.115 * table.records[i]['DSH_412'] - 121.211 * table.records[i][
55 | 'DSB_412'] - 0.101 * table.records[i]['MANU'] + 1.31 * table.records[i]['C_AGR'] + 0.045 *
56 | table.records[i]['TECHNICAL'] - 1014.87)
57 | P6 = int(
58 | -1346.7 * table.records[i]['PFGFZX_1'] + 359.369 * table.records[i]['DUIS_5'] + 212.124 *
59 | table.records[i][
60 | 'DAOS_41'] + 1.814 * table.records[i]['TECHNICAL'] + 423.01)
61 | P7 = int(831.307 * table.records[i]['CA_AGR_STU'] + 1568.597 * table.records[i]['DSB_412'] - 0.455 * \
62 | table.records[i]['COMMERCIAL'] + 6.065 * table.records[i]['CONSTRUC'] - 0.579 * table.records[i][
63 | 'PRIMARY'])
64 | P8 = int(1406.788 * table.records[i]['CA_AGR_STU'] + 0.548 * table.records[i]['TECHNICAL'])
65 | P9 = int(-17.843 * table.records[i]['NCA_AGR_PO'] + 15.152 * table.records[i]['CA_STU'])
66 | P10 = int(
67 | 151.483 * table.records[i]['DAOS_2'] - 902.88 * table.records[i]['DSB_12'] - 295.873 * table.records[i][
68 | 'PFGFZX_5'] + 902.831 * table.records[i]['DAOS_7'] + 637.124 * table.records[i][
69 | 'DSB_212'] + 156.757 * \
70 | table.records[i]['CYZGZRK_3'] - 2202.53 * table.records[i]['DSB_234'] + 2.696 * table.records[i][
71 | 'CA_WORKER'] + 0.115 * table.records[i]['TECHNICAL'] - 3428.282)
72 | A1 = int(
73 | 15.655 * table.records[i]['TEMP_POP'] + 0.508 * table.records[i]['TECHNICAL'] + 15600.2 *
74 | table.records[i][
75 | 'DSB_412'])
76 | A2 = int(0.091 * table.records[i]['TECHNICAL'] + 5550.183 * table.records[i]['DSB_412'])
77 | A3 = int(
78 | 2.811 * table.records[i]['TEMP_POP'] + 1540.784 * table.records[i]['DUIS_31'] - 20.186 *
79 | table.records[i][
80 | 'TEMT_STU'] + 0.14 * table.records[i]['TECHNICAL'] + 1120.081 * table.records[i]['DSB_412'])
81 | A4 = int(-5620.836 * table.records[i]['DUIS_32'] + 1.779 * table.records[i]['NAGR_STU'] + 1344.195 * \
82 | table.records[i]['DSB_412'] - 0.405 * table.records[i]['C_SERVICE'] + 0.162 * table.records[i][
83 | 'TECHNICAL'])
84 | A5 = int(
85 | 2.21 * table.records[i]['TEMP_POP'] + 0.335 * table.records[i]['CA_STU'] - 0.151 * table.records[i][
86 | 'C_SERVICE'] + 0.083 * table.records[i]['TECHNICAL'])
87 | A6 = int(-40.501 * table.records[i]['NCA_AGR_PO'] - 41046.051 * table.records[i]['PFGFZX_1'] + 42.289 * \
88 | table.records[i]['CA_STU'] - 37721.026 * table.records[i]['YDS_42'] + 136.153 * table.records[i][
89 | 'DSB_412'] - 3.974 * table.records[i]['C_SERVICE'] + 1.489 * table.records[i][
90 | 'TECHNICAL'] + 802022.399)
91 | A7 = int(
92 | 4.051 * table.records[i]['TEMP_POP'] + 5331.557 * table.records[i]['DAOS_31'] + 476.853 *
93 | table.records[i][
94 | 'CA_AGR_STU'] - 26.84 * table.records[i]['TEMT_STU'] + 3.375 * table.records[i][
95 | 'CA_STU'] + 50234.853 * \
96 | table.records[i]['DUIS_41'] - 1932.56 * table.records[i]['DAOS_42'] + 3610.825 * table.records[i][
97 | 'DSB_412'] - 0.224 * table.records[i]['COMMERCIAL'] + 0.182 * table.records[i]['TECHNICAL'])
98 | A8 = int(7.381 * table.records[i]['TEMP_POP'] + 915.111 * table.records[i]['CA_AGR_STU'] - 52.927 * \
99 | table.records[i]['TEMT_STU'] - 10446.220 * table.records[i]['YDS_42'] + 4837.942 *
100 | table.records[i][
101 | 'DSB_412'] + 0.253 * table.records[i]['TECHNICAL'] + 100002.545)
102 | A9 = int(9.476 * table.records[i]['NCA_AGR_PO'] + 9578.779 * table.records[i]['YDS_42'] - 4190.893 *
103 | table.records[i]['DAOS_42'] + 4978.961 * table.records[i]['DSB_412'] - 1.075 * table.records[i][
104 | 'C_SERVICE'] - 0.467 * table.records[i]['COMMERCIAL'] + 8.122 * table.records[i][
105 | 'CONSTRUC'] + 0.356 * table.records[i]['TECHNICAL'] - 0.605 * table.records[i]['SECONDARY'])
106 | A10 = int(
107 | -5.03 * table.records[i]['NCA_AGR_PO'] + 47.976 * table.records[i]['DAOS_31'] + 5.863 *
108 | table.records[i][
109 | 'CA_STU'] - 0.593 * table.records[i]['C_SERVICE'] + 0.209 * table.records[i]['TECHNICAL'])
110 | df = df.append(pd.DataFrame(
111 | {'index': [i + 1], 'P1': [P1], 'P2': [P2], 'P3': [P3], 'P4': [P4], 'P5': [P5], 'P6': [P6], 'P7': [P7],
112 | 'P8': [P8], 'P9': [P9], 'P10': [P10], 'A1': [A1], 'A2': [A2], 'A3': [A3], 'A4': [A4], 'A5': [A5],
113 | 'A6': [A6], 'A7': [A7],
114 | 'A8': [A8], 'A9': [A9], 'A10': [A10]}), ignore_index=True)
115 |
116 |
117 | #p2a 过程
118 | rate = pd.DataFrame(columns=('A1', 'A2', 'A3', 'A4', 'A5', 'A6','A7','A8', 'A9', 'A10'))
119 | productsum = []
120 | for i in df.columns:
121 | # print(df[i].sum())
122 | productsum.append(df[i].sum())
123 | # print(product)
124 | for j in range(11,21):
125 | origin_rate = []
126 | for i in range(50):
127 | origin_rate.append(df.iloc[i,j] / productsum[j])
128 | # print(sum(origin_rate))
129 | # print(origin_rate)
130 | # rate = rate.append(pd.DataFrame([{'A{}'.format(j-10):origin_rate}]), ignore_index=True,sort=False)
131 | rate['A{}'.format(j-10)] = origin_rate
132 |
133 | # print(rate)
134 |
135 | for i in range(1, 11):
136 | if productsum[i] != productsum[i + 10]:
137 | # for j in range(50):\\\\\\\\
138 | df['A{}'.format(i)] = productsum[i] * rate['A{}'.format(i)]
139 |
140 |
141 |
142 | # print(product)
143 | return df
144 |
145 |
146 | def main():
147 | file_name = '总表-变换数据-第三组_2020年预测用数据.dbf'
148 | generation = Generation(file_name)
149 | table = generation.read_file()
150 | df = generation.calculation_model(table)
151 | df.to_csv("预测PA矩阵.csv", encoding="gbk", index=False) # 不传递index
152 |
153 |
154 | if __name__ == '__main__':
155 | main()
156 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/cube小区.shp.xml:
--------------------------------------------------------------------------------
1 | 20190523103725001.0FALSECalculateField 小区 Pop 20000 VB #CalculateField 小区 Stu 20000 VB #CalculateField 小区 Car_owned 6000 VB #CalculateField 小区 Job 18000 VB #CalculateField 小区 ID 1 VB #CalculateField 小区 ID 2 VB #CalculateField 小区 ID 3 VB #CalculateField 小区 ID 4 VB #CalculateField 小区 ID 5 VB #CalculateField 小区 ID 6 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1 C:\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区 cube小区.shp # "ID "ID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,ID,-1,-1;Pop "Pop" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Pop,-1,-1;Stu "Stu" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Stu,-1,-1;Area "Area" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Area,-1,-1;Car_owned "Car_owned" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Car_owned,-1,-1;Job "Job" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Job,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,SHAPE_Length,-1,-1;SHAPE_Area "SHAPE_Area" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,SHAPE_Area,-1,-1" #file://\\小承故事多\C\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区\cube小区.shpLocal Area Networkcube小区0020.000ProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190523104632002019052310463200 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414cube小区002Shapefile0.000datasetEPSG7.4.1Simple4FALSE0FALSEFALSE0cube小区Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.IDIDSmallInteger440PopPopSmallInteger440StuStuSmallInteger440AreaAreaDouble1900Car_ownedCar_ownedSmallInteger440JobJobSmallInteger440SHAPE_LengSHAPE_LengDouble1900SHAPE_AreaSHAPE_AreaDouble1900Area of feature in internal units squared.ESRIPositive real numbers that are automatically generated.20190523
2 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/cube小区.shp.xml:
--------------------------------------------------------------------------------
1 | 20190523103725001.0FALSECalculateField 小区 Pop 20000 VB #CalculateField 小区 Stu 20000 VB #CalculateField 小区 Car_owned 6000 VB #CalculateField 小区 Job 18000 VB #CalculateField 小区 ID 1 VB #CalculateField 小区 ID 2 VB #CalculateField 小区 ID 3 VB #CalculateField 小区 ID 4 VB #CalculateField 小区 ID 5 VB #CalculateField 小区 ID 6 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1 C:\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区 cube小区.shp # "ID "ID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,ID,-1,-1;Pop "Pop" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Pop,-1,-1;Stu "Stu" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Stu,-1,-1;Area "Area" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Area,-1,-1;Car_owned "Car_owned" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Car_owned,-1,-1;Job "Job" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,Job,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,SHAPE_Length,-1,-1;SHAPE_Area "SHAPE_Area" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\小区_1,SHAPE_Area,-1,-1" #file://\\小承故事多\C\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区\cube小区.shpLocal Area Networkcube小区0020.000ProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190523104632002019052310463200 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414cube小区002Shapefile0.000datasetEPSG7.4.1Simple4FALSE0FALSEFALSE0cube小区Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.IDIDSmallInteger440PopPopSmallInteger440StuStuSmallInteger440AreaAreaDouble1900Car_ownedCar_ownedSmallInteger440JobJobSmallInteger440SHAPE_LengSHAPE_LengDouble1900SHAPE_AreaSHAPE_AreaDouble1900Area of feature in internal units squared.ESRIPositive real numbers that are automatically generated.20190523
2 |
--------------------------------------------------------------------------------
/示范路网小区/输出.dbf.xml:
--------------------------------------------------------------------------------
1 |
2 | 20190522211459001.0FALSECalculateField 交通小区 Area [SHAPE_Area] VB #CalculateField 交通小区 Pop 20000 VB #CalculateField 交通小区 Stu 3000 VB #CalculateField 交通小区 Car_owned 6000 VB #CalculateField 交通小区 Job 18000 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区 C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区 交通小区.shp # "Area "Area" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Area,-1,-1;Pop "Pop" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Pop,-1,-1;Stu "Stu" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Stu,-1,-1;Car_owned "Car_owned" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Car_owned,-1,-1;Job "Job" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Job,-1,-1;Zones_ID "Zones_ID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Zones_ID,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,SHAPE_Length,-1,-1;SHAPE_Area "SHAPE_Area" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,SHAPE_Area,-1,-1" #CalculateField 交通小区 Area [SHAPE_Area] VB #CalculateField 交通小区 Pop 2000 VB #CalculateField 交通小区 Pop 20000 VB #CalculateField 交通小区 Stu 20000 VB #CalculateField 交通小区 Car_owned 6000 VB #CalculateField 交通小区 Job 1800 VB #CalculateField 交通小区 Job 18000 VB #交通小区0020.000file://\\小承故事多\C\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shpLocal Area NetworkProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190410192032002019041019203200 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414交通小区002Shapefile0.000datasetEPSG7.4.1Simple4FALSE0FALSEFALSE0交通小区Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.AreaAreaDouble1900PopPopInteger990StuStuInteger990Car_ownedCar_ownedInteger990JobJobDouble1900Zones_IDZones_IDSmallInteger440SHAPE_LengSHAPE_LengDouble1900SHAPE_AreaSHAPE_AreaDouble1900Area of feature in internal units squared.ESRIPositive real numbers that are automatically generated.20190410
3 |
--------------------------------------------------------------------------------
/示范路网小区/路网.shp.xml:
--------------------------------------------------------------------------------
1 | 20190409163122001.0FALSECalculateField 路网 Length [SHAPE_Length] VB #CalculateField 路网 Linktype 1 VB #CalculateField 路网 Speed 60 VB #CalculateField 路网 Lanes 6 VB #CalculateField 路网 Capacity 2400 VB #CalculateField 路网 One_way 0 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网 C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区 路网.shp # "RoadID "RoadID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Name,-1,-1;Linktype "Linktype" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Linktype,-1,-1;A "A" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,A,-1,-1;B "B" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,B,-1,-1;One_way "One_way" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,One_way,-1,-1;Length "Length" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Length,-1,-1;Speed "Speed" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Speed,-1,-1;Lanes "Lanes" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Lanes,-1,-1;Capacity "Capacity" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Capacity,-1,-1;Roadscr "Roadscr" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,SHAPE_Length,-1,-1" #路网0020.000file://\\小承故事多\C\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shpLocal Area NetworkProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190409164339002019040916433900 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414路网002Shapefile0.000datasetEPSG7.4.1Simple3FALSE0FALSEFALSE0路网Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.RoadIDRoadIDSmallInteger440NameNameString5000LinktypeLinktypeSmallInteger440AASmallInteger440BBSmallInteger440One_wayOne_waySmallInteger440LengthLengthDouble1900SpeedSpeedSmallInteger440LanesLanesSmallInteger440CapacityCapacitySmallInteger440RoadscrRoadscrSmallInteger440SHAPE_LengSHAPE_LengDouble190020190409
2 |
--------------------------------------------------------------------------------
/出行生成/generation_2.py:
--------------------------------------------------------------------------------
1 | '''
2 | 出行生成模块
3 | 输入:file_name:人口及预测数据;PA计算回归公式
4 | 输出:预测PA矩阵
5 | 追加功能:对p2a ,a2p功能进行封装
6 | '''
7 |
8 | import numpy as np
9 | import pandas as pd
10 | import dbfread as dbf
11 | import csv
12 | import xlwt
13 | import datetime
14 | import os
15 |
16 |
17 | class Generation:
18 | def __init__(self, file_name):
19 | self.file_name = file_name
20 |
21 | def read_file(self):
22 | '''
23 | 读取输入文件
24 | '''
25 | table = dbf.DBF(self.file_name, load=True)
26 | return table
27 |
28 | def calculation_model(self, table):
29 | # 回归所得pa矩阵输入
30 | df = pd.DataFrame(columns=(
31 | 'index', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6',
32 | 'A7',
33 | 'A8', 'A9', 'A10'))
34 |
35 | for i in range(50):
36 | P1 = int(23.968 * table.records[i]['TEMP_POP'] + 13.492 * table.records[i]['NAGR_STU'] - 55647.229 *
37 | table.records[i]['DUIS_33'] + 234682.728 * table.records[i]['CYZQCS_1'] - 33178.606 *
38 | table.records[i][
39 | 'DAOS_42'] + 10549.388 * table.records[i]['DSB_412'] + 0.654 * table.records[i]['TECHNICAL'])
40 | P2 = int(3398.607 * table.records[i]['FZX_1'] + 0.091 * table.records[i]['TECHNICAL'] + 558.268)
41 | P3 = int(
42 | 31.441 * table.records[i]['NCA_NAGR_P'] - 1.654 * table.records[i]['CA_POP'] + 4.122 * table.records[i][
43 | 'YDS_25'] + 5.122 * table.records[i]['YDS_33'] + 33.095 * table.records[i]['TOTAL_STU'] + 35.636 * \
44 | table.records[i]['DUIS_41'] + 64.763 * table.records[i]['DAOS_42'] - 5167.338 * table.records[i][
45 | 'DSH_412'] + 5.447 * table.records[i]['C_AGR'] + 0.275 * table.records[i]['TECHNICAL'] - 2.57 * \
46 | table.records[i]['VCS'])
47 | P4 = int(3.516 * table.records[i]['TEMP_POP'] - 11.318 * table.records[i]['TEMT_STU'])
48 | P5 = int(
49 | 38.911 * table.records[i]['DSB_12'] - 792.465 * table.records[i]['PFGFZX_5'] - 76.852 *
50 | table.records[i][
51 | 'DSB_56'] + 7.581 * table.records[i]['DAOS_7'] + 1.806 * table.records[i]['DSB_212'] + 6.396 *
52 | table.records[i]['CYZGZRK_3'] + 81 * table.records[i]['CA_WORKER'] - 26.923 * table.records[i][
53 | 'NCA_AGR_ST'] + 2.209 * table.records[i]['CA_STU'] - 16.317 * table.records[i]['YDS_34'] - 84.809 *
54 | table.records[i]['DAOS_34'] - 3.2 * table.records[i]['PRIV_CAR'] + 4.192 * table.records[i][
55 | 'CYZQCS_1'] + 4.536 * table.records[i]['YDS_41'] - 0.234 * table.records[i]['UNIT_CAR'] - 19.737 *
56 | table.records[i]['DAOS_42'] - 304.115 * table.records[i]['DSH_412'] - 121.211 * table.records[i][
57 | 'DSB_412'] - 0.101 * table.records[i]['MANU'] + 1.31 * table.records[i]['C_AGR'] + 0.045 *
58 | table.records[i]['TECHNICAL'] - 1014.87)
59 | P6 = int(
60 | -1346.7 * table.records[i]['PFGFZX_1'] + 359.369 * table.records[i]['DUIS_5'] + 212.124 *
61 | table.records[i][
62 | 'DAOS_41'] + 1.814 * table.records[i]['TECHNICAL'] + 423.01)
63 | P7 = int(831.307 * table.records[i]['CA_AGR_STU'] + 1568.597 * table.records[i]['DSB_412'] - 0.455 * \
64 | table.records[i]['COMMERCIAL'] + 6.065 * table.records[i]['CONSTRUC'] - 0.579 * table.records[i][
65 | 'PRIMARY'])
66 | P8 = int(1406.788 * table.records[i]['CA_AGR_STU'] + 0.548 * table.records[i]['TECHNICAL'])
67 | P9 = int(-17.843 * table.records[i]['NCA_AGR_PO'] + 15.152 * table.records[i]['CA_STU'])
68 | P10 = int(
69 | 151.483 * table.records[i]['DAOS_2'] - 902.88 * table.records[i]['DSB_12'] - 295.873 * table.records[i][
70 | 'PFGFZX_5'] + 902.831 * table.records[i]['DAOS_7'] + 637.124 * table.records[i][
71 | 'DSB_212'] + 156.757 * \
72 | table.records[i]['CYZGZRK_3'] - 2202.53 * table.records[i]['DSB_234'] + 2.696 * table.records[i][
73 | 'CA_WORKER'] + 0.115 * table.records[i]['TECHNICAL'] - 3428.282)
74 | A1 = int(
75 | 15.655 * table.records[i]['TEMP_POP'] + 0.508 * table.records[i]['TECHNICAL'] + 15600.2 *
76 | table.records[i][
77 | 'DSB_412'])
78 | A2 = int(0.091 * table.records[i]['TECHNICAL'] + 5550.183 * table.records[i]['DSB_412'])
79 | A3 = int(
80 | 2.811 * table.records[i]['TEMP_POP'] + 1540.784 * table.records[i]['DUIS_31'] - 20.186 *
81 | table.records[i][
82 | 'TEMT_STU'] + 0.14 * table.records[i]['TECHNICAL'] + 1120.081 * table.records[i]['DSB_412'])
83 | A4 = int(-5620.836 * table.records[i]['DUIS_32'] + 1.779 * table.records[i]['NAGR_STU'] + 1344.195 * \
84 | table.records[i]['DSB_412'] - 0.405 * table.records[i]['C_SERVICE'] + 0.162 * table.records[i][
85 | 'TECHNICAL'])
86 | A5 = int(
87 | 2.21 * table.records[i]['TEMP_POP'] + 0.335 * table.records[i]['CA_STU'] - 0.151 * table.records[i][
88 | 'C_SERVICE'] + 0.083 * table.records[i]['TECHNICAL'])
89 | A6 = int(-40.501 * table.records[i]['NCA_AGR_PO'] - 41046.051 * table.records[i]['PFGFZX_1'] + 42.289 * \
90 | table.records[i]['CA_STU'] - 37721.026 * table.records[i]['YDS_42'] + 136.153 * table.records[i][
91 | 'DSB_412'] - 3.974 * table.records[i]['C_SERVICE'] + 1.489 * table.records[i][
92 | 'TECHNICAL'] + 802022.399)
93 | A7 = int(
94 | 4.051 * table.records[i]['TEMP_POP'] + 5331.557 * table.records[i]['DAOS_31'] + 476.853 *
95 | table.records[i][
96 | 'CA_AGR_STU'] - 26.84 * table.records[i]['TEMT_STU'] + 3.375 * table.records[i][
97 | 'CA_STU'] + 50234.853 * \
98 | table.records[i]['DUIS_41'] - 1932.56 * table.records[i]['DAOS_42'] + 3610.825 * table.records[i][
99 | 'DSB_412'] - 0.224 * table.records[i]['COMMERCIAL'] + 0.182 * table.records[i]['TECHNICAL'])
100 | A8 = int(7.381 * table.records[i]['TEMP_POP'] + 915.111 * table.records[i]['CA_AGR_STU'] - 52.927 * \
101 | table.records[i]['TEMT_STU'] - 10446.220 * table.records[i]['YDS_42'] + 4837.942 *
102 | table.records[i][
103 | 'DSB_412'] + 0.253 * table.records[i]['TECHNICAL'] + 100002.545)
104 | A9 = int(9.476 * table.records[i]['NCA_AGR_PO'] + 9578.779 * table.records[i]['YDS_42'] - 4190.893 *
105 | table.records[i]['DAOS_42'] + 4978.961 * table.records[i]['DSB_412'] - 1.075 * table.records[i][
106 | 'C_SERVICE'] - 0.467 * table.records[i]['COMMERCIAL'] + 8.122 * table.records[i][
107 | 'CONSTRUC'] + 0.356 * table.records[i]['TECHNICAL'] - 0.605 * table.records[i]['SECONDARY'])
108 | A10 = int(
109 | -5.03 * table.records[i]['NCA_AGR_PO'] + 47.976 * table.records[i]['DAOS_31'] + 5.863 *
110 | table.records[i][
111 | 'CA_STU'] - 0.593 * table.records[i]['C_SERVICE'] + 0.209 * table.records[i]['TECHNICAL'])
112 | df = df.append(pd.DataFrame(
113 | {'index': [i + 1], 'P1': [P1], 'P2': [P2], 'P3': [P3], 'P4': [P4], 'P5': [P5], 'P6': [P6], 'P7': [P7],
114 | 'P8': [P8], 'P9': [P9], 'P10': [P10], 'A1': [A1], 'A2': [A2], 'A3': [A3], 'A4': [A4], 'A5': [A5],
115 | 'A6': [A6], 'A7': [A7],
116 | 'A8': [A8], 'A9': [A9], 'A10': [A10]}), ignore_index=True)
117 | return df
118 |
119 | def p2a(self, df):
120 | # p2a 过程
121 | rate = pd.DataFrame(columns=('A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10'))
122 | productsum = []
123 | for i in df.columns:
124 | # print(df[i].sum())
125 | productsum.append(df[i].sum())
126 | # print(product)
127 | for j in range(11, 21):
128 | origin_rate = []
129 | for i in range(50):
130 | origin_rate.append(df.iloc[i, j] / productsum[j])
131 | # print(sum(origin_rate))
132 | # print(origin_rate)
133 | # rate = rate.append(pd.DataFrame([{'A{}'.format(j-10):origin_rate}]), ignore_index=True,sort=False)
134 | rate['A{}'.format(j - 10)] = origin_rate
135 |
136 | for i in range(1, 11):
137 | if productsum[i] != productsum[i + 10]:
138 | # for j in range(50):\\\\\\\\
139 | df['A{}'.format(i)] = productsum[i] * rate['A{}'.format(i)]
140 | # print(product)
141 | return df
142 |
143 | def a2p(self, df):
144 | # a2p 过程
145 | rate = pd.DataFrame(columns=('P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10'))
146 | attractive_sum = []
147 | for i in df.columns:
148 | # print(df[i].sum())
149 | attractive_sum.append(df[i].sum())
150 | # print(product)
151 | for j in range(11):
152 | origin_rate = []
153 | for i in range(50):
154 | origin_rate.append(df.iloc[i, j] / attractive_sum[j])
155 | # print(sum(origin_rate))
156 | # print(origin_rate)
157 | # rate = rate.append(pd.DataFrame([{'A{}'.format(j-10):origin_rate}]), ignore_index=True,sort=False)
158 | rate['P{}'.format(j)] = origin_rate
159 |
160 | for i in range(1, 11):
161 | if attractive_sum[i] != attractive_sum[i + 10]:
162 | # for j in range(50):\\\\\\\\
163 | df['P{}'.format(i)] = attractive_sum[i] * rate['P{}'.format(i)]
164 | # print(product)
165 | return df
166 |
167 | def nml(self, df):
168 | # nml 过程
169 | rate = pd.DataFrame(columns=('P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10'))
170 | attractive_sum = []
171 | for i in df.columns:
172 | # print(df[i].sum())
173 | attractive_sum.append(df[i].sum())
174 | # print(product)
175 | for j in range(11):
176 | origin_rate = []
177 | for i in range(50):
178 | origin_rate.append(df.iloc[i, j] / attractive_sum[j])
179 | # print(sum(origin_rate))
180 | # print(origin_rate)
181 | # rate = rate.append(pd.DataFrame([{'A{}'.format(j-10):origin_rate}]), ignore_index=True,sort=False)
182 | rate['P{}'.format(j)] = origin_rate
183 |
184 | for i in range(1, 11):
185 | if attractive_sum[i] != attractive_sum[i + 10]:
186 | # for j in range(50):\\\\\\\\
187 | df['P{}'.format(i)] = attractive_sum[i] * rate['P{}'.format(i)]
188 | # print(product)
189 | return df
190 |
191 | def main():
192 | file_name = '总表-变换数据-第三组_2020年预测用数据.dbf'
193 | generation = Generation(file_name)
194 | table = generation.read_file()
195 | df = generation.calculation_model(table)
196 | balance_df = generation.p2a(df)
197 | # print(df)
198 | # print(balance_df)
199 | balance_df.to_csv("预测PA矩阵.csv", encoding="gbk", index=False) # 不传递index
200 |
201 |
202 | if __name__ == '__main__':
203 | main()
204 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/交通小区.shp.xml:
--------------------------------------------------------------------------------
1 | 20190409163059001.0FALSECalculateField 交通小区 Area [SHAPE_Area] VB #CalculateField 交通小区 Pop 20000 VB #CalculateField 交通小区 Stu 3000 VB #CalculateField 交通小区 Car_owned 6000 VB #CalculateField 交通小区 Job 18000 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区 C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区 交通小区.shp # "Area "Area" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Area,-1,-1;Pop "Pop" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Pop,-1,-1;Stu "Stu" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Stu,-1,-1;Car_owned "Car_owned" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Car_owned,-1,-1;Job "Job" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Job,-1,-1;Zones_ID "Zones_ID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,Zones_ID,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,SHAPE_Length,-1,-1;SHAPE_Area "SHAPE_Area" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\交通小区,SHAPE_Area,-1,-1" #CalculateField 交通小区 Area [SHAPE_Area] VB #CalculateField 交通小区 Pop 2000 VB #CalculateField 交通小区 Pop 20000 VB #CalculateField 交通小区 Stu 20000 VB #CalculateField 交通小区 Car_owned 6000 VB #CalculateField 交通小区 Job 1800 VB #CalculateField 交通小区 Job 18000 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb 交通小区 # "Area "Area" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,Area,-1,-1;Pop "Pop" true true false 9 Long 0 9 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,Pop,-1,-1;Stu "Stu" true true false 9 Long 0 9 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,Stu,-1,-1;Car_owned "Car_owned" true true false 9 Long 0 9 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,Car_owned,-1,-1;Job "Job" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,Job,-1,-1;Zones_ID "Zones_ID" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,Zones_ID,-1,-1;SHAPE_Leng "SHAPE_Leng" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,SHAPE_Leng,-1,-1;SHAPE_Area "SHAPE_Area" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\交通小区.shp,SHAPE_Area,-1,-1" #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区 C:\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区 交通小区.shp # "Area "Area" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Area,-1,-1;Pop "Pop" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Pop,-1,-1;Stu "Stu" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Stu,-1,-1;Car_owned "Car_owned" true true false 4 Long 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Car_owned,-1,-1;Job "Job" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Job,-1,-1;Zones_ID "Zones_ID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Zones_ID,-1,-1;SHAPE_Leng "SHAPE_Leng" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,SHAPE_Leng,-1,-1;Shape_Le_1 "Shape_Length" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Shape_Length,-1,-1;Shape_Area "Shape_Area" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\交通小区,Shape_Area,-1,-1" #交通小区0020.000file://\\小承故事多\C\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区\交通小区.shpLocal Area NetworkProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190509160949002019050916094900 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414交通小区002Shapefile0.000datasetEPSG7.4.1Simple4FALSE0FALSEFALSE0交通小区Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.AreaAreaDouble1900PopPopInteger990StuStuInteger990Car_ownedCar_ownedInteger990JobJobDouble1900Zones_IDZones_IDSmallInteger440SHAPE_LengSHAPE_LengDouble1900Shape_Le_1Shape_Le_1Double1900SHAPE_AreaShape_AreaDouble1900Area of feature in internal units squared.ESRIPositive real numbers that are automatically generated.20190509
2 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/对着的版本/路网.shp.xml:
--------------------------------------------------------------------------------
1 | 20190409163122001.0FALSECalculateField 路网 Length [SHAPE_Length] VB #CalculateField 路网 Linktype 1 VB #CalculateField 路网 Speed 60 VB #CalculateField 路网 Lanes 6 VB #CalculateField 路网 Capacity 2400 VB #CalculateField 路网 One_way 0 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网 C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区 路网.shp # "RoadID "RoadID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Name,-1,-1;Linktype "Linktype" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Linktype,-1,-1;A "A" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,A,-1,-1;B "B" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,B,-1,-1;One_way "One_way" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,One_way,-1,-1;Length "Length" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Length,-1,-1;Speed "Speed" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Speed,-1,-1;Lanes "Lanes" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Lanes,-1,-1;Capacity "Capacity" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Capacity,-1,-1;Roadscr "Roadscr" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,SHAPE_Length,-1,-1" #CalculateField 路网 Name [RoadID] VB #CalculateField 路网 Name [RoadID] VB #CalculateField 路网 Name [RoadID] VB #CalculateField 路网 Linktype 1 VB #CalculateField 路网 Length [SHAPE_Leng] VB #CalculateField 路网 Length [SHAPE_Leng] VB #CalculateField 路网 Speed 60 VB #CalculateField 路网 Lanes 6 VB #CalculateField 路网 Capacity 2400 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb 路网 # "RoadID "RoadID" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Name,-1,-1;Linktype "Linktype" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Linktype,-1,-1;A "A" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,A,-1,-1;B "B" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,B,-1,-1;One_way "One_way" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,One_way,-1,-1;Length "Length" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Length,-1,-1;Speed "Speed" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Speed,-1,-1;Lanes "Lanes" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Lanes,-1,-1;Capacity "Capacity" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Capacity,-1,-1;Roadscr "Roadscr" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,SHAPE_Leng,-1,-1" #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网 C:\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区 路网.shp # "RoadID "RoadID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Name,-1,-1;Linktype "Linktype" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Linktype,-1,-1;A "A" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,A,-1,-1;B "B" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,B,-1,-1;One_way "One_way" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,One_way,-1,-1;Length "Length" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Length,-1,-1;Speed "Speed" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Speed,-1,-1;Lanes "Lanes" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Lanes,-1,-1;Capacity "Capacity" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Capacity,-1,-1;Roadscr "Roadscr" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,SHAPE_Leng,-1,-1;Shape_Le_1 "Shape_Length" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\新示范\路网,Shape_Length,-1,-1" #路网0020.000file://\\小承故事多\C\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区\路网.shpLocal Area NetworkProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190509161007002019050916100700 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414路网002Shapefile0.000datasetEPSG7.4.1Simple3FALSE0FALSEFALSE0路网Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.RoadIDRoadIDSmallInteger440NameNameString5000LinktypeLinktypeSmallInteger440AASmallInteger440BBSmallInteger440One_wayOne_waySmallInteger440LengthLengthDouble1900SpeedSpeedSmallInteger440LanesLanesSmallInteger440CapacityCapacitySmallInteger440RoadscrRoadscrSmallInteger440SHAPE_LengSHAPE_LengDouble1900Shape_Le_1Shape_Le_1Double190020190509
2 |
--------------------------------------------------------------------------------
/出行分布/示范路网小区/路网.shp.xml:
--------------------------------------------------------------------------------
1 | 20190409163122001.0FALSECalculateField 路网 Length [SHAPE_Length] VB #CalculateField 路网 Linktype 1 VB #CalculateField 路网 Speed 60 VB #CalculateField 路网 Lanes 6 VB #CalculateField 路网 Capacity 2400 VB #CalculateField 路网 One_way 0 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网 C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区 路网.shp # "RoadID "RoadID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Name,-1,-1;Linktype "Linktype" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Linktype,-1,-1;A "A" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,A,-1,-1;B "B" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,B,-1,-1;One_way "One_way" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,One_way,-1,-1;Length "Length" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Length,-1,-1;Speed "Speed" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Speed,-1,-1;Lanes "Lanes" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Lanes,-1,-1;Capacity "Capacity" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Capacity,-1,-1;Roadscr "Roadscr" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\建立数据库\新建文件地理数据库.gdb\西安\路网,SHAPE_Length,-1,-1" #CalculateField 路网 Name [RoadID] VB #CalculateField 路网 Name [RoadID] VB #CalculateField 路网 Name [RoadID] VB #CalculateField 路网 Linktype 1 VB #CalculateField 路网 Length [SHAPE_Leng] VB #CalculateField 路网 Length [SHAPE_Leng] VB #CalculateField 路网 Speed 60 VB #CalculateField 路网 Lanes 6 VB #CalculateField 路网 Capacity 2400 VB #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb 路网 # "RoadID "RoadID" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Name,-1,-1;Linktype "Linktype" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Linktype,-1,-1;A "A" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,A,-1,-1;B "B" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,B,-1,-1;One_way "One_way" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,One_way,-1,-1;Length "Length" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Length,-1,-1;Speed "Speed" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Speed,-1,-1;Lanes "Lanes" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Lanes,-1,-1;Capacity "Capacity" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Capacity,-1,-1;Roadscr "Roadscr" true true false 4 Short 0 4 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" true true false 19 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\路网.shp,SHAPE_Leng,-1,-1" #FeatureClassToFeatureClass C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1 C:\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区 路网.shp # "RoadID "RoadID" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,RoadID,-1,-1;Name "Name" true true false 50 Text 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Name,-1,-1;Linktype "Linktype" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Linktype,-1,-1;A "A" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,A,-1,-1;B "B" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,B,-1,-1;One_way "One_way" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,One_way,-1,-1;Length "Length" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Length,-1,-1;Speed "Speed" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Speed,-1,-1;Lanes "Lanes" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Lanes,-1,-1;Capacity "Capacity" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Capacity,-1,-1;Roadscr "Roadscr" true true false 2 Short 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Roadscr,-1,-1;SHAPE_Leng "SHAPE_Leng" true true false 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,SHAPE_Leng,-1,-1;Shape_Le_1 "Shape_Length" false true true 8 Double 0 0 ,First,#,C:\Users\Administrator\Desktop\毕业设计\参考非文献资料\GIS建立路网\示范路网小区\新示范.gdb\xinxinshifan\路网1,Shape_Length,-1,-1" #路网0020.000file://\\小承故事多\C\Users\Administrator\Desktop\python_work\毕业设计\出行分布\示范路网小区\路网.shpLocal Area NetworkProjectedGCS_Xian_1980Xian_1980_3_Degree_GK_CM_108E<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS["Xian_1980_3_Degree_GK_CM_108E",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",2381]]</WKT><XOrigin>-5123200</XOrigin><YOrigin>-10002100</YOrigin><XYScale>450265407.00157917</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2381</WKID></ProjectedCoordinateSystem>20190531145226002019053114522600 Version 6.2 (Build 9200) ; ESRI ArcGIS 10.0.0.2414路网002Shapefile0.000datasetEPSG7.4.1Simple3FALSE0FALSEFALSE0路网Feature Class0FIDFIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.RoadIDRoadIDSmallInteger440NameNameString5000LinktypeLinktypeSmallInteger440AASmallInteger440BBSmallInteger440One_wayOne_waySmallInteger440LengthLengthDouble1900SpeedSpeedSmallInteger440LanesLanesSmallInteger440CapacityCapacitySmallInteger440RoadscrRoadscrSmallInteger440SHAPE_LengSHAPE_LengDouble1900Shape_Le_1Shape_Le_1Double190020190531
2 |
--------------------------------------------------------------------------------
/出行分布/distribution_3.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | '''
3 | 输入:.shp路网文件
4 | pa矩阵
5 | 功能:1.读取路网文件
6 | 2.计算路径时间
7 | 3.检索最短路径
8 | 4.解决小区到小区问题,现在将小区与小区节点路径修正到原来的节点中
9 | 5.增加了迭代次数
10 | 问题:重力模型里gamma值没有修正,只做了单约束没做双约束导致PA不平衡
11 | * ━━━━━━神兽出没━━━━━━
12 | * ┏┓ ┏┓
13 | * ┏┛┻━━━┛┻┓
14 | * ┃ ┃
15 | * ┃ ━ ┃
16 | * ┃ ┳┛ ┗┳ ┃
17 | * ┃ ┃
18 | * ┃ ┻ ┃
19 | * ┃ ┃
20 | * ┗━┓ ┏━┛Code is far away from bug with the animal protecting
21 | * ┃ ┃ 神兽保佑,代码无bug
22 | * ┃ ┃
23 | * ┃ ┗━━━┓
24 | * ┃ ┣┓
25 | * ┃ ┏┛
26 | * ┗┓┓┏━┳┓┏┛
27 | * ┃┫┫ ┃┫┫
28 | * ┗┻┛ ┗┻┛
29 | *
30 | * ━━━━━━感觉萌萌哒━━━━━━
31 | '''
32 |
33 | import numpy as np
34 | import pandas as pd
35 | import dbfread as dbf
36 | import csv
37 | import shapefile
38 | import matplotlib.pyplot as plt
39 | import geopandas as gdf
40 | import math
41 | import time
42 | import copy
43 | import os
44 |
45 |
46 | def read_shp(file_name, point_number,
47 | vot=[4230.8, 3296.3, 3661.525, 3854.55, 3527.65, 4953.2, 4393.55, 5257.7, 5534.025, 6173.825]):
48 | '''
49 | 读取路网文件,并设置dijkstra法基础矩阵
50 | :param file_name:文件路径
51 | 缺省vot方便用户自己选择是否输入
52 | :return:将原始存在直接路径的路阻进行赋值
53 | '''
54 | sf = shapefile.Reader(file_name, encoding='gbk')
55 |
56 | df = pd.DataFrame(columns=(
57 | 'A', 'B', 'lw_time', 'C', 'V'))
58 | sf_records = sf.records()
59 |
60 | i = 1
61 | self_list = [0]
62 | for i in range(1, 1 + point_number):
63 | self_list.append(i * (point_number + 1))
64 | arr = np.arange(point_number ** 2)
65 |
66 | for i in range(point_number ** 2):
67 | arr[i] = 999999
68 | if i in self_list:
69 | arr[i] = 0
70 | dir_link = pd.DataFrame(arr.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
71 | index=(range(1, 1 + point_number)))
72 |
73 | for sf_record in sf_records:
74 | lw_time = (sf_record.Length / sf_record.Speed * 60 + 0.3 * vot[1])
75 |
76 | A = sf_record[3]
77 | B = sf_record[4]
78 | C = sf_record[9]
79 | dir_link[B][A] = lw_time
80 | dir_link[A][B] = lw_time
81 | df = df.append(pd.DataFrame({'A': [A], 'B': [B], 'lw_time': [lw_time], 'V': 0, 'C': [C]}))
82 | sf.close()
83 |
84 | return dir_link
85 |
86 |
87 | def zdy_dijkstra(dir_link):
88 | '''
89 | dijkstra最短路径搜索
90 | :param dir_link:
91 | :return:各节点间最短路径路阻确定
92 | '''
93 | road_list = []
94 | point_number = len(dir_link)
95 | origin_dir_link = copy.deepcopy(dir_link)
96 | work_dir_link = copy.deepcopy(dir_link)
97 | for start in range(1, point_number + 1): # 定义起始节点
98 | for end in range(1, point_number + 1): # 定义目标节点
99 | link_list = []
100 | link_list.append(start)
101 | zdy_list = [] # 清空最短路径列表
102 | for k in range(1, point_number + 1):
103 | zdy_list.append(work_dir_link[start][k] + work_dir_link[k][end]) # 检索前节点到目标节点最短路
104 |
105 | if min(zdy_list) < work_dir_link[start][end]:
106 | work_dir_link[start][end] = min(zdy_list) # 计算最短路与目标值对比
107 | work_dir_link[end][start] = work_dir_link[start][end] # 矩阵对称同步
108 | link_list.append(zdy_list.index(min(zdy_list)) + 1)
109 | link_list.append(end)
110 | road_list.append(link_list)
111 |
112 | array1 = np.array(road_list).T
113 | df1 = pd.DataFrame(array1.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
114 | index=(range(1, 1 + point_number)))
115 | df1.to_csv("路径12213.csv", encoding="gbk", index=False)
116 |
117 | # 得到最短路径的路径list
118 |
119 | for l_list in road_list:
120 | i = 0
121 | # for i in range(len(l_list) - 1):
122 | print(l_list)
123 | while i < (len(l_list) - 1):
124 | if origin_dir_link[l_list[i]][l_list[i + 1]] == 999999 :
125 | print('cuowu',road_list[(l_list[i] - 1) * point_number + l_list[i + 1] - 1][1])
126 | l_list.insert(i + 1, road_list[(l_list[i] - 1) * point_number + l_list[i + 1] - 1][1])
127 |
128 | i+=1
129 | print('over')
130 | # 将路径list进行整列成为矩阵
131 | array = np.array(road_list).T
132 | # print(array)
133 | df = pd.DataFrame(array.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
134 | index=(range(1, 1 + point_number)))
135 | for i in range(1, point_number + 1):
136 | for j in range(i, point_number + 1):
137 | df[i][j] = list(reversed(df[j][i]))
138 | df.to_csv("路径.csv", encoding="gbk", index=False)
139 | return work_dir_link, df
140 |
141 |
142 | def read_info(file_name, zonal_name):
143 | # 读取路网文件
144 | sf = shapefile.Reader(file_name)
145 | shapes = sf.shapes()
146 | fields = sf.fields
147 | records = sf.records()
148 | fields_name = []
149 | # 将路网信息从dbf转换为矩阵
150 | for field in fields:
151 | fields_name.append(field[0])
152 | del fields_name[0]
153 | table = []
154 | for record in records:
155 | table.append(record[:])
156 | net_info = pd.DataFrame(table, columns=fields_name)
157 |
158 | # 将点坐标与点建立对应矩阵
159 | point_dict = {}
160 | for i in range(len(shapes)):
161 | # for j in range(len(shapes[i].points)):
162 | point_dict[net_info['A'][i]] = shapes[i].points[0]
163 | point_dict[net_info['B'][i]] = shapes[i].points[1]
164 | point_info = pd.DataFrame(list(point_dict.items()), columns=['点', '坐标'])
165 | point_info.to_csv("点坐标信息.csv", encoding="gbk", index=False)
166 |
167 | # 读取小区数据
168 | zonal_sf = shapefile.Reader(zonal_name)
169 | zonal_shapes = zonal_sf.shapes()
170 | zonal_fields = zonal_sf.fields
171 | zonal_records = zonal_sf.records()
172 |
173 | # 小区周边邻接矩阵点读入
174 | zonal_point_info = {}
175 |
176 | for i in range(len(zonal_shapes)):
177 | zonal_point_list = []
178 | for j in range(point_info.shape[0]):
179 | if point_info['坐标'][j] in zonal_shapes[i].points:
180 | zonal_point_list.append(j)
181 | zonal_point_info['{}'.format(i)] = zonal_point_list
182 | return zonal_point_info
183 |
184 |
185 | def zonal_inter_link(road_cost, zonal_point_info):
186 | # 计算区内出行时间:小区周边道路出行最短行程时间/2
187 | zonal_inter_cost = {}
188 | i = 1
189 | for value in zonal_point_info.values():
190 |
191 | inter_cost = []
192 |
193 | for origin in value:
194 | for end in value:
195 | if end != origin:
196 | inter_cost.append(road_cost[origin + 1][end + 1])
197 |
198 | zonal_inter_cost[i] = min(inter_cost) / 2
199 | i += 1
200 |
201 | zonal_inter_cost_pd = pd.Series(zonal_inter_cost)
202 |
203 | zonal_dir_link_cost = pd.DataFrame(columns=range(1, len(zonal_point_info) + 1),
204 | index=range(1, len(zonal_point_info) + 1))
205 |
206 | zonal_point_info_pd = pd.Series(zonal_point_info)
207 |
208 | for i in range(len(zonal_point_info)):
209 | for j in range(len(zonal_point_info)):
210 | if i == j:
211 | zonal_dir_link_cost[i + 1][j + 1] = 0
212 | else:
213 | # 清空小区周边路网路阻列表
214 | zonal_cost = []
215 | # 拾取小区周边节点并进行基于对应节点进行阻抗计算
216 | for item_a in zonal_point_info_pd[i]:
217 | for item_b in zonal_point_info_pd[j]:
218 | if item_a == item_b:
219 | continue
220 | zonal_cost.append(road_cost[item_a + 1][item_b + 1])
221 |
222 | zonal_dir_link_cost[i + 1][j + 1] = min(zonal_cost)
223 |
224 | # 将计算所得小区区内出行时间加到路径出行时间上
225 | for i in range(1, 1 + len(zonal_point_info)):
226 | # print(zonal_inter_cost_pd[i])
227 | zonal_dir_link_cost[i] += zonal_inter_cost_pd[i]
228 | zonal_dir_link_cost[i][i] -= zonal_inter_cost_pd[i]
229 | return zonal_dir_link_cost
230 |
231 |
232 | def gravity_calculation(traffic_cost, pa):
233 | '''
234 | 计算各小区间交通量
235 | :param traffic_cost: 成本矩阵
236 | :param pa: PA矩阵
237 | :return:
238 | '''
239 | traffic_distribution = pd.DataFrame(columns=range(1, len(traffic_cost) + 1), index=range(1, len(traffic_cost) + 1))
240 |
241 | for i in range(len(traffic_cost)):
242 | for j in range(len(traffic_cost)):
243 | sum_list = []
244 | for k in range(len(traffic_cost)):
245 | # print(PA['A1'][k],traffic_cost.iloc[i][k+1])
246 | sum_list.append(pa['A1'][k] * traffic_cost.iloc[k][i + 1])
247 |
248 | # print(sum_list)
249 | # print(PA[1][i],PA[2][j],traffic_cost[i][j + 1],sum(sum_list))
250 |
251 | traffic_distribution.iloc[j][i + 1] = int(pa['P1'][i] * pa["A1"][j] * traffic_cost.iloc[j][i + 1] / sum(
252 | sum_list))
253 | traffic_distribution.insert(0, 'index', range(1, 1 + len(traffic_cost)))
254 |
255 | return traffic_distribution
256 |
257 |
258 | def gravity_model(traffic_cost, PAmatrix):
259 | '''
260 | 重力模型
261 | :param traffic_cost: 路阻函数
262 | :param PAmatrix: 产生吸引矩阵
263 | :return:
264 | '''
265 | # 试算调整gamma值
266 | gamma = 2
267 | # f(cij)函数运算
268 | traffic_cost = traffic_cost[traffic_cost != 0] ** -gamma
269 | traffic_cost = traffic_cost.fillna(0)
270 | traffic_distribution = gravity_calculation(traffic_cost, PAmatrix)
271 | return traffic_distribution
272 |
273 |
274 | def bpr_caculation(t, vc, a=0.15, b=4):
275 | # 基于BPR函数计算加载交通量对路阻影响
276 | t = t * (1 + a * (vc ** b))
277 | return t
278 |
279 |
280 | def assignment(file_name, zonal_name, road_cost, distribution_matrix, dir_link_df, link_time, zonal_point_info):
281 | zonal_point_info_pd = pd.Series(zonal_point_info)
282 | n_sf = shapefile.Reader(file_name)
283 | z_sf = shapefile.Reader(zonal_name)
284 | n_sf_records = n_sf.records()
285 | link_df = pd.DataFrame(columns=(
286 | 'A', 'B', 'lw_time', 'c', 'v', 'opposite_v'))
287 | # 设置基础的路径矩阵
288 | for n_sf_record in n_sf_records:
289 | A = n_sf_record[3]
290 | B = n_sf_record[4]
291 | C = n_sf_record[9]
292 | lw_time = (n_sf_record.Length / n_sf_record.Speed * 60 + 0.3 * 3296.3)
293 | link_df = link_df.append(
294 | pd.DataFrame({'A': [A], 'B': [B], 'lw_time': [lw_time], 'v': 0, 'opposite_v': 0, 'c': [C]}))
295 | origin_link_df = copy.deepcopy(link_df)
296 | for col in range(0, len(zonal_point_info)): # 检索每个交通小区的OD,这一步先不做,只做小区1 到小区2的路径
297 | for loc in range(1, len(zonal_point_info) + 1):
298 | number = 0
299 | if col + 1 != loc: # 起终点小区不一致
300 | zonal_cost = {}
301 | # 拾取小区周边节点并进行确定小区之间最短阻抗的路径节点
302 | for item_a in zonal_point_info_pd[col]:
303 | for item_b in zonal_point_info_pd[loc - 1]:
304 | if item_a == item_b:
305 | continue
306 | zonal_cost[(item_a + 1, item_b + 1)] = road_cost[item_a + 1][item_b + 1]
307 | # print(zonal_cost)
308 | ori_zonal_min_dir = min(zonal_cost, key=zonal_cost.get)
309 | zonal_min_dir = ori_zonal_min_dir[:]
310 |
311 | # 以100为一个迭代单位采用容量限制增量分配法进行迭代分配
312 | while number < distribution_matrix.iloc[col, loc]: # 判定一个小区分配完毕条件
313 | work_list = dir_link_df[zonal_min_dir[0]][zonal_min_dir[1]]
314 | for j in range(len(work_list) - 1): # 针对最短路径中每条路进行分配流量
315 | # print(col + 1, loc)
316 | # print(work_list, j, distribution_matrix.iloc[col, loc] - number)
317 | link_df.loc[((link_df.A == work_list[j]) & (link_df.B == work_list[j + 1])) | (
318 | (link_df.B == work_list[j]) & (link_df.A == work_list[j + 1])), 'v'] += 500
319 | # 拾取正在工作的单位行
320 | work_link = link_df.loc[((link_df.A == work_list[j]) & (link_df.B == work_list[j + 1])) | (
321 | (link_df.B == work_list[j]) & (link_df.A == work_list[j + 1]))]
322 |
323 | origin_work_link = origin_link_df.loc[
324 | ((origin_link_df.A == work_list[j]) & (origin_link_df.B == work_list[j + 1])) | (
325 | (origin_link_df.B == work_list[j]) & (origin_link_df.A == work_list[j + 1]))]
326 | print(work_list)
327 | print(work_link)
328 | print(origin_work_link)
329 | new_lw_time = bpr_caculation( # 计算分配交通量后的新路阻
330 | float(origin_work_link.loc[0]['lw_time']),
331 | (float(work_link.loc[0]['v']) / work_link.loc[0]['c']))
332 | # 将新阻抗写入路径矩阵
333 | link_df.loc[(link_df.A == work_list[j]) & (link_df.B == work_list[j + 1]) | (
334 | (link_df.B == work_list[j]) & (
335 | link_df.A == work_list[j + 1])), 'lw_time'] = new_lw_time
336 | # 基于新路阻计算新的整个路网路阻及路阻函数
337 | link_time[work_list[j]][work_list[j + 1]] = new_lw_time
338 | link_time[work_list[j + 1]][work_list[j]] = new_lw_time
339 | road_cost, dir_link_df = zdy_dijkstra(link_time)
340 | number += 500
341 |
342 | else: # 对于每次以100为迭代单位导致的剩余量进行相同操作
343 | # print('该计算单元已结束')
344 | for j in range(len(work_list) - 1):
345 | link_df.loc[((link_df.A == work_list[j]) & (link_df.B == work_list[j + 1])) | (
346 | (link_df.B == work_list[j]) & (link_df.A == work_list[j + 1])), 'v'] += \
347 | distribution_matrix.iloc[col, loc] + 500 - number
348 | work_link = link_df.loc[((link_df.A == work_list[j]) & (link_df.B == work_list[j + 1])) | (
349 | (link_df.B == work_list[j]) & (link_df.A == work_list[j + 1]))]
350 |
351 | origin_work_link = origin_link_df.loc[
352 | ((origin_link_df.A == work_list[j]) & (origin_link_df.B == work_list[j + 1])) | (
353 | (origin_link_df.B == work_list[j]) & (origin_link_df.A == work_list[j + 1]))]
354 | new_lw_time = bpr_caculation(
355 | float(origin_work_link.loc[0]['lw_time']),
356 | (float(work_link.loc[0]['v']) / work_link.loc[0]['c']))
357 | # 计算新阻抗
358 | link_df.loc[(link_df.A == work_list[j]) & (link_df.B == work_list[j + 1]) | (
359 | (link_df.B == work_list[j]) & (
360 | link_df.A == work_list[j + 1])), 'lw_time'] = new_lw_time
361 |
362 | link_time[work_list[j]][work_list[j + 1]] = new_lw_time
363 | link_time[work_list[j + 1]][work_list[j]] = new_lw_time
364 | road_cost, dir_link_df = zdy_dijkstra(link_time)
365 | # link_df为携带着加载交通量的路网信息文件
366 | print(link_df)
367 | return road_cost, dir_link_df, link_df
368 |
369 |
370 | def main():
371 | file_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
372 | zonal_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
373 | link_time = read_shp(file_name, 12)
374 |
375 | origin_dir_link = copy.deepcopy(link_time) # 对于读取文件获得的路网基础路阻文件进行备份
376 | road_cost, dir_link_df = zdy_dijkstra(link_time) # 采用dijkstra算法得到路网路阻及对应的最短路径文件
377 |
378 | zonal_point_info = read_info(file_name, zonal_name) # 读取小区文件中,每个小区周边的节点信息
379 |
380 | for i in range(3):
381 | traffic_cost = zonal_inter_link(road_cost, zonal_point_info) # 计算小区之间的出行成本
382 | traffic_cost.to_csv("出行成本.csv", encoding="gbk", index=False)
383 | PAfile_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行生成\\预测PA矩阵.csv'
384 | PAfile_data = pd.read_csv(PAfile_name, low_memory=False) # 防止弹出警告
385 | PAfile_df = pd.DataFrame(PAfile_data)
386 |
387 | distribution_matrix = gravity_model(traffic_cost, PAfile_df)
388 |
389 | # 返回分配后的加载路阻,对应各节点之间最短路径,携带加载流量的路径文件
390 | road_cost, dir_link_df, link_df = assignment(file_name, zonal_name, road_cost, distribution_matrix, dir_link_df,
391 | origin_dir_link, zonal_point_info)
392 |
393 | distribution_matrix.to_csv("分布矩阵.csv", encoding="gbk", index=False)
394 | # plt.rcParams['font.sans-serif'] = ['SimHei']
395 | # plt.rcParams['axes.unicode_minus'] = False
396 | # distribution_matrix[1:].plot(kind='bar', stacked=True, title='各小区间分布交通量', edgecolor='black', linewidth=1, alpha=0.8,
397 | # rot=0)
398 | # geopandas用于绘图
399 | # nybb_path = gdf.datasets.get_path('交通小区')
400 |
401 | # # 可视化部分代码
402 | # nybb_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
403 | # n = gdf.GeoDataFrame.from_file(file_name, encoding='gb18030')
404 | # g = gdf.GeoDataFrame.from_file(nybb_path, encoding='gb18030')
405 | # # g['geometry'].convex_hull
406 | # # # g.set_index('BoroCode', inplace=True)
407 | # # # g.sort()
408 | # g['centroid_column'] = g.centroid
409 | # # g.coords[:]
410 | # # print(type(g['centroid_column'][1]))
411 | # # print(g['centroid_column'][1])
412 | # zuobiao = []
413 | #
414 | # for i in range(4):
415 | # zuobiao.append([g['centroid_column'][i].x, g['centroid_column'][i].y])
416 | # # print(zuobiao)
417 | # # plt.plot(zuobiao[1], zuobiao[2], color='r')
418 | # # for i in range(4):
419 | # # for j in range(4):
420 | # # if i != j :
421 | # # plt.plot(zuobiao[i],zuobiao[j], color='r')
422 | # # plt.scatter(zuobiao[i],zuobiao[j], color='b')
423 | # # g.plot()
424 | # t = g.set_geometry('centroid_column')
425 | # # print(t)
426 | # # print(type(g))
427 | # # print(g['centroid_column'])
428 | # # for i in range(4):
429 | # # for j in range(4):
430 | # # if i != j:
431 | # # print(g['centroid_column'][i], g['centroid_column'][j])
432 | # # g.plot(g['centroid_column'][i], g['centroid_column'][j], color='r')
433 | # # 出图部分
434 | # ax1 = g.plot(color='blue')
435 | # ax2 = n.plot(color='black', ax=ax1)
436 | # t.plot(ax=ax2, color='r')
437 | # #
438 | # # # print(g['geometry'])
439 | # plt.show()
440 | # # # print(g)
441 |
442 |
443 | if __name__ == '__main__':
444 | time1 = time.time()
445 | main()
446 | time2 = time.time()
447 | # 输出执行时间
448 | print(f'耗时:{time2 - time1}秒')
449 | # #打开文件
450 | # os.system('分布矩阵.csv')
451 |
--------------------------------------------------------------------------------
/出行分布/distribution_2.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | '''
3 | 输入:.shp路网文件
4 | pa矩阵
5 | 功能:1.读取路网文件
6 | 2.计算路径时间
7 | 3.检索最短路径
8 | 问题:重力模型里gamma值没有修正,只做了单约束没做双约束导致PA不平衡
9 |
10 | '''
11 |
12 | import numpy as np
13 | import pandas as pd
14 | import dbfread as dbf
15 | import csv
16 | import shapefile
17 | import matplotlib.pyplot as plt
18 | import geopandas as gdf
19 | import math
20 | import time
21 | import copy
22 | import os
23 |
24 |
25 | def read_shp(file_name, point_number,
26 | vot=[4230.8, 3296.3, 3661.525, 3854.55, 3527.65, 4953.2, 4393.55, 5257.7, 5534.025, 6173.825]):
27 | '''
28 | 读取路网文件,并设置dijkstra法基础矩阵
29 | :param file_name:文件路径
30 | 缺省vot方便用户自己选择是否输入
31 | :return:将原始存在直接路径的路阻进行赋值
32 | '''
33 | sf = shapefile.Reader(file_name, encoding='gbk')
34 |
35 | df = pd.DataFrame(columns=(
36 | 'A', 'B', 'lw_time', 'C', 'V'))
37 | sf_records = sf.records()
38 |
39 | i = 1
40 | self_list = [0]
41 | for i in range(1, 1 + point_number):
42 | self_list.append(i * (point_number + 1))
43 | arr = np.arange(point_number ** 2)
44 |
45 | for i in range(point_number ** 2):
46 | arr[i] = 999999
47 | if i in self_list:
48 | arr[i] = 0
49 | dir_link = pd.DataFrame(arr.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
50 | index=(range(1, 1 + point_number)))
51 |
52 | for sf_record in sf_records:
53 | lw_time = (sf_record.Length / sf_record.Speed * 60 + 0.3 * vot[1])
54 |
55 | A = sf_record[3]
56 | B = sf_record[4]
57 | C = sf_record[9]
58 | dir_link[B][A] = lw_time
59 | dir_link[A][B] = lw_time
60 | df = df.append(pd.DataFrame({'A': [A], 'B': [B], 'lw_time': [lw_time], 'V': 0, 'C': [C]}))
61 | sf.close()
62 | return dir_link
63 |
64 |
65 | def zdy_dijkstra(dir_link):
66 | '''
67 | dijkstra最短路径搜索
68 | :param dir_link:
69 | :return:各节点间最短路径路阻确定
70 | '''
71 | road_list = []
72 | point_number = len(dir_link)
73 | origin_dir_link = copy.deepcopy(dir_link)
74 | work_dir_link = copy.deepcopy(dir_link)
75 | for start in range(1, point_number + 1): # 定义起始节点
76 | for end in range(1, point_number + 1): # 定义目标节点
77 | link_list = []
78 | link_list.append(start)
79 | zdy_list = [] # 清空最短路径列表
80 | for k in range(1, point_number + 1):
81 | zdy_list.append(work_dir_link[start][k] + work_dir_link[k][end]) # 检索前节点到目标节点最短路
82 |
83 | if min(zdy_list) < work_dir_link[start][end]:
84 | work_dir_link[start][end] = min(zdy_list) # 计算最短路与目标值对比
85 | work_dir_link[end][start] = work_dir_link[start][end] # 矩阵对称同步
86 | link_list.append(zdy_list.index(min(zdy_list)) + 1)
87 | link_list.append(end)
88 | road_list.append(link_list)
89 |
90 | # 得到最短路径的路径list
91 | for l_list in road_list:
92 | for i in range(len(l_list) - 1):
93 | if origin_dir_link[l_list[i]][l_list[i + 1]] == 999999:
94 | l_list.insert(i + 1, road_list[(l_list[i] - 1) * point_number + l_list[i + 1] - 1][1])
95 | # 将路径list进行整列成为矩阵
96 | array = np.array(road_list).T
97 | # print(array)
98 | df = pd.DataFrame(array.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
99 | index=(range(1, 1 + point_number)))
100 | for i in range(1, point_number + 1):
101 | for j in range(i, point_number + 1):
102 | df[i][j] = list(reversed(df[j][i]))
103 | return work_dir_link, df
104 |
105 |
106 | def read_info(file_name, zonal_name):
107 | # 读取路网文件
108 | sf = shapefile.Reader(file_name)
109 | shapes = sf.shapes()
110 | fields = sf.fields
111 | records = sf.records()
112 | fields_name = []
113 | # 将路网信息从dbf转换为矩阵
114 | for field in fields:
115 | fields_name.append(field[0])
116 | del fields_name[0]
117 | table = []
118 | for record in records:
119 | table.append(record[:])
120 | net_info = pd.DataFrame(table, columns=fields_name)
121 |
122 | # 将点坐标与点建立对应矩阵
123 | point_dict = {}
124 | for i in range(len(shapes)):
125 | # for j in range(len(shapes[i].points)):
126 | point_dict[net_info['A'][i]] = shapes[i].points[0]
127 | point_dict[net_info['B'][i]] = shapes[i].points[1]
128 | point_info = pd.DataFrame(list(point_dict.items()), columns=['点', '坐标'])
129 | point_info.to_csv("点坐标信息.csv", encoding="gbk", index=False)
130 |
131 | # 读取小区数据
132 | zonal_sf = shapefile.Reader(zonal_name)
133 | zonal_shapes = zonal_sf.shapes()
134 | zonal_fields = zonal_sf.fields
135 | zonal_records = zonal_sf.records()
136 |
137 | # 小区周边邻接矩阵点读入
138 | zonal_point_info = {}
139 |
140 | for i in range(len(zonal_shapes)):
141 | zonal_point_list = []
142 | for j in range(point_info.shape[0]):
143 | if point_info['坐标'][j] in zonal_shapes[i].points:
144 | zonal_point_list.append(j)
145 | zonal_point_info['{}'.format(i)] = zonal_point_list
146 | return zonal_point_info
147 |
148 |
149 | def zonal_inter_link(road_cost, zonal_point_info):
150 | # 计算区内出行时间:小区周边道路出行最短行程时间/2
151 | zonal_inter_cost = {}
152 | i = 1
153 | for value in zonal_point_info.values():
154 |
155 | inter_cost = []
156 |
157 | for origin in value:
158 | for end in value:
159 | if end != origin:
160 | inter_cost.append(road_cost[origin + 1][end + 1])
161 |
162 | zonal_inter_cost[i] = min(inter_cost) / 2
163 | i += 1
164 |
165 | zonal_inter_cost_pd = pd.Series(zonal_inter_cost)
166 |
167 | zonal_dir_link_cost = pd.DataFrame(columns=range(1, len(zonal_point_info) + 1),
168 | index=range(1, len(zonal_point_info) + 1))
169 |
170 |
171 | zonal_point_info_pd = pd.Series(zonal_point_info)
172 |
173 | for i in range(len(zonal_point_info)):
174 | for j in range(len(zonal_point_info)):
175 | if i == j:
176 | zonal_dir_link_cost[i + 1][j + 1] = 0
177 | else:
178 | # 清空小区周边路网路阻列表
179 | zonal_cost = []
180 | # 拾取小区周边节点并进行基于对应节点进行阻抗计算
181 | for item_a in zonal_point_info_pd[i]:
182 | for item_b in zonal_point_info_pd[j]:
183 | if item_a == item_b:
184 | continue
185 | zonal_cost.append(road_cost[item_a + 1][item_b + 1])
186 |
187 | zonal_dir_link_cost[i + 1][j + 1] = min(zonal_cost)
188 |
189 | # 将计算所得小区区内出行时间加到路径出行时间上
190 | for i in range(1, 1 + len(zonal_point_info)):
191 | # print(zonal_inter_cost_pd[i])
192 | zonal_dir_link_cost[i] += zonal_inter_cost_pd[i]
193 | zonal_dir_link_cost[i][i] -= zonal_inter_cost_pd[i]
194 | return zonal_dir_link_cost
195 |
196 |
197 | def gravity_calculation(traffic_cost, pa):
198 | '''
199 | 计算各小区间交通量
200 | :param traffic_cost: 成本矩阵
201 | :param pa: PA矩阵
202 | :return:
203 | '''
204 | traffic_distribution = pd.DataFrame(columns=range(1, len(traffic_cost) + 1), index=range(1, len(traffic_cost) + 1))
205 |
206 | for i in range(len(traffic_cost)):
207 | for j in range(len(traffic_cost)):
208 | sum_list = []
209 | for k in range(len(traffic_cost)):
210 | # print(PA['A1'][k],traffic_cost.iloc[i][k+1])
211 | sum_list.append(pa['A1'][k] * traffic_cost.iloc[k][i + 1])
212 |
213 | # print(sum_list)
214 | # print(PA[1][i],PA[2][j],traffic_cost[i][j + 1],sum(sum_list))
215 |
216 | traffic_distribution.iloc[j][i + 1] = int(pa['P1'][i] * pa["A1"][j] * traffic_cost.iloc[j][i + 1] / sum(
217 | sum_list))
218 | traffic_distribution.insert(0, 'index', range(1, 1 + len(traffic_cost)))
219 |
220 | return traffic_distribution
221 |
222 |
223 | def gravity_model(traffic_cost, PAmatrix):
224 | '''
225 | 重力模型
226 | :param traffic_cost: 路阻函数
227 | :param PAmatrix: 产生吸引矩阵
228 | :return:
229 | '''
230 | # 试算调整gamma值
231 | gamma = 2
232 | # f(cij)函数运算
233 | traffic_cost = traffic_cost[traffic_cost != 0] ** -gamma
234 | traffic_cost = traffic_cost.fillna(0)
235 | traffic_distribution = gravity_calculation(traffic_cost, PAmatrix)
236 | return traffic_distribution
237 |
238 |
239 | def bpr_caculation(t, vc, a=0.15, b=4):
240 | # 基于BPR函数计算加载交通量对路阻影响
241 | t = t * (1 + a * (vc ** b))
242 | return t
243 |
244 |
245 | def assignment(file_name, zonal_name, traffic_cost, distribution_matrix, dir_link_df, link_time,zonal_point_info):
246 | zonal_point_info_pd = pd.Series(zonal_point_info)
247 | n_sf = shapefile.Reader(file_name)
248 | z_sf = shapefile.Reader(zonal_name)
249 | n_sf_records = n_sf.records()
250 | link_df = pd.DataFrame(columns=(
251 | 'A', 'B', 'lw_time', 'c', 'v', 'opposite_v'))
252 | # 设置基础的路径矩阵
253 | for n_sf_record in n_sf_records:
254 | A = n_sf_record[3]
255 | B = n_sf_record[4]
256 | C = n_sf_record[9]
257 | lw_time = (n_sf_record.Length / n_sf_record.Speed * 60 + 0.3 * 3296.3)
258 | link_df = link_df.append(
259 | pd.DataFrame({'A': [A], 'B': [B], 'lw_time': [lw_time], 'v': 0, 'opposite_v': 0, 'c': [C]}))
260 | origin_link_df = copy.deepcopy(link_df)
261 | for start in range(len(traffic_cost)): # 检索每个交通小区的OD,这一步先不做,只做小区1 到小区2的路径
262 | for end in range(1,len(traffic_cost)+1):
263 | for item_a in zonal_point_info_pd[start]:
264 | for item_b in zonal_point_info_pd[end-1]:
265 | number = 0
266 | while number < distribution_matrix.iloc[start, end]: # 以小区2 到小区1 作为示范进行交通量
267 | for j in range(len(dir_link_df[start + 1][end]) - 1):
268 | link_df.loc[((link_df.A == dir_link_df[start + 1][end][j]) & (
269 | link_df.B == dir_link_df[start + 1][end][j + 1])) | ((
270 | link_df.B ==
271 | dir_link_df[start + 1][end][
272 | j]) & (link_df.A ==
273 | dir_link_df[
274 | start + 1][end][
275 | j + 1])), 'v'] += 10
276 | work_link = link_df.loc[((link_df.A == dir_link_df[start + 1][end][j]) & (
277 | link_df.B == dir_link_df[start + 1][end][j + 1])) | ((
278 | link_df.B ==
279 | dir_link_df[start + 1][end][
280 | j]) & (link_df.A ==
281 | dir_link_df[
282 | start + 1][end][
283 | j + 1]))]
284 | print(work_link)
285 | origin_work_link = origin_link_df.loc[((origin_link_df.A == dir_link_df[start + 1][end][j]) & (
286 | origin_link_df.B == dir_link_df[start + 1][end][j + 1])) | ((
287 | origin_link_df.B ==
288 | dir_link_df[start + 1][end][
289 | j]) & (
290 | origin_link_df.A ==
291 | dir_link_df[
292 | start + 1][end][
293 | j + 1]))]
294 | new_lw_time = bpr_caculation(
295 | float(origin_work_link.loc[0]['lw_time']), (float(work_link.loc[0]['v']) / work_link.loc[0]['c']))
296 |
297 | link_df.loc[ # 计算新阻抗
298 | (link_df.A == dir_link_df[start + 1][end][j]) & (
299 | link_df.B == dir_link_df[start + 1][end][j + 1]) | ((
300 | link_df.B ==
301 | dir_link_df[start + 1][end][
302 | j]) & (link_df.A ==
303 | dir_link_df[
304 | start + 1][end][
305 | j + 1])), 'lw_time'] = new_lw_time
306 |
307 | link_time[dir_link_df[start + 1][end][j]][dir_link_df[start + 1][end][j + 1]] = new_lw_time
308 | link_time[dir_link_df[start + 1][end][j + 1]][dir_link_df[start + 1][end][j]] = new_lw_time
309 | newdir_link, new_dir_link_df = zdy_dijkstra(link_time)
310 | number += 10
311 | print(link_df)
312 | # else:
313 | # for j in range(len(dir_link_df[start + 1][end]) - 1):
314 | # link_df.end[((link_df.A == dir_link_df[start + 1][end][j]) & (
315 | # link_df.B == dir_link_df[start + 1][end][j + 1])) | ((
316 | # link_df.B ==
317 | # dir_link_df[start + 1][end][
318 | # j]) & (link_df.A ==
319 | # dir_link_df[
320 | # start + 1][end][
321 | # j + 1])), 'v'] += \
322 | # distribution_matrix.iloc[start, end] + 10 - number
323 | # work_link = link_df.end[((link_df.A == dir_link_df[start + 1][end][j]) & (
324 | # link_df.B == dir_link_df[start + 1][end][j + 1])) | ((
325 | # link_df.B ==
326 | # dir_link_df[start + 1][end][
327 | # j]) & (link_df.A ==
328 | # dir_link_df[
329 | # start + 1][end][
330 | # j + 1]))]
331 | # print(work_link)
332 | # new_lw_time = bpr_caculation(
333 | # float(work_link.end[0]['lw_time']), (float(work_link.end[0]['v']) / work_link.end[0]['c']))
334 | #
335 | # link_df.end[ # 计算新阻抗
336 | # (link_df.A == dir_link_df[start + 1][end][j]) & (
337 | # link_df.B == dir_link_df[start + 1][end][j + 1]), 'lw_time'] = new_lw_time
338 | #
339 | # link_time[dir_link_df[start + 1][end][j]][dir_link_df[start + 1][end][j + 1]] = new_lw_time
340 | # link_time[dir_link_df[start + 1][end][j + 1]][dir_link_df[start + 1][end][j]] = new_lw_time
341 | # newdir_link, new_dir_link_df = zdy_dijkstra(link_time)
342 | print(link_df)
343 | print(new_dir_link_df)
344 |
345 |
346 | def main():
347 | file_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
348 | zonal_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
349 | link_time = read_shp(file_name, 9)
350 | origin_dir_link = copy.deepcopy(link_time)
351 |
352 | road_cost, dir_link_df = zdy_dijkstra(link_time)
353 | zonal_point_info = read_info(file_name, zonal_name)
354 | traffic_cost = zonal_inter_link(road_cost, zonal_point_info)
355 | traffic_cost.to_csv("出行成本.csv", encoding="gbk", index=False)
356 | PAfile_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行生成\\预测PA矩阵.csv'
357 | PAfile_data = pd.read_csv(PAfile_name, low_memory=False) # 防止弹出警告
358 | PAfile_df = pd.DataFrame(PAfile_data)
359 |
360 | distribution_matrix = gravity_model(traffic_cost, PAfile_df)
361 |
362 | assignment_matrix = assignment(file_name, zonal_name, traffic_cost, distribution_matrix, dir_link_df,
363 | origin_dir_link,zonal_point_info)
364 |
365 | # print(distribution_matrix.plot)
366 |
367 | distribution_matrix.to_csv("分布矩阵.csv", encoding="gbk", index=False)
368 | # plt.rcParams['font.sans-serif'] = ['SimHei']
369 | # plt.rcParams['axes.unicode_minus'] = False
370 | # distribution_matrix[1:].plot(kind='bar', stacked=True, title='各小区间分布交通量', edgecolor='black', linewidth=1, alpha=0.8,
371 | # rot=0)
372 | # geopandas用于绘图
373 | # nybb_path = gdf.datasets.get_path('交通小区')
374 |
375 | # # 可视化部分代码
376 | # nybb_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
377 | # n = gdf.GeoDataFrame.from_file(file_name, encoding='gb18030')
378 | # g = gdf.GeoDataFrame.from_file(nybb_path, encoding='gb18030')
379 | # # g['geometry'].convex_hull
380 | # # # g.set_index('BoroCode', inplace=True)
381 | # # # g.sort()
382 | # g['centroid_column'] = g.centroid
383 | # # g.coords[:]
384 | # # print(type(g['centroid_column'][1]))
385 | # # print(g['centroid_column'][1])
386 | # zuobiao = []
387 | #
388 | # for i in range(4):
389 | # zuobiao.append([g['centroid_column'][i].x, g['centroid_column'][i].y])
390 | # # print(zuobiao)
391 | # # plt.plot(zuobiao[1], zuobiao[2], color='r')
392 | # # for i in range(4):
393 | # # for j in range(4):
394 | # # if i != j :
395 | # # plt.plot(zuobiao[i],zuobiao[j], color='r')
396 | # # plt.scatter(zuobiao[i],zuobiao[j], color='b')
397 | # # g.plot()
398 | # t = g.set_geometry('centroid_column')
399 | # # print(t)
400 | # # print(type(g))
401 | # # print(g['centroid_column'])
402 | # # for i in range(4):
403 | # # for j in range(4):
404 | # # if i != j:
405 | # # print(g['centroid_column'][i], g['centroid_column'][j])
406 | # # g.plot(g['centroid_column'][i], g['centroid_column'][j], color='r')
407 | # # 出图部分
408 | # ax1 = g.plot(color='blue')
409 | # ax2 = n.plot(color='black', ax=ax1)
410 | # t.plot(ax=ax2, color='r')
411 | # #
412 | # # # print(g['geometry'])
413 | # plt.show()
414 | # # # print(g)
415 |
416 |
417 | if __name__ == '__main__':
418 | time1 = time.time()
419 | main()
420 | time2 = time.time()
421 | # 输出执行时间
422 | print(f'耗时:{time2 - time1}秒')
423 | # #打开文件
424 | # os.system('分布矩阵.csv')
425 |
--------------------------------------------------------------------------------
/出行分布/distribution.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | '''
3 | 输入:.shp路网文件
4 | pa矩阵
5 | 功能:1.读取路网文件
6 | 2.计算路径时间
7 | 3.检索最短路径
8 | 问题:重力模型里gamma值没有修正,只做了单约束没做双约束导致PA不平衡
9 |
10 | '''
11 |
12 | import numpy as np
13 | import pandas as pd
14 | import dbfread as dbf
15 | import csv
16 | import shapefile
17 | import matplotlib.pyplot as plt
18 | import geopandas as gdf
19 | import math
20 | import time
21 | import copy
22 | import os
23 |
24 |
25 | def read_shp(file_name, point_number,
26 | vot=[4230.8, 3296.3, 3661.525, 3854.55, 3527.65, 4953.2, 4393.55, 5257.7, 5534.025, 6173.825]):
27 | '''
28 | 读取路网文件,并设置dijkstra法基础矩阵
29 | :param file_name:文件路径
30 | 缺省vot方便用户自己选择是否输入
31 | :return:将原始存在直接路径的路阻进行赋值
32 | '''
33 | sf = shapefile.Reader(file_name, encoding='gbk')
34 |
35 | df = pd.DataFrame(columns=(
36 | 'A', 'B', 'lw_time', 'C', 'V'))
37 | sf_records = sf.records()
38 |
39 | i = 1
40 | self_list = [0]
41 | for i in range(1, 1 + point_number):
42 | self_list.append(i * (point_number + 1))
43 | arr = np.arange(point_number ** 2)
44 |
45 | for i in range(point_number ** 2):
46 | arr[i] = 999999
47 | if i in self_list:
48 | arr[i] = 0
49 | dir_link = pd.DataFrame(arr.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
50 | index=(range(1, 1 + point_number)))
51 |
52 | for sf_record in sf_records:
53 | lw_time = (sf_record.Length / sf_record.Speed * 60 + 0.3 * vot[1])
54 |
55 | A = sf_record[3]
56 | B = sf_record[4]
57 | C = sf_record[9]
58 | dir_link[B][A] = lw_time
59 | dir_link[A][B] = lw_time
60 | df = df.append(pd.DataFrame({'A': [A], 'B': [B], 'lw_time': [lw_time], 'V': 0, 'C': [C]}))
61 | sf.close()
62 | return dir_link
63 |
64 |
65 | def zdy_dijkstra(dir_link):
66 | '''
67 | dijkstra最短路径搜索
68 | :param dir_link:
69 | :return:各节点间最短路径路阻确定
70 | '''
71 | road_list = []
72 | point_number = len(dir_link)
73 | origin_dir_link = copy.deepcopy(dir_link)
74 | work_dir_link = copy.deepcopy(dir_link)
75 | for start in range(1, point_number + 1): # 定义起始节点
76 | for end in range(1, point_number + 1): # 定义目标节点
77 | link_list = []
78 | link_list.append(start)
79 | zdy_list = [] # 清空最短路径列表
80 | for k in range(1, point_number + 1):
81 | zdy_list.append(work_dir_link[start][k] + work_dir_link[k][end]) # 检索前节点到目标节点最短路
82 |
83 | if min(zdy_list) < work_dir_link[start][end]:
84 | work_dir_link[start][end] = min(zdy_list) # 计算最短路与目标值对比
85 | work_dir_link[end][start] = work_dir_link[start][end] # 矩阵对称同步
86 | link_list.append(zdy_list.index(min(zdy_list)) + 1)
87 | link_list.append(end)
88 | road_list.append(link_list)
89 |
90 | # 得到最短路径的路径list
91 | for l_list in road_list:
92 | for i in range(len(l_list) - 1):
93 | if origin_dir_link[l_list[i]][l_list[i + 1]] == 999999:
94 | l_list.insert(i + 1, road_list[(l_list[i] - 1) * point_number + l_list[i + 1] - 1][1])
95 | # 将路径list进行整列成为矩阵
96 | array = np.array(road_list).T
97 | # print(array)
98 | df = pd.DataFrame(array.reshape((point_number, point_number)), columns=range(1, 1 + point_number),
99 | index=(range(1, 1 + point_number)))
100 | for i in range(1, point_number + 1):
101 | for j in range(i, point_number + 1):
102 | df[i][j] = list(reversed(df[j][i]))
103 | return work_dir_link, df
104 |
105 |
106 | def read_info(file_name, zonal_name):
107 | # 读取路网文件
108 | sf = shapefile.Reader(file_name)
109 | shapes = sf.shapes()
110 | fields = sf.fields
111 | records = sf.records()
112 | fields_name = []
113 | # 将路网信息从dbf转换为矩阵
114 | for field in fields:
115 | fields_name.append(field[0])
116 | del fields_name[0]
117 | table = []
118 | for record in records:
119 | table.append(record[:])
120 | net_info = pd.DataFrame(table, columns=fields_name)
121 |
122 | # 将点坐标与点建立对应矩阵
123 | point_dict = {}
124 | for i in range(len(shapes)):
125 | # for j in range(len(shapes[i].points)):
126 | point_dict[net_info['A'][i]] = shapes[i].points[0]
127 | point_dict[net_info['B'][i]] = shapes[i].points[1]
128 | point_info = pd.DataFrame(list(point_dict.items()), columns=['点', '坐标'])
129 | point_info.to_csv("点坐标信息.csv", encoding="gbk", index=False)
130 |
131 | # 读取小区数据
132 | zonal_sf = shapefile.Reader(zonal_name)
133 | zonal_shapes = zonal_sf.shapes()
134 | zonal_fields = zonal_sf.fields
135 | zonal_records = zonal_sf.records()
136 |
137 | # 小区周边邻接矩阵点读入
138 | zonal_point_info = {}
139 |
140 | for i in range(len(zonal_shapes)):
141 | zonal_point_list = []
142 | for j in range(point_info.shape[0]):
143 | if point_info['坐标'][j] in zonal_shapes[i].points:
144 | zonal_point_list.append(j)
145 | zonal_point_info['{}'.format(i)] = zonal_point_list
146 | return zonal_point_info
147 |
148 |
149 | def zonal_inter_link(road_cost, zonal_point_info):
150 | # 计算区内出行时间:小区周边道路出行最短行程时间/2
151 | zonal_inter_cost = {}
152 | i = 1
153 | for value in zonal_point_info.values():
154 |
155 | inter_cost = []
156 |
157 | for origin in value:
158 | for end in value:
159 | if end != origin:
160 | inter_cost.append(road_cost[origin + 1][end + 1])
161 |
162 | zonal_inter_cost[i] = min(inter_cost) / 2
163 | i += 1
164 |
165 | zonal_inter_cost_pd = pd.Series(zonal_inter_cost)
166 |
167 | zonal_dir_link_cost = pd.DataFrame(columns=range(1, len(zonal_point_info) + 1),
168 | index=range(1, len(zonal_point_info) + 1))
169 |
170 | zonal_point_info_pd = pd.Series(zonal_point_info)
171 |
172 | for i in range(len(zonal_point_info)):
173 | for j in range(len(zonal_point_info)):
174 | if i == j:
175 | zonal_dir_link_cost[i + 1][j + 1] = 0
176 | else:
177 | # 清空小区周边路网路阻列表
178 | zonal_cost = []
179 | # 拾取小区周边节点并进行基于对应节点进行阻抗计算
180 | for item_a in zonal_point_info_pd[i]:
181 | for item_b in zonal_point_info_pd[j]:
182 | if item_a == item_b:
183 | continue
184 | zonal_cost.append(road_cost[item_a + 1][item_b + 1])
185 |
186 | zonal_dir_link_cost[i + 1][j + 1] = min(zonal_cost)
187 |
188 | # 将计算所得小区区内出行时间加到路径出行时间上
189 | for i in range(1, 1 + len(zonal_point_info)):
190 | # print(zonal_inter_cost_pd[i])
191 | zonal_dir_link_cost[i] += zonal_inter_cost_pd[i]
192 | zonal_dir_link_cost[i][i] -= zonal_inter_cost_pd[i]
193 | return zonal_dir_link_cost
194 |
195 |
196 | def gravity_calculation(traffic_cost, pa):
197 | '''
198 | 计算各小区间交通量
199 | :param traffic_cost: 成本矩阵
200 | :param pa: PA矩阵
201 | :return:
202 | '''
203 | traffic_distribution = pd.DataFrame(columns=range(1, len(traffic_cost) + 1), index=range(1, len(traffic_cost) + 1))
204 |
205 | for i in range(len(traffic_cost)):
206 | for j in range(len(traffic_cost)):
207 | sum_list = []
208 | for k in range(len(traffic_cost)):
209 | # print(PA['A1'][k],traffic_cost.iloc[i][k+1])
210 | sum_list.append(pa['A1'][k] * traffic_cost.iloc[k][i + 1])
211 |
212 | # print(sum_list)
213 | # print(PA[1][i],PA[2][j],traffic_cost[i][j + 1],sum(sum_list))
214 |
215 | traffic_distribution.iloc[j][i + 1] = int(pa['P1'][i] * pa["A1"][j] * traffic_cost.iloc[j][i + 1] / sum(
216 | sum_list))
217 | traffic_distribution.insert(0, 'index', range(1, 1 + len(traffic_cost)))
218 |
219 | return traffic_distribution
220 |
221 |
222 | def gravity_model(traffic_cost, PAmatrix):
223 | '''
224 | 重力模型
225 | :param traffic_cost: 路阻函数
226 | :param PAmatrix: 产生吸引矩阵
227 | :return:
228 | '''
229 | # 试算调整gamma值
230 | gamma = 2
231 | # f(cij)函数运算
232 | traffic_cost = traffic_cost[traffic_cost != 0] ** -gamma
233 | traffic_cost = traffic_cost.fillna(0)
234 | traffic_distribution = gravity_calculation(traffic_cost, PAmatrix)
235 | return traffic_distribution
236 |
237 |
238 | def bpr_caculation(t, vc, a=0.15, b=4):
239 | # 基于BPR函数计算加载交通量对路阻影响
240 | t = t * (1 + a * (vc ** b))
241 | return t
242 |
243 |
244 | def assignment(file_name, zonal_name, road_cost, distribution_matrix, dir_link_df, link_time, zonal_point_info):
245 |
246 | zonal_point_info_pd = pd.Series(zonal_point_info)
247 | n_sf = shapefile.Reader(file_name)
248 | z_sf = shapefile.Reader(zonal_name)
249 | n_sf_records = n_sf.records()
250 | link_df = pd.DataFrame(columns=(
251 | 'A', 'B', 'lw_time', 'c', 'v', 'opposite_v'))
252 | # 设置基础的路径矩阵
253 | for n_sf_record in n_sf_records:
254 | A = n_sf_record[3]
255 | B = n_sf_record[4]
256 | C = n_sf_record[9]
257 | lw_time = (n_sf_record.Length / n_sf_record.Speed * 60 + 0.3 * 3296.3)
258 | link_df = link_df.append(
259 | pd.DataFrame({'A': [A], 'B': [B], 'lw_time': [lw_time], 'v': 0, 'opposite_v': 0, 'c': [C]}))
260 | origin_link_df = copy.deepcopy(link_df)
261 | for col in range(0, len(zonal_point_info)): # 检索每个交通小区的OD,这一步先不做,只做小区1 到小区2的路径
262 | for loc in range(1, len(zonal_point_info) + 1):
263 | number = 0
264 | if col + 1 != loc:#起终点小区不一致
265 | zonal_cost = {}
266 | # 拾取小区周边节点并进行基于对应节点进行阻抗计算
267 | for item_a in zonal_point_info_pd[col]:
268 | for item_b in zonal_point_info_pd[loc-1]:
269 | if item_a == item_b:
270 | continue
271 | zonal_cost[(item_a+1,item_b+1)]=road_cost[item_a + 1][item_b + 1]
272 | print(zonal_cost)
273 | zonal_min_dir = min(zonal_cost, key=zonal_cost.get)
274 | print(dir_link_df)
275 | print(dir_link_df[zonal_min_dir[0]][zonal_min_dir[1]])
276 |
277 | # while number < distribution_matrix.iloc[col, loc]: # 以小区2 到小区1 作为示范进行交通量
278 | # for j in range(len(dir_link_df[col + 1][loc]) - 1):
279 | # link_df.loc[((link_df.A == dir_link_df[col + 1][loc][j]) & (
280 | # link_df.B == dir_link_df[col + 1][loc][j + 1])) | ((
281 | # link_df.B ==
282 | # dir_link_df[col + 1][loc][
283 | # j]) & (link_df.A ==
284 | # dir_link_df[
285 | # col + 1][loc][
286 | # j + 1])), 'v'] += 10
287 | # work_link = link_df.loc[((link_df.A == dir_link_df[col + 1][loc][j]) & (
288 | # link_df.B == dir_link_df[col + 1][loc][j + 1])) | ((
289 | # link_df.B ==
290 | # dir_link_df[col + 1][loc][
291 | # j]) & (link_df.A ==
292 | # dir_link_df[
293 | # col + 1][loc][
294 | # j + 1]))]
295 | #
296 | # origin_work_link = origin_link_df.loc[((origin_link_df.A == dir_link_df[col + 1][loc][j]) & (
297 | # origin_link_df.B == dir_link_df[col + 1][loc][j + 1])) | ((
298 | # origin_link_df.B ==
299 | # dir_link_df[col + 1][
300 | # loc][
301 | # j]) & (
302 | # origin_link_df.A ==
303 | # dir_link_df[
304 | # col + 1][loc][
305 | # j + 1]))]
306 | # new_lw_time = bpr_caculation(
307 | # float(origin_work_link.loc[0]['lw_time']),
308 | # (float(work_link.loc[0]['v']) / work_link.loc[0]['c']))
309 | #
310 | # link_df.loc[ # 计算新阻抗
311 | # (link_df.A == dir_link_df[col + 1][loc][j]) & (
312 | # link_df.B == dir_link_df[col + 1][loc][j + 1]) | ((
313 | # link_df.B ==
314 | # dir_link_df[col + 1][loc][
315 | # j]) & (link_df.A ==
316 | # dir_link_df[
317 | # col + 1][
318 | # loc][
319 | # j + 1])), 'lw_time'] = new_lw_time
320 | #
321 | # link_time[dir_link_df[col + 1][loc][j]][dir_link_df[col + 1][loc][j + 1]] = new_lw_time
322 | # link_time[dir_link_df[col + 1][loc][j + 1]][dir_link_df[col + 1][loc][j]] = new_lw_time
323 | # newdir_link, new_dir_link_df = zdy_dijkstra(link_time)
324 | # number += 10
325 | # print(link_df)
326 | # else:
327 | # for j in range(len(dir_link_df[col + 1][loc]) - 1):
328 | # link_df.loc[((link_df.A == dir_link_df[col + 1][loc][j]) & (
329 | # link_df.B == dir_link_df[col + 1][loc][j + 1])) | ((
330 | # link_df.B ==
331 | # dir_link_df[col + 1][loc][
332 | # j]) & (link_df.A ==
333 | # dir_link_df[
334 | # col + 1][loc][
335 | # j + 1])), 'v'] += \
336 | # distribution_matrix.iloc[col, loc] + 10 - number
337 | # work_link = link_df.loc[((link_df.A == dir_link_df[col + 1][loc][j]) & (
338 | # link_df.B == dir_link_df[col + 1][loc][j + 1])) | ((
339 | # link_df.B ==
340 | # dir_link_df[col + 1][loc][
341 | # j]) & (link_df.A ==
342 | # dir_link_df[
343 | # col + 1][loc][
344 | # j + 1]))]
345 | # print(work_link)
346 | # new_lw_time = bpr_caculation(
347 | # float(work_link.loc[0]['lw_time']), (float(work_link.loc[0]['v']) / work_link.loc[0]['c']))
348 | #
349 | # link_df.loc[ # 计算新阻抗
350 | # (link_df.A == dir_link_df[col + 1][loc][j]) & (
351 | # link_df.B == dir_link_df[col + 1][loc][j + 1]), 'lw_time'] = new_lw_time
352 | #
353 | # link_time[dir_link_df[col + 1][loc][j]][dir_link_df[col + 1][loc][j + 1]] = new_lw_time
354 | # link_time[dir_link_df[col + 1][loc][j + 1]][dir_link_df[col + 1][loc][j]] = new_lw_time
355 | # newdir_link, new_dir_link_df = zdy_dijkstra(link_time)
356 |
357 |
358 |
359 |
360 | def main():
361 | file_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\路网.dbf'
362 | zonal_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
363 | link_time = read_shp(file_name, 9)
364 | origin_dir_link = copy.deepcopy(link_time)
365 |
366 | road_cost, dir_link_df = zdy_dijkstra(link_time)
367 | zonal_point_info = read_info(file_name, zonal_name)
368 | traffic_cost = zonal_inter_link(road_cost, zonal_point_info)
369 | traffic_cost.to_csv("出行成本.csv", encoding="gbk", index=False)
370 | PAfile_name = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行生成\\预测PA矩阵.csv'
371 | PAfile_data = pd.read_csv(PAfile_name, low_memory=False) # 防止弹出警告
372 | PAfile_df = pd.DataFrame(PAfile_data)
373 |
374 | distribution_matrix = gravity_model(traffic_cost, PAfile_df)
375 |
376 | assignment_matrix = assignment(file_name, zonal_name, road_cost, distribution_matrix, dir_link_df,
377 | origin_dir_link, zonal_point_info)
378 |
379 | # print(distribution_matrix.plot)
380 |
381 | distribution_matrix.to_csv("分布矩阵.csv", encoding="gbk", index=False)
382 | # plt.rcParams['font.sans-serif'] = ['SimHei']
383 | # plt.rcParams['axes.unicode_minus'] = False
384 | # distribution_matrix[1:].plot(kind='bar', stacked=True, title='各小区间分布交通量', edgecolor='black', linewidth=1, alpha=0.8,
385 | # rot=0)
386 | # geopandas用于绘图
387 | # nybb_path = gdf.datasets.get_path('交通小区')
388 |
389 | # # 可视化部分代码
390 | # nybb_path = 'C:\\Users\\Administrator\\Desktop\\python_work\\毕业设计\\出行分布\\示范路网小区\\交通小区.dbf'
391 | # n = gdf.GeoDataFrame.from_file(file_name, encoding='gb18030')
392 | # g = gdf.GeoDataFrame.from_file(nybb_path, encoding='gb18030')
393 | # # g['geometry'].convex_hull
394 | # # # g.set_index('BoroCode', inplace=True)
395 | # # # g.sort()
396 | # g['centroid_column'] = g.centroid
397 | # # g.coords[:]
398 | # # print(type(g['centroid_column'][1]))
399 | # # print(g['centroid_column'][1])
400 | # zuobiao = []
401 | #
402 | # for i in range(4):
403 | # zuobiao.append([g['centroid_column'][i].x, g['centroid_column'][i].y])
404 | # # print(zuobiao)
405 | # # plt.plot(zuobiao[1], zuobiao[2], color='r')
406 | # # for i in range(4):
407 | # # for j in range(4):
408 | # # if i != j :
409 | # # plt.plot(zuobiao[i],zuobiao[j], color='r')
410 | # # plt.scatter(zuobiao[i],zuobiao[j], color='b')
411 | # # g.plot()
412 | # t = g.set_geometry('centroid_column')
413 | # # print(t)
414 | # # print(type(g))
415 | # # print(g['centroid_column'])
416 | # # for i in range(4):
417 | # # for j in range(4):
418 | # # if i != j:
419 | # # print(g['centroid_column'][i], g['centroid_column'][j])
420 | # # g.plot(g['centroid_column'][i], g['centroid_column'][j], color='r')
421 | # # 出图部分
422 | # ax1 = g.plot(color='blue')
423 | # ax2 = n.plot(color='black', ax=ax1)
424 | # t.plot(ax=ax2, color='r')
425 | # #
426 | # # # print(g['geometry'])
427 | # plt.show()
428 | # # # print(g)
429 |
430 |
431 | if __name__ == '__main__':
432 | time1 = time.time()
433 | main()
434 | time2 = time.time()
435 | # 输出执行时间
436 | print(f'耗时:{time2 - time1}秒')
437 | # #打开文件
438 | # os.system('分布矩阵.csv')
439 |
--------------------------------------------------------------------------------