Skip to main content

Tools for graph calculations on sewer networks

Project description



Build status Build Status

Building upon Networkx, this package provides tools for analysis and manipulation of sewer network data.


Provide graph functions to tackle analytical problems typical in sewer collections systems:

  • traverse sewer networks up/downstream
  • accumulation calculations
  • downstream choke-point analysis
  • data gap handling (within reason, folks)
  • design capacity analysis


Inspired by osmnx, sewergraph depends on Networkx and Pandas. For most use cases, installation is easy:

$ pip install sewergraph

Additional functionality is provided that makes use of GeoPandas, scipy and Shapely. It's recommended to install GeoPandas with conda first, then install sewergraph via pip:

$ conda install geopandas
$ pip install sewergraph

If you have ArcMap installed, be sure that the GeoPandas installation doesn't conflict with arcpy. To avoid risks, install sewergraph in a conda environment:

$ conda create --name myenv
$ activate myenv #enter the new environment
$ conda install geopandas
$ pip install sewergraph


Create a Networkx DiGraph with a shapefile of a sewer network.

import sewergraph as sg

#read shapefile into DiGraph
shapefile_path = r'path/to/sewers.shp'
G = sg.graph_from_shp(shapefile_path)

Attributes of each sewer segment are stored as edge data. Geometry is parse and stored in the geometry attribute along with whatever other fields exist in the shapefile.

#sewer connecting node 0 to node 1
  'OBJECTID': 115081,
  '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

Calculate the total drainage area at each sewer by accumulating local_area from the top to bottom of the network (i.e. sewershed).

#accumulate drainage area
G = sg.accumulate_downstream(G, 'local_area', 'total_area')

#convert to GeoDataFrame and sort the sewers by total_area
sewers = sg.gdf_from_graph(G)
sewers = sewers.sort_values(by = 'total_area', ascending=False)
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, ...

More functions are provided for calculating basic hydraulic capacity, outfall loading, flow splits, travel time, and identifying downstream constrictions from every point of the network.

#perform basic sewer capacity calculations (full flow Mannings capacity)
G = hhcalcs_on_network(G)

#id flow split sewers and calculate split fractions
G = analyze_flow_splits(G)

#accumulating travel times
G = accumulate_travel_time(G)

Running Tests

Test are located in the sewergraph > tests directory and are run with pytest.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sewergraph-0.1.4-py3-none-any.whl (29.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page