尝试从一组栅格中提取点的值时获取错误

时间:2016-04-20 08:41:12

标签: python

获取错误“当尝试从一组栅格中提取点的值时,列表索引必须是整数,而不是元组:

def defineIndexAllPoints(inputPoints, inputRaster, indexName):
    #Define file of points:    
    desc = arcpy.Describe(inputPoints)
    shapefieldname = desc.ShapeFieldName*

    #Define set of rasters"
    rstArray  = [arcpy.RasterToNumPyArray(arcpy.Describe(ras).catalogPath) for ras in arcpy.ListRasters()] 

    #This code was help from this  web site
    ulx = desc.Extent.XMin
    uly = desc.Extent.YMax

    with arcpy.da.UpdateCursor(infc,["SHAPE@", indexName]) as uc: #"value - will be different Indexes for  different  Data Set Images:"
        for row in uc:
            pnt = row[0].projectAs(sr)
    #assuming every point falls to the left and below uperleft corner
            deltaX = pnt.centroid.X - ulx
            deltaY = uly- pnt.centroid.Y
            arow = int(deltaY/rastr.meanCellHeight)
            acol = int(deltaX/rastr.meanCellWidth)
            row[1] = rstArray[arow,acol]
            uc.updateRow(row)

env.workspace = r"C:\Users\1_fire_RdNBR" 
inputPoints = r"C:\Users\select1.shp"     

defineIndexAllPoints(inputPoints, env.workspace, "dNBR_1")   

我认为inputRaster有问题 - 但是rstArray - 只是问一下.catalogPath。  如何解决?

我只想问这个函数转换1个Numpy数组中的栅格列表还是不?

0 个答案:

没有答案