1

I'm trying to add the symbology of an already existing layer in my folder to a the slope map being created by my Python script. I'm getting this error, however, and I don't know why.

Code:

def main():
    import arcpy
    from arcpy.sa import *
    arcpy.CheckOutExtension("Spatial")
    arcpy.env.workspace = "C:\\Users\\user\\OneDrive\\Documents\\ArcGIS\\ArcMap_Folder"
    inRaster = "USGS_13_n37w082_20220512.tif"

    outSlope = Slope(inRaster, "PERCENT_RISE")
    outSlope.save("C:\\Users\\user\\OneDrive\\Documents\\ArcGIS\\ArcMap_Folder\\slope2.tif")

    myRemapRange = RemapRange([[0, 3.99, 1], [4, 9.99, 2], [10, 15.99, 3], [16, 30.99, 4], [31, 60.99, 5], [61, 999999, 6]])
    outReclassRR = Reclassify(outSlope, "VALUE", myRemapRange,"NODATA" )
    outReclassRR.save("C:\\Users\\user\\OneDrive\\Documents\\ArcGIS\\ArcMap_Folder\\reclass2.tif")
    arcpy.management.MakeRasterLayer(outReclassRR, "outReclassRR_layer")
    arcpy.management.ApplySymbologyFromLayer(outReclassRR, "reclass_copy.lyr")
    

if __name__ == '__main__':
    main()

Error:

Runtime error  Traceback (most recent call last):   File "<string>", line 20, in <module>   File "<string>", line 16, in main   File "c:\program files (x86)\arcgis\desktop10.8\arcpy\arcpy\management.py", line 6944, in ApplySymbologyFromLayer     raise e ExecuteError: ERROR 000732: Input Layer: Dataset C:\Users\darel\OneDrive\Documents\ArcGIS\ArcMap_Folder\reclass2.tif does not exist or is not supported ERROR 000968: The symbol layer does not match the input layer

I'm using ArcMap,.

2
  • 1
    The error message says "...The symbol layer does not match the input layer", I suspect your raster is not matching what ever is in your layer file reclass_copy.lyr? You are not showing us this so no one can comment.
    – Hornbydd
    Jun 27 at 13:59
  • @Hornbydd I figured it out. In the arcpy.management.ApplySymbologyFromLayer(outReclassRR, "reclass_copy.lyr") I was passing in a variable, instead of another .lyr file. I should have been passing the outReclassRR_layer .lyr file created from arcpy.management.MakeRasterLayer(outReclassRR, "outReclassRR_layer"). Now the code works properly. Thanks!
    – Darell
    Jun 27 at 14:25

1 Answer 1

1

So I figured out that the problem was that I was passing in "outReclassRR" in the arcpy.management.ApplySymbologyFromLayer() function instead of "outReclass_layer" which was created from arcpy.management.MakeRasterLayer(outReclassRR, "outReclassRR_layer").

Now both are being passed as .lyr files and the code is working properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.