swmmio.graphics package

Submodules

swmmio.graphics.drawing module

swmmio.graphics.drawing.annotate_details(txt, draw)[source]
swmmio.graphics.drawing.annotate_streets(df, img, text_col)[source]
swmmio.graphics.drawing.annotate_timestamp(draw)[source]
swmmio.graphics.drawing.annotate_title(title, draw)[source]
swmmio.graphics.drawing.conduit_draw_color(conduit)[source]

return the draw color of a conduit

swmmio.graphics.drawing.conduit_draw_size(conduit)[source]

return the draw size of a conduit

swmmio.graphics.drawing.draw_conduit(conduit, draw)[source]
swmmio.graphics.drawing.draw_node(node, draw)[source]

draw a node to the given PIL ImageDraw object

swmmio.graphics.drawing.draw_parcel_risk(parcel, draw)[source]
swmmio.graphics.drawing.draw_parcel_risk_delta(parcel, draw)[source]
swmmio.graphics.drawing.gradient_color_red(x, xmin, xmax, startCol=235, 235, 225)[source]
swmmio.graphics.drawing.gradient_grey_red(x, xmin, xmax)[source]
swmmio.graphics.drawing.line_size(q, exp=1)[source]
swmmio.graphics.drawing.node_draw_color(node)[source]

given a row of a nodes() dataframe, return the color it should be drawn

swmmio.graphics.drawing.node_draw_size(node)[source]

given a row of a nodes() dataframe, return the size it should be drawn

swmmio.graphics.drawing.parcel_draw_color(parcel, style='risk')[source]

swmmio.graphics.swmm_graphics module

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

export model as a geojson object

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.

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.

model -> swmmio.Model object

nodes -> Pandas Dataframe (optional, if model not provided)

conduits -> Pandas Dataframe (optional, if model not provided)

parcels - > Pandas Dataframe (optional)

title -> string, to be written in top left of PNG

annotation -> string, to be written in bottom left of PNG

file_path -> stirng, file path where png should be drawn. if not specified,

a PIL Image object is return (nice for IPython notebooks)

bbox -> tuple of coordinates representing 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 e.g. bbox = ((2691647, 221073), (2702592, 227171))

Note: this hasn’t been tested with anything other than PA StatePlane coords

px_width -> float, width of image in pixels

swmmio.graphics.utils module

swmmio.graphics.utils.angle_bw_points(xy1, xy2)[source]
swmmio.graphics.utils.circle_bbox(coordinates, radius=5)[source]

the bounding box of a circle given as centriod coordinate and radius

swmmio.graphics.utils.clip_to_box(df, bbox)[source]

clip a dataframe with a coords column to a bounding box

swmmio.graphics.utils.length_bw_coords(upstreamXY, downstreamXY)[source]
swmmio.graphics.utils.midpoint(xy1, xy2)[source]
swmmio.graphics.utils.point_in_box(bbox, point)[source]

check if a point falls with in a bounding box, bbox

swmmio.graphics.utils.px_to_irl_coords(df, px_width=4096.0, bbox=None, shift_ratio=None)[source]

given a dataframe with element id (as index) and X1, Y1 columns (and optionally X2, Y2 columns), return a dataframe with the coords as pixel locations based on the targetImgW.

swmmio.graphics.utils.rotate_coord_about_point(xy, radians, origin=0, 0)[source]

Rotate a point around a given origin https://gist.github.com/LyleScott/e36e08bfb23b1f87af68c9051f985302

swmmio.graphics.utils.save_image(img, img_path, antialias=True, auto_open=False)[source]

Module contents