Raster processing tools that take a raster OR a constant fail
Hornbydd opened 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"]
@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.
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 existFailed to execute (Divide).
Failed at Tue Mar 10 18:46:31 2020 (Elapsed Time: 0.42 seconds)
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.