污水管网图形计算工具
sewergraph的Python项目详细描述
下水道图
v0.1.2
在networkx的基础上,这个包提供了分析和操作的工具 污水管网数据。
目标
提供图形函数以解决下水道中典型的分析问题 收集系统:
- 向上/向下穿过污水管网
- 累积计算
- 下游瓶颈分析
- 数据缺口处理(在合理范围内,伙计们)
- 设计能力分析
安装
受osmnx启发,Sewergraph依赖于Networkx和Pandas。对于大多数用例,安装很容易:
$ pip install sewergraph
提供了使用GeoPandas的附加功能, 苗条又有型。建议先用conda安装geopandas,然后再安装 通过PIP的污水图:
$ conda install geopandas $ pip install sewergraph
如果安装了arcmap,请确保geopandas安装不与arcpy
冲突。为避免风险,请在conda
环境中安装SewerGraph:
$ conda create --name myenv
$ activate myenv #enter the new environment
$ conda install geopandas
$ pip install sewergraph
示例
创建具有下水道网络形状文件的NetworkX有向图。
importsewergraphassg#read shapefile into DiGraphshapefile_path=r'path/to/sewers.shp'G=sg.graph_from_shp(shapefile_path)
每个污水管段的属性存储为边缘数据。几何学被解析并存储在^ {CD3}}属性中,以及在SeaFEFLE中存在的任何其他字段。
#sewer connecting node 0 to node 1print(G[0][1])
{'OBJECTID': 115081, 'STREET': 'ADAINVILLE DR', 'ShpName': 'sample_sewer_network_1', 'diameter': 8, 'facilityid': 'BCE7B25E', 'geometry': <shapely.geometry.linestring.LineString at 0x12a6caf0>, 'height': 0, 'length': 164.758, 'local_area': 39449.474, 'material': 'VCP', 'pipeshape': 'CIR', 'slope': 0.01, 'width': 0}
通过从网络的顶部到底部(即污水棚)累积local_area
,计算每个下水道的总排水面积。
#accumulate drainage areaG=sg.accumulate_downstream(G,'local_area','total_area')#convert to GeoDataFrame and sort the sewers by total_areasewers=sg.gdf_from_graph(G)sewers=sewers.sort_values(by='total_area',ascending=False)sewers.head()
total_area | OBJECTID | facilityid | pipeshape | diameter | height | width | length | slope | material | STREET | local_area | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
19 | 4,233,504 | 112545 | A58064DF | BOX | 0 | 12 | 16 | 327.279370 | 0.0075 | RCP | None | 119043.524941 | LINESTRING (6558821.45028765 2032961.24586616,... |
18 | 4,114,461 | 112546 | 5890D18F | BOX | 0 | 12 | 16 | 318.081402 | 0.0100 | RCP | None | 171961.403740 | LINESTRING (6558826.08945222 2032643.19829701,... |
24 | 3,942,499 | 112563 | 12FF7372 | BOX | 0 | 12 | 16 | 131.352534 | 0.0100 | RCP | None | 16557.605522 | LINESTRING (6558821.78250872 2032511.9163921, ... |
提供了更多的功能,用于计算基本水力容量、排水口负荷、分流、行程时间,以及从网络的每个点识别下游收缩。
#perform basic sewer capacity calculations (full flow Mannings capacity)G=hhcalcs_on_network(G)#id flow split sewers and calculate split fractionsG=analyze_flow_splits(G)#accumulating travel timesG=accumulate_travel_time(G)
运行测试
测试位于sewergraph>;tests目录中,并使用pytest
运行。