关于arcpy的问题,如何解决?

 ###### arcpy对栅格计算器进行计算
但是在运行时总会报错。找不到原因。报错:

Runtime error 
Traceback (most recent call last):
  File "", line 28, in 
AttributeError: ResultObject: \u672a\u627e\u5230\u83b7\u53d6\u5c5e\u6027 save

原代码如下

import arcpy
from arcpy.sa import *
from arcpy import env

# 设置工作空间和输出文件夹
arcpy.env.workspace = r"F:/study/DataCopy"
output_folder = r"F:/study/DataCopy/data2/"

# 定义栅格计算器表达式
# 这里使用了字典,方便后面进行循环处理
expression_dict = {
    "1991-1992": "10 * \"CLCD_v01_1991_albert_henan.tif\" + \"CLCD_v01_1992_albert_henan.tif\"",
    "1991-1993": "100 * \"CLCD_v01_1991_albert_henan.tif\" + 10 * \"CLCD_v01_1992_albert_henan.tif\" + \"CLCD_v01_1993_albert_henan.tif\"",
    "1991-1994": "1000 * \"CLCD_v01_1991_albert_henan.tif\" + 100 * \"CLCD_v01_1992_albert_henan.tif\" + 10 * \"CLCD_v01_1993_albert_henan.tif\" + \"CLCD_v01_1994_albert_henan.tif\"",
    # "2000_2001": "10 * \"CLCD_v01_2000_albert_henan.tif\" + \"CLCD_v01_2001_albert_henan.tif\"",
    # "2000_2002": "100 * \"CLCD_v01_2000_albert_henan.tif\" + 10 * \"CLCD_v01_2001_albert_henan.tif\" + \"CLCD_v01_2002_albert_henan.tif\"",
    # "2000_2003": "1000 * \"CLCD_v01_2000_albert_henan.tif\" + 100 * \"CLCD_v01_2001_albert_henan.tif\" + 10 * \"CLCD_v01_2002_albert_henan.tif\" + \"CLCD_v01_2003_albert_henan.tif\"",
    # "2000_2004": "10000 * \"CLCD_v01_2000_albert_henan.tif\" + 1000 * \"CLCD_v01_2001_albert_henan.tif\" + 100 * \"CLCD_v01_2002_albert_henan.tif\" + 10 * \"CLCD_v01_2003_albert_henan.tif\" + \"CLCD_v01_2004_albert_henan.tif\"",
    # "2001_2002": "10 * \"CLCD_v01_2001_albert_henan.tif\" + \"CLCD_v01_2002_albert_henan.tif\"",
    # "2001_2003": "100 * \"CLCD_v01_2001_albert_henan.tif\" + 10 * \"CLCD_v01_2002_albert_henan.tif\" + \"CLCD_v01_2003_albert_henan.tif\""
}

# 循环处理每个表达式,进行栅格计算并保存输出
for key, expression in expression_dict.items():
    # 执行乘法和加法运算
    result = arcpy.gp.RasterCalculator(expression)
    # 生成输出文件名
    output_name = key + ".tif"
    # 拼接输出文件路径
    output_path = output_folder + "\\" + output_name
    # 保存结果到输出文件
    result.save(output_path)

请指点

result.save(output_path)
改为:
arcpy.CopyRaster(result, output_path)

该错误提示说Result Object没有save属性,将保存结果的方法从result.save改为arcpy.CopyRaster()

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632