Monday, October 8, 2018

Using the HEC-RAS Controller with the R programming environment

Hey all HEC-RAS Controllers-

Charlie Ferguson of the University of Cambridge recently emailed me about some questions about automating HEC-RAS using the HECRASController and the R programming environment.  While "Breaking the HEC-RAS Code" was written around use of VBA for automating HEC-RAS, there are several other programming languages out there that will work.  R is a powerful programming language for statistical computing and graphics.  I've seen it used before and it is quite impressive.  In talking with folks interested in automating HEC-RAS, besides VBA and Visual Studio, Python and R seem to be the programming languages/platforms most people are talking about.  You can read up more on R here.  

Unfortunately I don't have experience using R (yet).  So I'm opening this up to the HECRASController community out there for assistance.  The following is Mr. Ferguson's call for help and collaboration regarding automating HEC-RAS using R.  Please comment below and respond directly to Mr. Ferguson if you wish to share ideas.

The HEC RAS Controller has been used in several different environments (VBA, Matlab etc.) and I am trying to establish how to get it working in R. From what I can find online, there have already been several attempts and would really appreciate any advice or collaboration.

So far I have followed a similar process to ‘Toby’ in this post on the online HEC RAS Controller help forum. The process relies on an R package called R-DCOMClient. A slight difference in my script is to construct the variable ‘strMessages’ as an empty character matrix;
which appears to satisfy the data type required by the underlying COM method (Compute_CurrentPlan).

However, I’ve then found another error stemming from R-DCOMClient requiring a related R package called ‘R-DCOMServer’. Unfortunately, as far as I’m aware, this package and its prerequisites are no longer available (also, for separate reasons, I need to use an R version no older than 3.1.).  This means I’ve hit a dead-end.

I am wondering whether anyone has found a way past this problem OR has found an entirely different solution for running controller in R?

Any advice or offers to collaborate would be welcome!