Back to blog
TutorialOctober 17, 20266 min read

Shapefile to SWMM: Build a Model from GIS or CAD Data

Can EPA SWMM import a shapefile or DXF directly?

No. EPA SWMM 5.2 has no GIS or CAD import. It can export its map as DXF and show a backdrop image, but cannot read pipes or manholes from either. The SWMM 5.2 user manual suggests that for larger systems you collect data from CAD drawings or GIS files and transfer it into an input file in the format of its Appendix D. Every route from GIS or CAD to SWMM ends in that .inp text file.

Which .inp sections does a pipe network need?

A pipe network needs six sections, with these formats from Appendix D:

SectionFormatHolds
[JUNCTIONS]Name Elev (Ymax Y0 Ysur Apond)Manhole invert and depth to ground
[OUTFALLS]Name Elev FREE (Gated) (RouteTo)Discharge points; NORMAL, FIXED, TIDAL or TIMESERIES replace FREE
[CONDUITS]Name Node1 Node2 Length N Z1 Z2 (Q0 Qmax)Pipe ends, length, Manning n, end offsets
[XSECTIONS]Link Shape Geom1 Geom2 Geom3 Geom4 (Barrels Culvert)Shape; for CIRCULAR, Geom1 is the diameter
[COORDINATES]Node Xcoord YcoordNode positions
[VERTICES]Link Xcoord YcoordPipe bends, from inlet to outlet

The flow units set in [OPTIONS] fix every other unit: CFS, GPM or MGD mean feet, while CMS, LPS or MLD mean metres, so a 300 mm pipe in an LPS model has a Geom1 of 0.3. The file holds no coordinate system. [MAP] carries only the extent and a unit of FEET, METERS, DEGREES or NONE, so record your projection elsewhere.

What attributes do you need from the GIS or CAD data?

You need an ID, a position and levels for every manhole, and an ID, two end nodes, a size and a roughness for every pipe:

  • Manholes: unique ID, X and Y in a projected system, ground level, and invert level or depth. A type field helps you mark outfalls.
  • Pipes: unique ID, upstream and downstream node (or line ends that meet the manholes), length, diameter, material or Manning n, and both end inverts.

SWMM reads each line as items separated by spaces and treats a semicolon as the start of a comment, so an ID with a space or a semicolon in it breaks the line. Names are not case sensitive, so SWMM treats MH1 and mh1 as the same name. CAD drawings usually hold IDs and levels as text labels, which must each be matched to the nearest manhole or pipe.

How do pipe inverts become SWMM elevations and offsets?

The node's elevation is the lowest invert in the manhole, and every pipe end above it becomes an offset. With LINK_OFFSETS set to DEPTH, the default, Z1 and Z2 are heights above the node invert; with ELEVATION they are absolute levels. A pipe entering a manhole 0.4 m above the outgoing pipe gets a Z2 of 0.4 under DEPTH.

SWMM does not stop on a wrong offset. An offset below the node invert is set to zero with WARNING 03, which moves the pipe end. For Ymax, use ground level minus the invert. If Ymax is 0, SWMM sets the maximum depth to the top of the highest connecting pipe, and if Ymax is below a pipe crown, SWMM raises it with WARNING 02. Either way the node floods at the pipe crown, not at ground level.

Missing inverts are the usual gap in GIS layers. Fill them by a rule you can defend, such as a uniform gradient between surveyed levels, and list each filled value.

How do you check connectivity before exporting?

Check that every line end touches a manhole, that pipes point downhill, and that each outfall has one pipe. The common faults:

  • Ends that miss. A line stopping a few centimetres short of a manhole is not connected. Snap ends within a tolerance, and look for lines that end partway along another without a vertex there.
  • Digitising direction. Node1 must be the upstream node, so compare inverts or ground levels and reverse lines drawn uphill.
  • Duplicates and orphans. Two copies of one pipe, or manholes with no pipe.
  • Shared outfalls. SWMM allows one link at an outfall. Where two sewers meet at the discharge point, keep it as a junction and add a short pipe to a separate outfall.

Under steady or kinematic wave routing SWMM also rejects adverse slopes, loops and junctions with two outlet pipes. Dynamic wave accepts these but needs at least one outfall.

What errors does SWMM report on a converted file?

These errors, with meanings from Appendix E of the manual, mostly trace back to the attribute table or the line work:

  • ERROR 203 too few items on a line, for example an empty attribute.
  • ERROR 207 duplicate ID name.
  • ERROR 209 undefined object, such as a conduit naming a node that was never written.
  • ERROR 211 invalid number, such as NULL or a comma decimal in a level field.
  • ERROR 111 invalid length, usually a zero-length line.
  • ERROR 112 elevation drop exceeds length; check the length and both end levels, for example levels in feet against lengths in metres.
  • ERROR 141 an outfall with more than one inlet link or an outlet link.
  • ERROR 145 no outfall under dynamic wave routing.

A file that runs is not yet a checked model. Read the warnings in the status report, then compare results with measured flows as in how to calibrate an EPA SWMM model.

Which tools write the .inp file for you?

Several tools convert GIS layers to an .inp file, each with its own expected layout:

  • Generate SWMM inp, a QGIS plugin by Jannik Schilling, writes input files from QGIS layers and reads .inp and report files back.
  • The TUFLOW plugin for QGIS has a GeoPackage - Write to SWMM inp tool, for a GeoPackage prepared with its own GeoPackage - Create and Add Sections tools.
  • swmmr (R) has shp_to_inp, which needs shapefile columns named in SWMM's terms or cut to seven characters.
  • swmm-api (Python) has gpkg_to_swmm, which reads a GeoPackage laid out the way its write_geo_package function writes one.

How does DrainPilot build a SWMM model from a survey?

DrainPilot reads the source, joins the network and writes the .inp for you. Its Survey Import window (File > Import Survey...) takes manhole and pipe schedules as Excel or CSV; a DXF drawing with sewer polylines, manhole blocks, points or circles, and text labels such as MH-12, GL 101.25, IL 99.80 and 200 mm; or a GeoJSON file or zipped shapefile with sewer lines, manhole points and their attributes.

After you confirm which column, layer or attribute is which, DrainPilot snaps line ends within your snap tolerance, turns drawn sewers to run from the higher to the lower level, and, if inference is on, fills blank inverts. Surveyed values are never changed, and every filled value appears in the inference report. An outfall taking more than one sewer stays a junction and drains through a 1 m stub to a new outfall. With only a manhole schedule, it joins manholes by nearest lower invert, nearest lower ground or row order. The new project uses LPS and dynamic wave routing. Files are read in the browser and never uploaded.

What does DrainPilot not do on import?

DrainPilot's import has these limits:

  • It does not read GeoPackage, file geodatabase or DWG files; export to GeoJSON, a zipped shapefile or DXF first.
  • It imports pipes and manholes only, with no subcatchments, rainfall or inflows. Add those afterwards, for example a design storm.
  • It writes circular pipes and free outfalls only.
  • It works in metres and millimetres, and does not convert levels in feet or diameters in inches.
  • For GIS layers it joins pipes where their ends meet, not by from and to attributes.
  • It projects longitude and latitude only to Web Mercator or UTM zones 42N to 46N, and reads a zipped shapefile that has a .prj file as longitude and latitude. Elsewhere, save the layers as GeoJSON in a projected system in metres, which it reads as they are.
  • Its minimum slopes for filled inverts and its Manning n by material come from India's CPHEEO sewerage manual. Check them against your own standard.

DrainPilot runs EPA SWMM 5.2.4 in the browser at geopilotai.com/drainpilot. The import and export docs page lists every field in the Survey Import window and how models, results and DXF drawings are exported.

Share

Jagadeesh Gaddam

CEO, Smart Bhujal

Try this in GeoPilot

Run the analysis described in this article with one prompt. No setup required.

Open GeoPilot

Related posts