6

I have a series of tools that I need to run in ArcGIS to hydrologically condition my DEM, but the first step in this process is running the Breach Depressions tool from Whitebox GAT (I have found that this tool works really well for breaching streams across bridges and dams).

Is it possible to work entirely in ArcMap and call the breach depression tool from whitebox? I tried executing the python code in ArcGIS but it doesn't seem to work. Here is what I tried:

wd = "D:\LIDAR\02060006_Patuxent\01_HeadwatersPatuxent\0104_HUC12"
pluginHost.setWorkingDirectory(wd)
inputFile = wd + "DEM_clip.dep"
outputFile = wd + "DEMBreach.dep"
maxBreachLength = "50"
outputPointer = "true"
args = [inputFile, outputFile]
pluginHost.runPlugin("BreachDepressions", args, False)

I'm pretty new to python and coding in general so the answer may be more obvious than I think. I should add that right now I'm running my tools in a geoprocessing model so ideally I would like to somehow add the whitebox breach depressions tool into my geoprocessing model, but would be open to trying it out in a python script.

  • 1
    This is the only loosely related Q&A that I could find here by search on "ArcGIS whitebox integration": gis.stackexchange.com/questions/18568/… – PolyGeo Aug 3 '15 at 9:10
  • 1
    @PolyGeo back in 2012 when I asked that question ^, Whitebox GAT was developed in .Net, and thus had a library of .DLLs available for consumption in other .Net environments (like custom ArcObjects tools, etc). Since then, however, Whitebox has been ported to Java. So I'm guessing any insights gleaned from my earlier question are probably void in in the context of this question. – elrobis Aug 12 '15 at 18:01
8

I'm afraid that when I wrote Whitebox GAT, I never really anticipated that there would be a demand to be able to run the Whitebox plugin tools from outside the user interface. I knew that there would be a need for automating workflows and that's why I wrote the scripting capabilities into it, such that each tool can be called internally from a Python, Javascript, or Groovy script. But I just never thought about people wanting to run a Whitebox tool from within ArcGIS. Because Whitebox runs on the Java Virtual Machine, and because of the way that I structured the program, unfortunately I don't think that it's currently possible to do this. Whitebox GAT plugin tools need to be able to communicate with the Whitebox user interface.

I have had quite a bit of interest in being able to do this over the years and so have started to develop a small experimental open-source geospatial analysis library, called GoSpatial, with this exact purpose in mind. There aren't many tools in GoSpatial yet, but there is a breaching tool (BreachDepressions) that is based on the tool in Whitebox GAT that you are referring to. I have recently written a paper that describes how this tool works in detail,

Lindsay JB. In Press. Efficient hybrid breaching-filling sink removal methods for flow path enforcement in digital elevation models. Hydrological Processes. DOI: 10.1002/hyp.10648

which you can download from this site:

http://www.uoguelph.ca/~hydrogeo/publications.html

I think you'll find that this breaching tool satisfies your need for an improved method for sink removal and flow enforcement. The tool takes a number of input DEM raster formats, including the ArcGIS binary raster (.flt and .hdr files) and GeoTIFF files, and will also write the modified DEM in these same formats. There is also a short description of how you can call GoSpatial tools from a Python script at the library's GitHub repository. The example shows how to call the FillDepressions tool, but the idea is the same for the BreachDepressions tool it just uses different parameters. If you read the paper, you'll find that I am strongly discouraging people from filling their depressions when breaching (and breach-first hybrid methods) provides a far better solution for flow enforcement under most conditions. So you might see the irony in the fact that I used the FillDepressions tool in the example Python script on the site. Anyhow, if you need help with it or run into any problems with the library, please let me know.

UPDATE

Significant progress has been made recently that has resulted in a need to update the original answer. It is now possible to use Python to call many of the geoprocessing tools in Whitebox GAT using the new WhiteboxTools library. While WhiteboxTools does not currently allow users to access all 400+ Whitebox GAT tools, approximately 300 of the original tools have been ported over to this new stand-alone geoprocessing library. The following is an example of how to use Python to call a tool:

# import WhiteboxTools class from whitebox_tools.py script
from whitebox_tools import WhiteboxTools

wbt = WhiteboxTools()

# set the working directory
wbt.work_dir = "/path/to/data/"

# run a 9 x 9 mean filter
wbt.mean_filter("input_file.tif", "output_file.tif", 9, 9) 

More detailed examples of using Python scripting to interact with WhiteboxTools can be found in the user manual.

  • +1, glad to see you're back answering again :) – Joseph Sep 14 '15 at 11:18
  • 1
    @Joseph, Thanks. I just got busy with work, that's all. – WhiteboxDev Sep 14 '15 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.