I'm trying to run a weighted overlay on two separate integer rasters. I built the original overlay model in arcpro and exported the tool as script. I then modified the script to fit the syntax as shown on the ESRI help pages. Now when I run the script I receive (Unspecified error Class not registered). The landcover and slopeint classes reference existing raster files in the environment gdb. I have cropped out the middle portion of the script that prepares the rasters.
What did I do wrong?
#Import modules
import arcpy
from arcpy.sa import *
from sys import argv
LandCover = "LandCover"
slopeint = "slopeint"
intable = WOTable([[slopeint, 50, "Value", RemapValue([[0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [11, 3], [12, 3], [13, 2], [14, 2], [15, 1], [16, 'Restricted'], [17, 'Restricted'], [18, 'Restricted'], [19, 'Restricted'], [21, 'Restricted'], [22, 'Restricted'], [23, 'Restricted'], [24, 'Restricted'], ["NODATA", "NODATA"]])],
[LandCover, 50, "Class", RemapValue([['Open Water', 'Restricted'], ['Perennial Snow/Ice', 1], ['Developed, Open Space', 3], ['Developed, Low Intensity', 2], ['Developed, Medium Intensity', 1], ['Developed, High Intensity', 'Restricted'], ['Barren Land', 3], ['Deciduous Forest', 'Restricted'], ['Evergreen Forest', 'Restricted'], ['Mixed Forest', 'Restricted'], ['Shrub/Scrub', 2], ['Herbaceuous', 2], ['Hay/Pasture', 3], ['Cultivated Crops', 3], ['Woody Wetlands', 'Restricted'], ['Emergent Herbaceuous Wetlands', 'Restricted'], ['NODATA', 'NODATA']])]],
[1, 3, 1])
helicoptersuitability = WeightedOverlay(intable)
helicoptersuitability.save("helicoptersuitability")
Error Message:
Traceback (most recent call last):
File "D:\Documents\School\USC\586\586_Project_5\Project_5\SiteSuitability.py", line 78, in <module>
helicoptersuitability = WeightedOverlay(intable)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 10452, in WeightedOverlay
return Wrapper(
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Utils.py", line 55, in swapper
result = wrapper(*args, **kwargs)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 10449, in Wrapper
result = arcpy.sa.Apply(rasters, "WeightedOverlay", args)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\ia\_ia.py", line 135, in Apply
return arcgisscripting._ia.Apply(in_raster=in_raster,
RuntimeError: Failed to apply Raster Function: 'WeightedOverlay' (Unspecified error
Class not registered
reformatting the WOTable to make it easier to see what looks off.
for slopeint ... not class 20?
([[slopeint, 50, "Value",
RemapValue([[0, 3],
[1, 3],
[2, 3],
[3, 3],
[4, 3],
[5, 3],
[6, 3],
[7, 3],
[8, 3],
[9, 3],
[10, 3],
[11, 3],
[12, 3],
[13, 2],
[14, 2],
[15, 1],
[16, 'Restricted'],
[17, 'Restricted'],
[18, 'Restricted'],
[19, 'Restricted'],
[21, 'Restricted'],
[22, 'Restricted'],
[23, 'Restricted'],
[24, 'Restricted'],
["NODATA", "NODATA"]])],
[LandCover, 50, "Class",
RemapValue([['Open Water', 'Restricted'],
['Perennial Snow/Ice', 1],
['Developed, Open Space', 3],
['Developed, Low Intensity', 2],
['Developed, Medium Intensity', 1],
['Developed, High Intensity', 'Restricted'],
['Barren Land', 3],
['Deciduous Forest', 'Restricted'],
['Evergreen Forest', 'Restricted'],
['Mixed Forest', 'Restricted'],
['Shrub/Scrub', 2],
['Herbaceuous', 2],
['Hay/Pasture', 3],
['Cultivated Crops', 3],
['Woody Wetlands', 'Restricted'],
['Emergent Herbaceuous Wetlands',
'Restricted'],
['NODATA', 'NODATA']])]],
[1, 3, 1])
I just corrected that but no change in the error.
This is the code as generated form arcpro if I were to export the tool as python
out_raster = arcpy.sa.WeightedOverlay(r"('D:\Documents\School\USC\586\586_Project_5\Project_5\Project_5.gdb\slopeint' 50 'Value' (0 3; 1 3; 2 3; 3 3; 4 3; 5 3; 6 3; 7 3; 8 3; 9 3; 10 3; 11 3; 12 3; 13 2; 14 2; 15 1; 16 Restricted; 17 Restricted; 18 Restricted; 19 Restricted; 21 Restricted; 22 Restricted; 23 Restricted; 24 Restricted; NODATA NODATA);
'D:\Documents\School\USC\586\586_Project_5\Project_5\Project_5.gdb\LandCover' 50 'Class' ('Open Water' Restricted; 'Perennial Snow/Ice' 2; 'Developed, Open Space' 3; 'Developed, Low Intensity' 2; 'Developed, Medium Intensity' 1; 'Developed, High Intensity' Restricted; 'Barren Land' 3; 'Deciduous Forest' Restricted; 'Evergreen Forest' Restricted; 'Mixed Forest' Restricted; 'Shrub/Scrub' 2; 'Herbaceuous' 2; 'Hay/Pasture' 3; 'Cultivated Crops' 3; 'Woody Wetlands' Restricted; 'Emergent Herbaceuous Wetlands' Restricted; NODATA NODATA))
;1 3 1");
out_raster.save(r"D:\Documents\School\USC\586\586_Project_5\Project_5\Project_5.gdb\suitabilityoverlay")
I don't know. But even though the whole input to the weighted overlay tool is raw encoded (r" ... ) the paths of the inputs and outputs are not.
'D:\Documents\School\USC\586\586_Project_5\Project_5\Project_5.gdb\slopeint'
yields errors which vanish when done as
r'D:\Documents\School\USC\586\586_Project_5\Project_5\Project_5.gdb\slopeint'
You might want to try different gdb (saving location or raw encode the file paths in the above lines and try it from within your python IDE