TypeError:'long'对象不是可迭代的Python

时间:2013-04-02 11:27:45

标签: python arcgis floating

我正在尝试在32位浮动栅格中重新分类PixelValue并收到以下错误:

 bw_liss-3_spring_mosaick_gk3_ndvi_mask.tif

 Traceback (most recent call last):    File
 "F:\Daten_Soner\CBD06\Test\NDVI\Spring\Extract\Reclassify_Cloudmask_LISS_Summer.py",
 line 29, in <module>
      remap = RemapValue([-340282346638528860000000000000000000000,000000,2])   

 File "C:\Program Files
 (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\ParameterClasses.py", line
 806, in __init__
     _Remap.__init__(self, remapTable)    File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\ParameterClasses.py", line
 751, in __init__
     self.remapTable = [list(record) for record in remapTable]

 TypeError: 'long' object is not iterable

我使用以下脚本:

Import arcpy module
import arcpy, os, sys

Check out any necessary licenses
arcpy.CheckOutExtension("Spatial")

Set the workspace environment
from arcpy import env
from arcpy.sa import *
env.workspace = "F:\Daten_Soner\CBD06\Test\NDVI\Spring\Extract"

从工作区中获取TIFFS列表并打印

rasterList = arcpy.ListRasters()

for raster in rasterList:
    print raster
    arcpy.CalculateStatistics_management(raster)

    # Process: Reclassify
    remap = RemapValue([-340282346638528860000000000000000000000,000000,2])  
    outReclassify = Reclassify(raster, "Value", remap , "NODATA")
    outReclassify.save(raster + "_re.tif")

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

当您只传递一个列表时,

RemapValue会获取一个列表列表([[oldValue, newValue],...])。