swmm_graphics#

swmmio.graphics.swmm_graphics.create_map(model=None, filename=None, basemap=None, auto_open=False)[source]#

Export model as a geojson object and create an HTML map.

Parameters:
modelobject, optional

The model object to be exported. Must have a valid CRS (Coordinate Reference System).

filenamestr, optional

The filename for the output HTML file. If None, a temporary file will be created.

basemapstr, optional

The path to the basemap file. If None, a default basemap path will be used.

auto_openbool, optional

If True, the generated HTML file will be automatically opened in a web browser.

Returns:
str

The content of the generated HTML file if filename is None, otherwise returns an empty string.

Raises:
ValueError

If the model object does not have a valid CRS.

Notes

The function reads a basemap file and inserts geojson data of the model’s links and nodes into it. It also sets the map’s center and bounding box based on the model’s coordinates.

swmmio.graphics.swmm_graphics.draw_model(model=None, nodes=None, conduits=None, parcels=None, title=None, annotation=None, file_path=None, bbox=None, px_width=2048.0)[source]#

Create a PNG rendering of the model and model results.

Parameters:
modelswmmio.Model, optional

A swmmio.Model object.

nodespandas.DataFrame, optional

DataFrame for the nodes of a model. Required if model is not provided.

conduitspandas.DataFrame, optional

DataFrame for the conduits of a model. Required if model is not provided.

parcelspandas.DataFrame, optional

DataFrame containing parcel data.

titlestr, optional

String to be written in the top left of the PNG.

annotationstr, optional

String to be written in the bottom left of the PNG.

file_pathstr, optional

File path where PNG should be saved. If not specified, a PIL Image object is returned.

bboxtuple of tuple of float, optional

Coordinates representing the bottom left and top right corner of a bounding box. The rendering will be clipped to this box. If not provided, the rendering will clip tightly to the model extents. Example: ((2691647, 221073), (2702592, 227171)).

px_widthfloat, optional

Width of the image in pixels. Default is 2048.0.

Returns:
PIL.Image.Image

The rendered image.

Notes

A swmmio.Model object can be passed in independently, or Pandas Dataframes for the nodes and conduits of a model may be passed in. A dataframe containing parcel data can optionally be passed in.