0

I have multiple land cover rasters for each year (i.e. 2002, 2003, 2004...etc.) and each of them have five land cover classes. I would like to set up evaluation rules in ModelBuilder.

An example of a rule would be: can't have class 2 or 3 and then have class 1. To clarify, if 2002 had a value of 1, and 2003 had a value of 2, and then 2004 had 1 again, this would be flagged.

I tried the combine tool, to have all the years in one single raster, and then evaluate across the fields.

Is there a way to achieve the above scenario?

The important distinction here is that anytime a sequence like 1-2-1 or 1-3-1 occurs, no matter the years, I'd like to identify it.

  • Combine is your tool. You tried and what happened? – FelixIP Mar 20 '17 at 19:07
  • How do you go about doing a conditional on the value of the combine? – mystery-manatee Mar 20 '17 at 19:53
0

Add field, type integer to attribute table of your combined raster and run this field calculator expression on it:

def findOnes(aList):
 n=len(aList); found=0
 for i in range(1,n-1):
  mid=aList[i]
  if mid==1:continue
  left=aList[i-1]
  if left!=1:continue
  right=aList[i+1]
  if right!=1:continue
  found=1;break
 return found
#---------------------
findOnes([ !ONE_A!, !ONE_B!, !ONE_C!, !ONE_D!, !ONE_E!])

You can use extract by attributes tool from Spatial Analyst, to create new raster:

enter image description here

  • Hi FelixIP, your solution was most helpful! It worked beautifully. I was wondering if there is a way to indicate which position this change occurred? Taking an example from your table, the first record flagged, is there a way to return "3" since it happened in "one_c", the third year in this sequence? – mystery-manatee Mar 21 '17 at 14:24
  • Replace found=0 by -1, found =1 by found=i+1 – FelixIP Mar 21 '17 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.