swmmio.graphics package#
Submodules#
swmmio.graphics.drawing module#
- swmmio.graphics.drawing.draw_node(node, draw)[source]#
draw a node to the given PIL ImageDraw object
- swmmio.graphics.drawing.node_draw_color(node)[source]#
given a row of a nodes() dataframe, return the color it should be drawn
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.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.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