SlideShare a Scribd company logo
5
Most read
6
Most read
7
Most read
Automating HEC-RAS with Excel
Virginia Lakes and Watersheds Conference, March 2015
Thomas Williams, PE
Amec Foster Wheeler
+ = ?
Contents
1. What is HEC-RAS? (brief intro)
2. The HECRASController API
3. Excel VBA Demos
1. Multi-Model Run
2. RAS Output Extraction
3. Manning’s ‘n’ Calibration (sort of)
4. Tips
5. Conclusion
2
1. What is HEC-RAS?
3
Hydrologic
Engineering
Centers
River
Analysis
System
“HEC-RAS allows you to
perform one-dimensional
steady flow, unsteady flow,
sediment transport/mobile
bed computations, and water
temperature modeling.”
- USACE
What is an API?
API = Application Programmer Interface
“In computer programming, an application programmer interface (API) is
a set of routines, protocols, and tools for building software
applications. An API expresses a software component in terms of its
operations, inputs, outputs, and underlying types.”
- Wikipedia
2. The HECRASController API
4
Their Program
Your
Program API
2. The HECRASController API (cont’d)
The HECRASController API
“The current version of the HECRASController has a wealth of
procedures that will allow a programmer to manipulate HEC-RAS
externally by setting input data, retrieving input or output data, and
performing common [HEC-RAS] functions…”
- Christopher Goodell, PE, D.WRE, Breaking the HEC-RAS Code, 2014
5
HEC-RAS
Excel
API
2. The HECRASController API (cont’d)
Accessing the API from Microsoft Excel
1. Click the Visual Basic button (on the Developer tab)
2. Create a new VBA module
3. Go to Tools > References, check “HEC River Analysis System”,
and click OK.
4. Write code!
6
2. The HECRASController API (cont’d)
A simple program…
7
Sub RunHECRAS()
' Opens and runs a HEC-RAS model
' Declare variables
Dim ras As New HECRASController
Dim nmsg As Long
Dim strMessages() As String
Dim prjFilePath As String
' Open the model
prjFilePath = "C:MyHecRasModel.prj"
ras.Project_Open (prjFilePath)
' Run the model
ras.Compute_CurrentPlan nmsg, strMessages
End Sub
2. The HECRASController API (cont’d)
Some example HECRASController
fuctions and subroutines:
• Project_Open
Opens a HEC-RAS model.
• Compute_CurrentPlan
Runs the current flow/geometry
regime.
• ExportGIS
Exports an *.sdf file that can be
read into ArcGIS using HEC-
GeoRAS.
• Output_NodeOutput
Returns an output value for a
given node and profile.
8
• Geometry_SetMann
Sets the Manning’s ‘n’ values for
a cross section, horizontally
varied.
• Add_BC
Adds a bridge/culvert.
• Edit_BC
Opens the Bridge/Culvert Editor
and displays the selected station.
• PlotPF
Displays the water surface profile
for a given River/Reach.
3. Excel VBA Demos
9
1. Multi-Model Run
2. RAS Output Extraction
3. Manning’s ‘n’ Calibration (sort of)
Cross your fingers!
4. Tips
• Breaking the HEC-RAS Code
by Christopher Goodell, PE, D.WRE
• The API is a little rough around the edges.
• Provides a lot of functionality, but not everything
• Inconsistencies:
• Parameter names and types
• Function / subroutine behavior
• No “official” API documentation
• HEC-RAS is public domain software, but not open source
• HEC-RAS project (*.prj), geometry (*.g##), flow (*.f##), and plan
(*.p##) files are plain text.
• Sometimes that’s easier than using the API.
• HEC-RAS output files (*.O##) are binary. 
10
5. Conclusion
1. The HECRASController API is really useful…
2. …but it takes a little work to figure out.
3. Happy coding!
Questions?
Contact Info
Thomas Williams, PE
Amec Foster Wheeler
thomas.williams@amecfw.com
11

More Related Content

PDF
Breaking the hec code
PPTX
HEC-RAS tutorial on single bridge
PDF
Hec ras tutorial-flume_example
PDF
Q922+re2+l06 v1
PPTX
Hec ras flood modeling little river newburyport
PDF
Using HEC-RAS to assess flash floods risk in arid regions
PPT
CHAPTER_4C-Water-Hammer.ppt
PPTX
Embankment lecture 1
Breaking the hec code
HEC-RAS tutorial on single bridge
Hec ras tutorial-flume_example
Q922+re2+l06 v1
Hec ras flood modeling little river newburyport
Using HEC-RAS to assess flash floods risk in arid regions
CHAPTER_4C-Water-Hammer.ppt
Embankment lecture 1

What's hot (20)

PDF
Chapter 4 embankment dams
PPTX
Concrete dam lecture 1
PDF
8 slope stability
PPTX
Dam outlet works lecture 2
PDF
Sediment Transport
PPTX
PQC concrete road
PDF
Q922+re2+l07 v1
PDF
Unit3 hbn
PPTX
DAM ENGINEERING I.pptx
PPTX
Dam outlet works lecture 1
PDF
PDF
Geotechnical Engineering-I [Lec #27A: Flow Calculation From Flow Nets]
PPTX
Canal design
PPTX
Unit hydrograph by anwar
PDF
Design of Hydraulic Structures
PDF
design of weirs
PDF
Presentacion proyecto HEC-HMS
PPTX
Hyetograph and hydrograph analysis
DOC
Dam engineering i 4
PDF
Metodo directo para el transito de avenidas en embalses
Chapter 4 embankment dams
Concrete dam lecture 1
8 slope stability
Dam outlet works lecture 2
Sediment Transport
PQC concrete road
Q922+re2+l07 v1
Unit3 hbn
DAM ENGINEERING I.pptx
Dam outlet works lecture 1
Geotechnical Engineering-I [Lec #27A: Flow Calculation From Flow Nets]
Canal design
Unit hydrograph by anwar
Design of Hydraulic Structures
design of weirs
Presentacion proyecto HEC-HMS
Hyetograph and hydrograph analysis
Dam engineering i 4
Metodo directo para el transito de avenidas en embalses
Ad

Viewers also liked (20)

PPTX
Hec ras
PPSX
Flood Mapping via HEC-RAS Model and ArcGIS
PDF
Ctn 762-guide hec-ras-h2009
PPTX
ASFPM 2016: Applications of 2D Surface flow Modeling in the New HEC-RAS Versi...
DOCX
seminar report of " Introduction to HEC RAS "
PDF
Minitutorial Hec-Ras
PDF
5 c 1-hec-georas_part1
PDF
Hec ras 4.1-applications_guide[1]
PDF
Aras tutorial
PDF
Ekons HecRas Model_01
PPT
Odisha sw wb mission-may14
PDF
Download-manuals-surface water-software-estimationofdischargebyarea-slopemethod
PDF
Network and mandates of wq monitoring
PDF
Download-manuals-surface water-manual-illustrations-hydrologicalobservations
PDF
Hp wq study of ground water quality characteristics in industrially predomina...
PDF
Download-manuals-surface water-software-investigation&selectionofhydrologica...
DOCX
Readers guide sw his documents v2
PDF
Download-manuals-surface water-software-introductiontoadvanceddischargemeasu...
PDF
Final wq handbook 180514
PPTX
Upstream Suburban Philadelphia Sub-Watershed Cluster Modeling Overview
Hec ras
Flood Mapping via HEC-RAS Model and ArcGIS
Ctn 762-guide hec-ras-h2009
ASFPM 2016: Applications of 2D Surface flow Modeling in the New HEC-RAS Versi...
seminar report of " Introduction to HEC RAS "
Minitutorial Hec-Ras
5 c 1-hec-georas_part1
Hec ras 4.1-applications_guide[1]
Aras tutorial
Ekons HecRas Model_01
Odisha sw wb mission-may14
Download-manuals-surface water-software-estimationofdischargebyarea-slopemethod
Network and mandates of wq monitoring
Download-manuals-surface water-manual-illustrations-hydrologicalobservations
Hp wq study of ground water quality characteristics in industrially predomina...
Download-manuals-surface water-software-investigation&selectionofhydrologica...
Readers guide sw his documents v2
Download-manuals-surface water-software-introductiontoadvanceddischargemeasu...
Final wq handbook 180514
Upstream Suburban Philadelphia Sub-Watershed Cluster Modeling Overview
Ad

Similar to Automating HEC-RAS with Excel (20)

PDF
water-10-01382-v2 (2).pdf
PDF
water-10-01382-v2 (2).pdf
PPTX
Lecture 1.pptx
PDF
Curso de Hecras aplicado a Inundaciones
DOCX
hec-ras_modeling_handout_15391166852036076181.v8.docx
PDF
HEC-RAS 5.0.4 HECRAS para principiantes
PDF
HEC-RAS 5.0.4 Inundaciones Puyo
PPT
2011 ras for_managers_11-22
PPTX
HEC-RAS software for design and modeling
PPTX
Seminar on Hydrological modelling
PDF
HEC-RAS 5.0.5 Release Notes
PDF
HYDRAULIC MODELING AND FLOOD.pdf
PDF
Hec geo ras-43_users_manual
PDF
APPLICATION OF 1-D HEC-RAS MODEL IN DESIGN OF CHANNELS
PDF
SponchiadoDavide_Pubblication
PDF
Georastutorial
PDF
Determination of safe grade elevation by using hec ras case study mutha river
PDF
Determination of safe grade elevation by using hec ras case study mutha river
PDF
HEC-GEORASTutorials.PDF
PDF
DEM GENERATION AND RIVER ANALYSIS USING HEC-RAS MODEL, HARIDWAR DISTRICT, UTT...
water-10-01382-v2 (2).pdf
water-10-01382-v2 (2).pdf
Lecture 1.pptx
Curso de Hecras aplicado a Inundaciones
hec-ras_modeling_handout_15391166852036076181.v8.docx
HEC-RAS 5.0.4 HECRAS para principiantes
HEC-RAS 5.0.4 Inundaciones Puyo
2011 ras for_managers_11-22
HEC-RAS software for design and modeling
Seminar on Hydrological modelling
HEC-RAS 5.0.5 Release Notes
HYDRAULIC MODELING AND FLOOD.pdf
Hec geo ras-43_users_manual
APPLICATION OF 1-D HEC-RAS MODEL IN DESIGN OF CHANNELS
SponchiadoDavide_Pubblication
Georastutorial
Determination of safe grade elevation by using hec ras case study mutha river
Determination of safe grade elevation by using hec ras case study mutha river
HEC-GEORASTutorials.PDF
DEM GENERATION AND RIVER ANALYSIS USING HEC-RAS MODEL, HARIDWAR DISTRICT, UTT...

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PDF
PPT on Performance Review to get promotions
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
composite construction of structures.pdf
PPTX
additive manufacturing of ss316l using mig welding
PPTX
OOP with Java - Java Introduction (Basics)
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Well-logging-methods_new................
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Current and future trends in Computer Vision.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
Digital Logic Computer Design lecture notes
PPT on Performance Review to get promotions
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mechanical Engineering MATERIALS Selection
composite construction of structures.pdf
additive manufacturing of ss316l using mig welding
OOP with Java - Java Introduction (Basics)
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Well-logging-methods_new................
Internet of Things (IOT) - A guide to understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Operating System & Kernel Study Guide-1 - converted.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Current and future trends in Computer Vision.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf

Automating HEC-RAS with Excel

  • 1. Automating HEC-RAS with Excel Virginia Lakes and Watersheds Conference, March 2015 Thomas Williams, PE Amec Foster Wheeler + = ?
  • 2. Contents 1. What is HEC-RAS? (brief intro) 2. The HECRASController API 3. Excel VBA Demos 1. Multi-Model Run 2. RAS Output Extraction 3. Manning’s ‘n’ Calibration (sort of) 4. Tips 5. Conclusion 2
  • 3. 1. What is HEC-RAS? 3 Hydrologic Engineering Centers River Analysis System “HEC-RAS allows you to perform one-dimensional steady flow, unsteady flow, sediment transport/mobile bed computations, and water temperature modeling.” - USACE
  • 4. What is an API? API = Application Programmer Interface “In computer programming, an application programmer interface (API) is a set of routines, protocols, and tools for building software applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types.” - Wikipedia 2. The HECRASController API 4 Their Program Your Program API
  • 5. 2. The HECRASController API (cont’d) The HECRASController API “The current version of the HECRASController has a wealth of procedures that will allow a programmer to manipulate HEC-RAS externally by setting input data, retrieving input or output data, and performing common [HEC-RAS] functions…” - Christopher Goodell, PE, D.WRE, Breaking the HEC-RAS Code, 2014 5 HEC-RAS Excel API
  • 6. 2. The HECRASController API (cont’d) Accessing the API from Microsoft Excel 1. Click the Visual Basic button (on the Developer tab) 2. Create a new VBA module 3. Go to Tools > References, check “HEC River Analysis System”, and click OK. 4. Write code! 6
  • 7. 2. The HECRASController API (cont’d) A simple program… 7 Sub RunHECRAS() ' Opens and runs a HEC-RAS model ' Declare variables Dim ras As New HECRASController Dim nmsg As Long Dim strMessages() As String Dim prjFilePath As String ' Open the model prjFilePath = "C:MyHecRasModel.prj" ras.Project_Open (prjFilePath) ' Run the model ras.Compute_CurrentPlan nmsg, strMessages End Sub
  • 8. 2. The HECRASController API (cont’d) Some example HECRASController fuctions and subroutines: • Project_Open Opens a HEC-RAS model. • Compute_CurrentPlan Runs the current flow/geometry regime. • ExportGIS Exports an *.sdf file that can be read into ArcGIS using HEC- GeoRAS. • Output_NodeOutput Returns an output value for a given node and profile. 8 • Geometry_SetMann Sets the Manning’s ‘n’ values for a cross section, horizontally varied. • Add_BC Adds a bridge/culvert. • Edit_BC Opens the Bridge/Culvert Editor and displays the selected station. • PlotPF Displays the water surface profile for a given River/Reach.
  • 9. 3. Excel VBA Demos 9 1. Multi-Model Run 2. RAS Output Extraction 3. Manning’s ‘n’ Calibration (sort of) Cross your fingers!
  • 10. 4. Tips • Breaking the HEC-RAS Code by Christopher Goodell, PE, D.WRE • The API is a little rough around the edges. • Provides a lot of functionality, but not everything • Inconsistencies: • Parameter names and types • Function / subroutine behavior • No “official” API documentation • HEC-RAS is public domain software, but not open source • HEC-RAS project (*.prj), geometry (*.g##), flow (*.f##), and plan (*.p##) files are plain text. • Sometimes that’s easier than using the API. • HEC-RAS output files (*.O##) are binary.  10
  • 11. 5. Conclusion 1. The HECRASController API is really useful… 2. …but it takes a little work to figure out. 3. Happy coding! Questions? Contact Info Thomas Williams, PE Amec Foster Wheeler thomas.williams@amecfw.com 11