opengeos/WhiteboxTools-ArcGIS

Raster processing tools that take a raster OR a constant fail

Closed this issue · 7 comments

There are many tools in the Math and Stats Tool toolset that have parameters that take a raster OR a constant. If try to run any of these tools they all fail as you cannot proceed as they reject a constant value.

Take the Divide tool as example you cannot divide your test data DEM.tif by a number.

For these tools expanding the allowable list of data types resolves the issue, I tried the following:

datatype=["GPRasterLayer","Long","Double"]

@Hornbydd This bug has been fixed. It should be working now. Thanks for reporting!

@giswqs your edits have not resolved the problem, the problem is in the Parameter definition and the datatype. It need's updating to something like:

datatype=["GPRasterLayer","Long","Double"]

The tool validation step does not allow you to enter a number, try it.

Your validation that you have put in the execute() can never run as the tool validation is where it should be trapping invalid parameters, so ironically it is doing it's job, you just need to expand the allowable datatypes.

I only tested in ArcGIS Pro, and it works fine. See below. So it seems ArcGIS Pro and ArcMap are handling tool validation differently. I will revise the code and test it in ArcMap.

It should work with ArcMap now.

@giswqs No it's not! You have fixed the issue with the validation by using the GPDouble, but you are using a method isnumeric() which is not compatible with the version of python installed with ArcMap, so the code crashes with:

Executing: Divide DEM.tif 5.3 C:\Scratch\oo.tif
Start Time: Tue Mar 10 18:46:31 2020
Running script Divide...

Traceback (most recent call last):
File "", line 27680, in execute
File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy_init_.py", line 1260, in Describe
return gp.describe(value, data_type)
File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\geoprocessing_base.py", line 376, in describe
self._gp.Describe(*gp_fixargs(args, True)))
IOError: "5.3" does not exist

Failed to execute (Divide).
Failed at Tue Mar 10 18:46:31 2020 (Elapsed Time: 0.42 seconds)

See here and here.

I would strongly recommend you don't use ArcPro as the test software as these sorts of incompatibilities creep in. As your homepage shows nothing but ArcMap screenshots I would stick to ArcMap and you need to program with version 2.7 in mind.

@Hornbydd Oops, I only tested integer numbers. Thanks for the catch. It should be truly fixed now. Please try again.

@giswqs Just tested some of the tools and they all appear to be running well! Parameters are accepted and no crashing, so well done. I can't get over how quick WBT runs, its great!