WaterNetworkGIS#

module wntr.gis.network

class WaterNetworkGIS[source]#

Bases: object

Water network GIS class

Contains methods to create GeoDataFrames from WaterNetworkModel and create WaterNetworkModel from GeoDataFrames.

Parameters:

gis_data (dict, optional) – Dictionary of GeoDataFrames containing data to populate an instance of WaterNetworkGIS. Valid dictionary keys are ‘junction’, ‘tanks’, ‘reservoirs’, ‘pipes’, ‘pumps’, and ‘valves’

Raises:

ModuleNotFoundError – if missing either shapely or geopandas


__init__(gis_data=None)[source]#

Add attribute to pipes, pumps, or valves GeoDataFrames

Parameters:
  • values (dict or Series or row of a DataFrame) – Attribute values

  • name (str) – Attribute name

add_node_attributes(values, name)[source]#

Add attribute to junctions, tanks, or reservoirs GeoDataFrames

Parameters:
  • values (dict or Series or row of a DataFrame) – Attribute values

  • name (str) – Attribute name

read_geojson(files, index_col='index')[source]#

Append information from GeoJSON files to a WaterNetworkGIS object

Parameters:
  • files (dictionary) – Dictionary of GeoJSON filenames, where the keys are in the set (‘junction’, ‘tanks’, ‘reservoirs’, ‘pipes’, ‘pumps’, ‘valves’) and values are the corresponding GeoJSON filename

  • index_col (str, optional) – Column that contains the element name

read_shapefile(files, index_col='index')[source]#

Append information from Esri Shapefiles to a WaterNetworkGIS object

Parameters:
  • files (dictionary) – Dictionary of Shapefile directory or filenames, where the keys are in the set (‘junction’, ‘tanks’, ‘reservoirs’, ‘pipes’, ‘pumps’, ‘valves’) and values are the corresponding GeoJSON filename

  • index_col (str, optional) – Column that contains the element name

set_crs(crs, allow_override=False)[source]#

Set CRS of the junctions, tanks, reservoirs, pipes, pumps, and valves GeoDataFrames.

Calls geopandas.GeoDataFrame.set_crs on each GeoDataFrame.

Parameters:
  • crs (str) – Coordinate reference system

  • allow_override (bool (optional)) – Allow override of existing coordinate reference system

to_crs(crs)[source]#

Transform CRS of the junctions, tanks, reservoirs, pipes, pumps, and valves GeoDataFrames.

Calls geopandas.GeoDataFrame.to_crs on each GeoDataFrame.

Parameters:

crs (str) – Coordinate reference system

write_geojson(prefix)[source]#

Write the WaterNetworkGIS object to a set of GeoJSON files, one file for each network element.

Parameters:

prefix (str) – File prefix

write_shapefile(prefix)[source]#

Write the WaterNetworkGIS object to a set of Esri Shapefiles, one directory for each network element.

Parameters:

prefix (str) – File and directory prefix