Trying to Write a Script Using Weighted Overlay Having Issues

352
0
03-31-2022 07:53 AM
Labels (3)
MaxwellDeBellaSRF
New Contributor

I am trying to develop an independent tool using python and ArcGIS Pro SDK. I have everything working except for the weighted overlay. When I run the weighted overlay within Pro as a tool/within the model builder it runs just fine. However, when I export it to python to be added to by code I get the error: 

Traceback (most recent call last):
  File "<string>", line 87, in execute
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 10159, in WeightedOverlay
    in_weighted_overlay_table)
  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 10092, in Wrapper
    m = table_eval_pattern.match(in_weighted_overlay_table)
TypeError: expected string or bytes-like object

 

This is the python export from the model builder:

Weighted_Overlay_Raster = "L:\\Projects\\14000\\14002\\GIS_Data\\gdb\\Deicing_Module_Builder.gdb\\Weighted_Overlay_Raster"
Weighted_Overlay = Weighted_Overlay_Raster
with arcpy.EnvManager(cellSize=Cell_Size, extent=Plow_Routes_Buffer, outputCoordinateSystem=Output_Coordinate_System,
parallelProcessingFactor=Parallel_Processing_Factor, workspace=Workspace):
Weighted_Overlay_Raster = arcpy.sa.WeightedOverlay(in_weighted_overlay_table=[[NLCD_Recalc, 0.1, "NLCD_Land", "Developed 6;Agriculture 1;Forest 2;Herbaceuous 3;'Barren Land' 5;Shrub/Scrub 6", "NLCD Recalc"], [Soils_Raster, 0.15, "muaggatt_drclassdcd", "'Well drained' 3;'Excessively drained' 1;'Moderately well drained' 4;'Poorly drained' 6;'Somewhat excessively drained' 2;'Very poorly drained' 7;'Somewhat poorly drained' 5", "Soils_Raster"], [Wellhead_Raster, 0.35, "whp_type_NAME", "'Aquifer Delineation' 1;'Conjunctive Delineation' 1", "Wellhead_Raster"], [NWI_NHD_Reclass_raster, 0.4, "Value", "1 1", "NWI/NHD Reclass raster"]])
Weighted_Overlay_Raster.save(Weighted_Overlay)

Can anyone tell me why I keep getting this message and why it only seems to happen when running in python? My goal is to have the weighted overlay run just like it does in Pro -- it prompts the user with a table and then produces a output raster. The only difference is that in my tool a ribbon button will bring up the table in a window. 

0 Kudos
0 Replies