Select to view content in your preferred language

Arcpy Weighted Overlay Type mismatch

698
2
Jump to solution
01-10-2023 03:09 PM
EdahŠahinović
New Contributor

Trying to run an arcpy.sa.WeightedOverlay on 3 datasets derived from multiple ring buffered point features and rasterized on the way, but am getting an error. I have tried everything in my power and listed online to mitigate this issue: same extent, cell size, projection, works fine when manually running in Pro with same datasets. Their pixel type: 16-bit signed integer

Short workflow on what I did with datasets: OSM data -> Multiple Ring Buffer -> Clip -> Polygon to Raster (this resulted in rasters with Short pixel type and produced same error). Next attempt was to convert to .tif format (as seen in the code the file extension) with Raster To Other Format (as it suggests on official Arcgis tool description). After that I've tried to reclassify the values, but results in Unsigned char pixel type.

Nevertheless, all these rasters I've tried in ArcPy actually work within the manual use of the tool. 

I receive:

RuntimeError: Failed to apply Raster Function: 'WeightedOverlay' (Type mismatch. )

Code sample:

 

import arcpy


arcpy.env.workspace = r'..\\Application Development\\Suitability Analysis'
directory = r'..\\Application Development\\Suitability Analysis'


park_raster = arcpy.Raster(directory + r"\\data\\osm\\osm_final_tiff\\park_raster.tif") # don't add extensions as .tif, does not recognize layer
bus_raster = arcpy.Raster(directory + r"\\data\\osm\\osm_final_tiff\\bus_raster.tif")
economic_raster = arcpy.Raster(directory + r"\\data\\osm\\osm_final_tiff\\economic_raster.tif")

describe1 = arcpy.Raster(park_raster)

#checking if it fetches the raster, works fine
check_park = arcpy.management.GetRasterProperties(park_raster, "VALUETYPE")


wotable = arcpy.sa.WOTable([[park_raster, 50, "VALUE", ([[250, 5], [500, 4], [750, 3], [1000, 2], [5000, 1], ["NODATA", "NODATA"]])],
                        [bus_raster, 30, "VALUE", ([[100, 5], [250, 4], [500, 3], [1000, 2], [5000, 1], ["NODATA", "NODATA"]])],
                        [economic_raster, 20, "VALUE", ([[250, 5], [500, 4], [1000, 3], [2000, 2], [5000, 1], ["NODATA", "NODATA"]])]], [1, 5, 1])
        

outWeightedOverlay = arcpy.sa.WeightedOverlay(wotable)
outWeightedOverlay.save(r"..\\Application Development\\Suitability Analysis")

 

 

I have done everything in my power and what I've encountered so far: same projection, cell size, data type

One noticeable thing is that here RemapValue is defined within the WOTable but in mine code it doesn't exist as it is an unrecognized parameter and throws an error, if this can serve as a clue..

 

Any help would be appretiable. Thank you

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

 

from arcpy.sa import *
wotable = WOTable([
    [park_raster, 50, "VALUE", ([[250, 5], [500, 4], [750, 3], [1000, 2], [5000, 1], ["NODATA", "NODATA"]])],
    [bus_raster, 30, "VALUE", ([[100, 5], [250, 4], [500, 3], [1000, 2], [5000, 1], ["NODATA", "NODATA"]])],
    [economic_raster, 20, "VALUE", ([[250, 5], [500, 4], [1000, 3], [2000, 2], [5000, 1], ["NODATA", "NODATA"]])]],
    [1, 5, 1]
)
out_ = WeightedOverlay(wotable)
out_.save(...etc)

Did you try with the * import as in the help topics?

WOTable—ArcGIS Pro | Documentation

 


... sort of retired...

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

 

from arcpy.sa import *
wotable = WOTable([
    [park_raster, 50, "VALUE", ([[250, 5], [500, 4], [750, 3], [1000, 2], [5000, 1], ["NODATA", "NODATA"]])],
    [bus_raster, 30, "VALUE", ([[100, 5], [250, 4], [500, 3], [1000, 2], [5000, 1], ["NODATA", "NODATA"]])],
    [economic_raster, 20, "VALUE", ([[250, 5], [500, 4], [1000, 3], [2000, 2], [5000, 1], ["NODATA", "NODATA"]])]],
    [1, 5, 1]
)
out_ = WeightedOverlay(wotable)
out_.save(...etc)

Did you try with the * import as in the help topics?

WOTable—ArcGIS Pro | Documentation

 


... sort of retired...
0 Kudos
EdahŠahinović
New Contributor

Wow, this actually worked! Thank you!

What I had seen just as a module 'shortcutting' acutally did the trick. The RemapValue is now glowing as a parameter as it should after all!

0 Kudos