Automating HEC-RAS!

Written by Chris Goodell | October 28, 2014


Are you an HEC-RAS user?  Yes?  OK, try this out:

1.  If you haven’t already done so, install the HEC-RAS example projects to the default location.

image
image

2.  Open up a blank workbook in Excel.

3.  Press Alt-F11.  When the Visual Basic Editor Window opens up, select Tools…References…

4.  Scroll down until you see HEC River Analysis System.  If you see more than one “HEC River Analysis System”, that means you have more than one version of HEC-RAS installed on your computer.  That’s okay, just select the one for the version of HEC-RAS you want to use.  Check the box and click OK.

image

5.  Click Insert…Module.  Then in the module editor that pops up type (or copy and paste) the following code.  In the line that starts with strRASProject = “C:Users…, make sure to use your User Name, not cgoodell.  The directory path should match where you’ve installed the HEC-RAS example projects.  Also, only include the last line, HRC.QuitRAS, if you are using HEC-RAS Version 5.0 or higher.  If you are using Version 4.1 or lower, omit this line of code.

Sub RunRAS()
    ‘Instantiate a new HECRASController Class
Dim HRC As New HECRASController

    ‘Open a new project.   
    Dim strRASProject As String
strRASProject = “C:UserscgoodellDocumentsHEC DataHEC-RASSteady ExamplesBEAVCREK.prj”
HRC.Project_Open strRASProject

    ‘Run the HEC-RAS Project
Dim lngMessages As Long
Dim strMessages() As String
HRC.Compute_CurrentPlan lngMessages, strMessages()

    ‘Get water surface elevations at Node 5
Dim sngWSElev As Single
sngWSElev = HRC.Output_NodeOutput(1, 1, 5, 0, 1, 2)
MsgBox “The water surface elevation is ” & sngWSElev & “.”

    ‘Close HEC-RAS.  The following line is only needed for HEC-RAS Version 5.0.
HRC.QuitRas

End Sub

6.  Click Run…Run Sub/UserForm, or just press F5, and watch what happens.  If you get the following error message (or similar), make sure you typed in the HEC-RAS project path and filename correctly and that you actually do have a project located there.  Remember to replace “cgoodell” with your computer User name in the strRASProject definition in the code.

image

If you see HEC-RAS compute and then get the following message, then congratulations…it worked!

image

There.  You’ve just run your first HECRASController application!  Let me know in the Comments below if it worked for you.  There is so much more you can do with the HECRASController.  Automation of HEC-RAS projects, specific output data retrieval, batch mode simulations, real time modeling, Monte Carlo simulations, to name a few.  As you’ve just found out, if you have HEC-RAS, you already have the HECRASController.

You can learn more about using the HECRASController in my new book, “Breaking the HEC-RAS Code.”  Get your copy today!
.
image

Comments

  1. Anonymous

    on October 28, 2014

    This is great. Are there libraries to run in .NET as well or only vba?

  2. Chris Goodell

    on October 28, 2014

    Yes, you can do this in .NET also. I just like to demonstrate it in VBA, since most everyone has Excel. Thanks.

  3. Bhavin Gandhi

    on October 29, 2014

    Chris, this is great..
    Looking forward to see the book in few weeks.

  4. Chris Goodell

    on October 29, 2014

    Thanks! I'll keep you posted.

  5. Colin M

    on October 30, 2014

    Worked for me as well. Thanks Chris. Looking forward to the book.

  6. Anonymous

    on November 1, 2014

    Can I perform these using R-programming or Python….

  7. Chris Goodell

    on November 21, 2014

    I think so. Give it a try and let me know if it works.

  8. Joshua Steele

    on January 15, 2015

    Did this ever work for you Anonymous? I'm considering trying both just for the heck of it but I don't want to if you've already found out it can't work…

  9. Chris Goodell

    on January 15, 2015

    Joshua-I've had some users email me about their attempts at using R for the RASController with some success. If you send me your email address, I can forward it on and maybe you can collaborate directly? Just a thought.

  10. Joshua Steele

    on February 18, 2015

    Hi Chris, sorry for the late reply. My email is joshua/.cal/eb.ste/ele@/gmail.com (remove the slashes), feel free to forward me onto whoever.

    I'm having almost no trouble getting it working in Excel, but I want to be better versed in R than I am too so it couldn't hurt.

  11. Martin

    on July 28, 2015

    Hi Chris,
    being in a need to autmate HEC-RAS launching I tested your example and it worked well for me – so well that ordered the book. However being in a hurry, let me please ask a question:
    – do you have any Java API/library for the HEC-RAS Controller ?
    – are there any hints in the book how to launch HEC-RAS and collect the results without Excel ?

    Thanks in advance

    Martin

  12. Chris Goodell

    on July 28, 2015

    Martin-Thanks for getting the book! To answer your questions, the API should work with Java, as long as your Java programming platform can reference the HECRASController. But, I have not tried that. If you get it to work, please let me know. Although the book is written around using the HECRASController in VBA (Excel), it does discuss briefly how to get it set up in Visual Studio. I imagine the procedure is similar in other platforms.

    Good luck. Let me know how it goes!
    Chris

  13. Martin

    on August 13, 2015

    Hi Chris,
    I am using the Excel to run my project (1 river, 1 reach, 35 river stations for 24 hours – 13AUG2015 0000 – 14AUG2015 0000).

    However I cannot get the stage output values for the respective hours of simulation:

    – the attempt to get the data from DSS file by the call:
    HRC.OutputDSS_GetStageFlow rivers(1), reaches(1), strRS(6), nValue, dateTimes(), stage(), flow(), errmsg

    results in nValue=25, correct dateTimes however with error message:
    No records were found (the data returned all -902's)
    No records were found (the data returned all -902's)

    However when I run the project in HEC-RAS GUI, I can see in the DSSFile the records with the data:
    /MORAVA DOLNY TOK//LOCATION-FLOW//13AUG2015 0000/FALOSNA/

    /MORAVA DOLNY TOK//LOCATION-FLOW//13AUG2015 2400/FALOSNA/
    and I can see stage data for all 35 RS for any particular time chosen.

    The calsl like Ouput_NodeOutput are probably of no use since I cannot get the data for all times, just the final value, or am I missing something ?

    Thanks in advance.

    Martin

  14. Chris Goodell

    on August 13, 2015

    please post your code here so I can see what is going on.

  15. Martin

    on October 23, 2015

    Hi Chris,
    I am still trying to automate the HEC-RAS – we need to run it on Windows machine from Linux one via ssh.
    I have the VBS script alunching an Excel file as well as Excel makro doing the HEC-RAS calculations.
    The problem is, that when I run the VBS script by command
    cscript C:IMSbinmodelsrunHECRAS.vbs c:IMSbinmodelsproject2.xls d:Sharesdata-model02HEC_RAS_Morava
    from Windows Power Shell locally, I can see starting Excel as background process in Task Manager, HEC-RAS starts either as Background process or as App as I can see in Task Manager (anyway very strange behaviour), I can see the HEC-RAS Window open, calculations are performed and everything works as it should.

    When I run the command over ssh:
    ssh [email protected].2 cscript "c:\IMS\bin\models\runHECRAS.vbs" "c:\IMS\bin\models\project2.xls" "D:\Shares\data-model02\HEC_RAS_Morava"
    the command starts, I can see starting Excel as background process in Task Manager, HEC-RAS starts as Background process but gets stuck.
    Logs from the Excel makro show, that the call which gets stuck is:

    Dim HRC As New HECRASController

    The macro stops and must be terminated manually, no error can be obtained.

    This may be a sort of security issue – the FreeSshd however runs as service under Local System Account and is allowed to interact with desktop.
    I wonder, if you have any sort of hint how to enable starting HEC-RAS from system service (I found in the book none).
    Any help would be appreciated.

    Martin

  16. Chris Goodell

    on October 23, 2015

    Martin- That is some advanced stuff. I really don't know anything about ssh and I'm afraid I don't know what is going on with your situation. I will forward this on to someone I know that may be able to help and I'll let you know if I get anything useful for you.
    Chris

  17. Martin

    on October 27, 2015

    Chris,
    just more information: running VBS script via ssh / cscript with starting of Excel but without access to HECRASController works well – the Excel starts, the macro produces expected output to log files, Excel finishes.
    The real problem is in HECRASController.
    Is there any debug mode in HEC-RAS which can be activated by me to see when and where it gets stuck ?
    Because being stuck, I cannot access even any Error from VBA in Excel.

    Martin

  18. Chris Goodell

    on October 27, 2015

    Unfortunately Martin, there is no debug mode for the HECRASController. I'm still waiting to hear back from HEC on your issue. Hopefully they'll have a useful workaround.

    Chris

  19. Martin

    on January 27, 2016

    Chris,
    I found the workaround by wrapping cscript command to Windows scheduled task and launching schtasks command via ssh. It worked automatically until some changes in User accounts on Windows have been introduced.

    Now I am facing very strange problem:
    – when launching the HEC-RAS via Excel directly using cscript command, everything is OK and the HEC-RAS produces output files including project.dss:
    ———-+ 1 matog None 32000 2016-01-27 14:24 project.IC.O01
    ———-+ 1 matog None 384000 2016-01-27 14:24 project.O01
    ———-+ 1 matog None 3348 2016-01-27 14:24 project.b01
    ———-+ 1 matog None 2840 2016-01-27 14:24 project.bco01
    ———-+ 1 matog None 27916 2016-01-27 14:24 project.c01
    ———-+ 1 matog None 558592 2016-01-27 14:24 project.dss
    ———-+ 1 matog None 258915 2016-01-27 14:24 project.g01.hdf
    ———-+ 1 matog None 208 2016-01-27 14:24 project.p01.blf
    ———-+ 1 matog None 344203 2016-01-27 14:24 project.p01.hdf
    ———-+ 1 matog None 60190 2016-01-27 14:24 project.r01
    ———-+ 1 matog None 43292 2016-01-27 14:24 project.x01

    In addition, the command HRC.Compute_CurrentPlan lngMessages, strMessages() produces following strMessages:
    Starting Unsteady Computations
    Computing
    Computations Completed

    – however when I launch the HEC-RAS via schtasks command, Excel/HEC-RAS get launched, even the command HRC.Compute_CurrentPlan lngMessages, strMessages() produces the same correct strMessages:
    Starting Unsteady Computations
    Computing
    Computations Completed
    but the model outputs are incomplete, the project.dss is missing:
    ———-+ 1 matog None 3348 2016-01-27 14:46 project.b01
    ———-+ 1 matog None 98748 2016-01-27 14:46 project.g01.hdf
    ———-+ 1 matog None 98748 2016-01-27 14:46 project.g01.tmp.hdf
    ———-+ 1 matog None 9976 2016-01-27 14:46 project.p01.hdf
    ———-+ 1 matog None 43292 2016-01-27 14:46 project.x01

    Do you have any idea where the HEC-RAS may crash after producing correct messages on HRC.Compute_CurrentPlan output but before writing output data ?

    Thanks in advance

    Martin

  20. Chris Goodell

    on January 27, 2016

    Did you make sure to set all cross sections to produce stage and flow output? From the unsteady flow analysis window, Options…stage and flow output locations.

  21. Martin

    on January 28, 2016

    Chris,
    thank you very much for your quick response. The problem has been solved – due to the security reasons / OS hardening the model did not write .dss file (and some other files) when running from scheduled task. So my problem is solved.

    However it might be worth to change the return value of the call "HRC.Compute_CurrentPlan lngMessages, strMessages()" because in both cases (success, failure) the output was:
    Starting Unsteady Computations
    Computing
    Computations Completed

    which was true, however there was no indication that the writing of the output data failed.
    Reporting of the output writing failure would help me (and maybe someone else in future) in integration/automation.

    Best regards

    Martin

  22. Logan Ashall

    on February 1, 2016

    Hi Chris/Martin

    I am sorry to hijack your conversation, but I am also have the same sort of problems Martin is having… But unlike Martin I am sticking purely within the VBA zone using the HECRASController to try to output stages/flows for a user specified Ri/Re/Node.

    My code runs but it only outputs the same first plan/dss file output for each plan i want to output. I have tried to set different dss files for each plan, and even creating different projects for each plan. But the function "RC.OutputDSS_GetStageFlow" will keep outputing the same output…

    Is there a way to manually set the different DSS pathnames so that I may run the "RC.OutputDSS_GetStageFlow" inside a for loop to output multiple plans? or maybe you can tell me if I am missing something in my code which I will paste in a reply to this comment.

  23. Logan Ashall

    on February 1, 2016

    Sub EXAMPLECODE()
    'Open an HEC-RAS Project
    Dim RC As New RAS500.HECRASController
    OpenRASProjectByRef RC '***Update: removed the "z" before OpenRASProjectByRef
    'Run the Project so there's output to retrieve
    Dim blnDidItWork As Boolean
    Dim blnDidItCompute As Boolean
    Dim lngMsg As Long, strMsg() As String
    'Compute
    'blnDidItWork = RC.Compute_CurrentPlan(lngMsg, strMsg())
    'Get a list of the plans
    Dim blnIncludeBasePlansOnly As Boolean
    Dim lngPlanCount As Long, strPlanNames As String
    blnIncludeBasePlansOnly = True
    'RC.Plan_Names lngPlanCount, strPlanNames(), _
    blnIncludeBasePlansOnly
    'Declare looping ints
    Dim i As Long, j As Long, k As Long, l As Long, m As Long, n As Long, p As Long
    Dim length As Integer, timesteps As Integer
    p = 0
    'Select plan
    Sheets("RASProjects").Select
    Cells.Select
    Range("B6").Select
    lngPlanCount = ActiveCell.Value
    'start loop for plans
    For m = 1 To lngPlanCount
    Sheets("RASProjects").Select
    Cells.Select
    Range("B7").Select
    ActiveCell.Offset(m, 0).Activate
    strPlanNames = ActiveCell.Value
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = "COMPLETE"
    'Set the current output plan to next iteration
    Dim blnSetIt As Boolean, blnOutputFile As Boolean
    Dim strPlanErrMsg As String
    'blnOutputFile = RC.PlanOutput_IsCurrent(strPlanNames, True, strPlanErrMsg)
    blnSetIt = RC.PlanOutput_SetCurrent(strPlanNames)
    Sheets("RASProjects").Select
    Cells.Select
    Range("M2").Select
    length = ActiveCell.Value
    ActiveCell.Offset(0, 2).Activate
    timesteps = ActiveCell.Value
    'Populate a RAS Geometry Type using the GetRiverReachesNodes Function
    Dim typRASGeometry As TypeRASGeom
    blnDidItWork = GetRiversReachesNodes(typRASGeometry, RC)
    'Write results to the excel sheet
    Sheets.Add
    ActiveSheet.Name = strPlanNames
    Sheets(strPlanNames).Select
    Cells.Select
    Selection.ClearContents
    Range("A1").Select
    'Rivers
    For n = 1 To length
    'get first row of selected river/reach/node ids
    Sheets("RASProjects").Select
    Cells.Select
    Range("N3").Select
    ActiveCell.Offset(n, 0).Activate
    i = ActiveCell.Value
    ActiveCell.Offset(0, 2).Activate
    j = ActiveCell.Value
    ActiveCell.Offset(0, 2).Activate
    k = ActiveCell.Value
    Application.StatusBar = "Working " & "on River " & i & ", Reach " & j & ", RS " & _
    Trim(typRASGeometry.Riv(i).Rch(j).Node(k).RiverStation) & "for plan" & m & " ."
    'Go back to output current sheet
    Sheets(strPlanNames).Select
    Cells.Select
    Range("A2").Select
    'Reaches
    With typRASGeometry.Riv(i)
    'write each river/reach
    ActiveCell.Offset(0, (n – 1) * 3).Activate: ActiveCell.Value = _
    .RivName
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    .Rch(j).RchName

    BREAK (cont'd next reply)

  24. Logan Ashall

    on February 1, 2016

    (2/2 Cont'd from above comment)

    'Nodes
    With .Rch(j)
    'write each node/RS
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    .Node(k).RiverStation
    'Write column headers
    ActiveCell.Offset(2, -2).Activate: ActiveCell.Value = _
    "Time"
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    "Stage (ft)"
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    "Flow (cfs)"
    ActiveCell.Offset(0, -2).Activate
    'Declare names of each river, reach and node for each iteration
    Dim strRiver As String, strReach As String, strRS As String
    strRiver = RC.Geometry.RiverName(i)
    strReach = RC.Geometry.ReachName(i, j)
    strRS = RC.Geometry.NodeRS(i, j, k)
    'Retrieve the output from the dss file
    Dim lngNumValue As Long, dblDateTime() As Double, _
    sngStage() As Single, sngFlow() As Single, _
    strErrMsg As String
    blnDidItCompute = RC.OutputDSS_GetStageFlow(strRiver, _
    strReach, strRS, lngNumValue, dblDateTime(), _
    sngStage(), sngFlow(), strErrMsg)
    'Write time/stage/flow
    For l = 1 To lngNumValue
    ActiveCell.Offset(1, 0).Activate: ActiveCell.Value = _
    dblDateTime(l) 'make sure to set this column number format to "time"
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    Round(CStr(sngStage(l + p)), 2)
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    Round(CStr(sngFlow(l)), 0)
    ActiveCell.Offset(0, -2).Activate
    Next l
    End With
    End With
    Next n
    Next m
    'Close HEC-RAS
    RC.QuitRAS
    End Sub

  25. Chris Goodell

    on February 1, 2016

    Logan-

    NOt sure if this is what is causing the problem or not, but the strPlanNames() is an array of plan names and requires an index number when using it to set the current plan. So, when you set it in the command RC.PlanOutput_SetCurrent(), the argument should be an indexed form of strPlanNames(), like strPlanNames(1). Also, I noticed that some important pieces of your code are commented out with an '. I'm guessing that you did that while trying to debug, but thought I'd mention it just in case. Hope this helps.
    Chris

  26. Logan Ashall

    on February 1, 2016

    Thanks for the fast reply Chris, I will try this now! Will respond in a couple hours.

    And oops sorry about the commented lines, I lose track sometimes of what version I am working on :P.

    Cheers,

  27. Logan Ashall

    on February 1, 2016

    Chris,

    You were right, I assumed from the start I could just pass the function a string, but it turns out it has to have that index number. So instead of grabbing strings from the excel spreadsheet, I am now using the plan_names function to extract all plans in the project.

    Thanks,
    logan

  28. Chris Goodell

    on February 1, 2016

    Great! Hope it works.

  29. Nayyar Minhaj Asif

    on April 24, 2016

    Hello Chris

    I recently purchased your book and i found it really helpful in automating HEC ras for my modeling problem.

    So far, i have no issues because the book is very well explained. Just a very small query, there is no QUITRAS command available in the Controller. I am using HEC RAS 4.1 and have looked through the library but this command does not exsit nor does it works.
    Well, i have figured another way round to address the problem but i believe that this command can be very helpful.
    Looking forward to your reply. Take care.

    Regards
    Nayyar Minhaj ASIF

  30. Chris Goodell

    on April 25, 2016

    Hi Nayyar. Thanks for buying the book. Glad you find it useful. The QuitRAS procedure is new for version 5.0. Since you are using Version 4.1, it won't be there. Sounds like you found a work around, so that's good.

  31. Nayyar Minhaj ASIF

    on June 28, 2016

    Hello Chris

    I would appreciate your help over the following issue.

    I am trying to extract flow hydrograph for a river station. I am using the OUTOUTDSS_GETSTAGE FLOW command for that. It works fine, however, whatif i want a flow hydrograph through a gated lateral structure? Even if i mention "Lateral Structure RS" in the "FLOW OUTPUT LOCATIONS", it does not give me the gated flow. It gives me the flow at that river station in the river but i would like to have the flow through the gated structure (lateral). How can i handle this?

    Currently, i have connected a temporary storage area with my lateral structure to actually extract the hydrograph using the DSS_GETSTAGEFLOWSA but that doesn't seems neat. Any suggestions?

    Thanking in advance.
    Regards
    Nayyar

  32. Nayyar Minhaj ASIF

    on June 28, 2016

    Forgot to mention.

    I cannot simply extract discharge of a lateral structure for a fix profile number. The reason is quite weird actually.

    I am using rule based BC's for the operations. And there seems a glitch in the HEC RAS output table. The discharge passing through the gates (lateral structure) in the SUMMARY OUTPUT TABLE BY PROFILE is not the same as shown in FLOW HYDROGRAPHS. The values shown in FLOW HYDROGRAPH are correct as those are the values that are writed in the text file and also present in the DSS, however, values shown in SUMMARY OUTPUT TABLE are incorrect. Using the "Discharge extraction by profile number" will give me the wrong value.

    As an example,

  33. Anonymous

    on July 22, 2016

    Hi Chris, at the moment I am attempting to use R to automate HEC-RAS. It has been difficult to find any documentation or previous experience on this subject. Could you please share with me some information so I can use it as a guide and probably collaborate?

  34. Nayyar Minhaj ASIF

    on August 29, 2016

    Hello Chris. I have a question regarding the OUTPUTDSS_GETSTAGEFLOW.

    Does this command works for extracting hydrographs of the Lateral Structures i.e. flow flowing through gates??

    I know i can extract gate flows through the profiles but that would be requiring post processing which i am looking to avoid. Is there a way to interact with the DSS for extracting hydrographs for lateral structures?

    Regards
    Nayyar

  35. Prince Mathur

    on November 3, 2016

    Hi Chris,
    Would like to have few clarification to atomize HecRAS setup..
    1. I do have sdf file (300mb)generated from ArcGIS for geometry input. How can I import sdf file without using HecRAS GUI. Since it is taking too much time to load in HecRAS.
    2. How can I setup a new HecRAS project without using GUI and import all the relevant file in it?

  36. Chris Goodell

    on November 4, 2016

    1. You would have to learn the structure of the sdf file, then write code to write a .geo file based on the data in the sdf file. "Breaking the HEC-RAS Code" can help you with the structure of the geometry input file, but this would not be a trivial task.

    2. See my answer to question 1.

  37. Anonymous

    on January 12, 2017

    Hi, Chris,

    I tested your code above with a replaced path for the Beaver Creek example in HEC-RAS 5.0.3. I used the RAS500 DLL. I got an error message in Microsoft Visual Basic "Run-time error'429':ActiveX component can't create object". What did I miss? Thanks for your time.

    Ken Ying

  38. Chris Goodell

    on January 12, 2017

    You should use the RAS503 DLL if you are using HEC-RAS 5.0.3.

  39. Unknown

    on January 13, 2017

    Chris,

    I got the 4.1 version working. But 5.03 just didn't work. It seems that the function name HECRASController is different in 5.03. Any idea? Thanks.

  40. Ken Ying

    on January 16, 2017

    Chris,

    I tried the RAS503.HECRASController and it gave me the error message: "Compile error: User-defined type not defined".

  41. Chris Goodell

    on January 16, 2017

    What line of code returned that error message?

  42. Edsel Matt Morales

    on June 12, 2017

    Hi Chris, we are trying to automate the process in producing flood map and I just want to ask if this is achievable?

    Thanks.

  43. Chris Goodell

    on June 19, 2017

    Yes, it's possible, but you'll have to learn how to read from an hdf5 file.

  44. Alex C

    on June 20, 2017

    I received the same message in relation to the line;
    Dim RC As New RAS41.HECRASController

  45. Chris Goodell

    on June 21, 2017

    Alex, have you added RAS41 as a reference to your code (steps 3 and 4 above)? In any case, I suggest using RAS503 instead. Just make sure you have RAS Version 5.0.3 installed on your computer first.

  46. For Comment

    on October 23, 2017

    Is there API calls in the controller to create DSS file and add timeseries data to it?

  47. Chris Goodell

    on October 24, 2017

    Not to write to the DSS file. You can read from it though. You might explore DSSVue and the DSSVue plugins from the HEC website.

  48. MSc. HOJJAT SEYYEDI

    on March 8, 2018

    Hi Chris,

    I just ordered your book and hoping that it is gonna help me with setting up HEC RAS 2D for large areas, with several runs. I hope that I can do following list using the API:
    1- Create a new terrain
    2- Define 2D flow area
    3- Define BCs
    4- Mesh generation
    5- Assign flow data to BCs

  49. Chris Goodell

    on March 8, 2018

    Thank you Hojjat! I’m pretty sure the current version of HRC can’t create a terrain for you or directly define a 2D area, but there’s lots you can do with reading and writing to the input text files that may help you accomplish this. Reading from the HDF files will be useful too.

  50. Anonymous

    on April 25, 2018

    Hi Chris,

    I just got your book. What an extensive work!
    I'm trying to run a Monte-Carlo simulation using the resources provided in the book. I like you explained the procedure in details but the code that manipulates Manning's n values by reading/rewriting a geometry file is missing. Only the code that is using the HECRASController function Geometry_SetMann_LChR is available. Where can I find the missing code? I appreciate your help on this issue. Thanks!!

    -Nathalie

  51. Chris Goodell

    on April 26, 2018

    Thanks Nathalie- Glad you enjoy the book. You know, you are the first person to point that out that mistake in the book. The paragraph before the code says the code was written demonstrating reading and writing from/to HEC-RAS text files. Indeed it was originally, but for publishing I switched to the easier Geometry_SetMannLChR function. But, if you would like to see how the geometry text file could be rewritten each realization (instead of using SetMannLChR), page 100 at the bottom begins some code that demonstrates how to do this. Let me know if you have any trouble figuring this out.

  52. Anonymous

    on April 30, 2018

    Thank you, Chris. I was able to get the geometry file modification to work based on other parts of the book like p.100 you mentioned! Somehow SetMannLChR function doesn't update the n values on me but I'm glad the other approach works. Thank you for being responsive. I saw your recent webinar and that was helpful as well. Keep up the good work!

  53. Unknown

    on August 7, 2018

    Hi Chris,

    When running: RC.OutputDSS_GetStageFlow("RivernName","ReachName","Station",0,0,0,0,"Error")

    I got 0 as result.

    Would you please advice?

    Thanks,
    Zara

  54. Anonymous

    on September 4, 2018

    Dear Chris

    Is there a way to automatically calculate flood area after a run, that's mean to pilot RasMapper throught an API or with command line ?

    Fabrice

  55. Charlie

    on September 27, 2018

    Hi Joshua- did you ever have success with automating HEC-RAS within R? I have found it difficult to find information on this and any advice you have would be appreciated!

  56. Evan

    on June 14, 2019

    Chris:

    Just a quick head's up, the link at the bottom of this article takes you to https://www.createspace.com/4701459, which I imagine is your admin page for Amazon publishing, rather than to the amazon link itself.

  57. Chris G.

    on June 18, 2019

    Thanks for the heads up Evan. I've corrected the link now.

    -Chris

  58. ScottK

    on September 13, 2019

    Martin,

    I am working on a project very similar to yours. I am trying to execute Ras models on remote machines but instead of using excel and a macro I am using a python script that takes parameters through command line the parameters are the .prj, .p01, etc. I see hec-ras open on the Task Manager but like your issue it stalls. I am using c# to access the remote machines through PsExec adn write the command line script. Any guidance on getting the models to run would be great! Thanks!

  59. Jesse

    on July 19, 2021

    Chris,

    Is there a similar function to Geometry_SetMann_LChR that can change the parameters in the Ice Cover option in RAS? I’d like to be able to do a Monte Carlo analysis with the Ice Cover and Ice Jam parameters.

    Thanks,
    Jesse

  60. Yersultan Saduakhas

    on October 11, 2021

    Hi Chris!, I’m a GIS software engineer. Now I’m working on automating flood modeling with HEC-Ras, here I need some help on converting flood result hdf file into web images.
    You answered to Edsel Matt Morales:
    Hi Chris, we are trying to automate the process in producing flood map and I just want to ask if this is achievable?
    Yes, it’s possible, but you’ll have to learn how to read from an hdf5 file.

    Could you please give any guide how to export hdf to gis formats: tiff or png

  61. Stefano

    on February 1, 2023

    Hello Chris, i am a phd student in civil engeneering and from several years i am working with hec-ras by using matlab. Thank you for your book. It is very useful. Now, i am struggling with OutputDSS_GetStageFlow. By using the new version of Hec-ras (e.g 6.3.1) the above mentioned command doesn’t work, because a new format for DSS files has been introduced (DSS7). How can i read the DSS7? Thank you!

  62. Salar

    on May 16, 2023

    Hi Chris. I got your book and written codes however I get an error while I am trying to execute OutputDSS_GetStageFlow to get the outflow hydrograph in Hec-Ras versions 6 and newer. The only difference between the OutputDSS_GetStageFlow function in hecras 507 and 6 is that in version 6 the flow and stage should be Dim As Double and not a Single. VBA debugger highlights the
    blnDidItCompute = RC.OutputDSS_GetStageFlow(strRiver, _
    strReach, strRS, lngNumValue, dblDateTime(), _
    dblStage(), dblFlow(), strErrMsg)
    I tried many ways and it didn’t work. It runs on version 5.0.7. but not in 6 versions. What would be the issue? Is that basically mean this function is not working in version 6? Thank you.

  63. Chris Goodell

    on May 18, 2023

    Hi Salar. This is a known issue in Version 6. For some reason, the OutputDSS_GetStageFlow procedure just doesn’t work. HEC knows about this. Hopefully they will fix it soon. I’ve gotten around this by reading my output from the HDF file now, instead of using the OutputDSS_GetStageFlow procedure. You can find libaries out there that contain procedures for reading from HDF files. I use the H5Reader class in the HDFPInvokeDotNet dll (HDF.PInvoke.dll) that comes with the HEC-RAS Software.

Add Your Comment

Leave a Reply

one × 5 =


Related Posts

SEE ALL BLOG POSTS