Select to view content in your preferred language

Error: a.any or a.all

388
0
06-10-2010 12:20 PM
GregoryVerutes
New Contributor
Hi,

I am trying to run a model in ArcGIS based on some Python code I wrote.  Despite my best efforts, I keep getting the following error:
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The confusing part is that when I run it in Python it works fine, but through ArcGIS geoprocessor I get the error.

If anyone has some ideas on how to clean up my code and make it work in ArcGIS, it is most appreciated!

A snippet of my code is below:
#c_below_cur
c_below_curL1 = invest.convertRastertoArray(gp.workspace,'c_below_curL')[/INDENT]
c_below_curL = numpy.where(c_below_curL1 == -3.40282347e+38, 0, c_below_curL1)
c_below_curU1 = invest.convertRastertoArray(gp.workspace,'c_below_curU')
c_below_curU = numpy.where(c_below_curU1 == -3.40282347e+38, 0, c_below_curU1)
c_below_curRnd = []
randomBelowCurList = []
for x in range(len(c_below_curU)):
[INDENT]found = 'no'[/INDENT]
<--ERROR OCCURS HERE-->
[INDENT]if c_below_curU <> 0:[/INDENT]
[INDENT][INDENT]for z in range(len(randomBelowCurList)):[/INDENT][/INDENT]
[INDENT][INDENT][INDENT]if c_below_curU == randomBelowCurList:[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT][INDENT]found = 'yes'[/INDENT][/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT][INDENT]indexBelowCur = randomBelowCurList.index(c_below_curU) [/INDENT][/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT][INDENT]break[/INDENT][/INDENT][/INDENT][/INDENT]
[INDENT][INDENT]if found == 'yes':[/INDENT][/INDENT]
[INDENT][INDENT][INDENT]randBelowCur = randomBelowCurList[indexBelowCur+1][/INDENT][/INDENT][/INDENT]
[INDENT][INDENT]if found == 'no':[/INDENT][/INDENT]
[INDENT][INDENT][INDENT]randBelowCur = random.uniform(0, 1)[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT]randomBelowCurList.append(c_below_curU)[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT]randomBelowCurList.append(randBelowCur)[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT]tempCpj = (((c_below_curU - c_below_curL)*randBelowCur) + c_below_curL)[/INDENT][/INDENT]
[INDENT][INDENT]c_below_curRnd.append(tempCpj)  [/INDENT][/INDENT]            
         
c_below_curRSum = numpy.sum(c_below_curRnd, dtype=numpy.float64)
0 Kudos
0 Replies