wntr.gis.network module

The wntr.gis.network module contains methods to convert between water network models and GIS formatted data

class wntr.gis.network.WaterNetworkGIS(gis_data=None)[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

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

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

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

Add attribute to pipes, pumps, or valves 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

write_geojson(prefix: str)[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: str)[source]

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

Parameters

prefix (str) – File and directory prefix