Calculate Value Python Code

668
1
08-10-2011 01:53 AM
IbraheemKhan1
New Contributor III
Hi,

I want to run a set of if statements on raster layers using values but facing a tough time due to weak understanding with python. Following is what i've been using:

Input is from "iterate raster"

Expression: str(%Name%)
Code Block:
nt(1) = 0
nt(2) = 1.8
nb(1) = 1.8
nb(2) = 4.2
t(1) = 0
t(2) = 5
b(1) = 5
b(2) = 10

for l in nt(l):
  for k in nb(k):
def str(Name):
       if (t(l) <= nt(k)) & (b(l) >= nb(k)):
return:
            sum1 = %Name% * (nb(k) - nt(k))
elif:     (t(l) <= nt(k)) & (b(l) > nt(k)):
return:
            sum1 = sum1 + %Name% * (b(l) - nt(k))
elif:     (t(l) > nt(k)) & (b(l) < nb(k)):
return:
            sum1 = sum1+ %Name% * (b(l) - t(l))
elif:     (t(l) < nb(k)) & (b(l) >= nb(k)):
return:
            sum1 = sum1 + %Name% * (nb(k) - t(l))


Any help to make it work would be deeply appreciative. Thanks!
Tags (2)
0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor
Maybe you can describe what you're trying to do.
0 Kudos