How to Compare feature class in Model Builder?

642
1
10-29-2016 05:46 AM
Highlighted
New Contributor

HI, I'm trying  to compare the feature classe in 2 geodatabase, and make an APPEND if the name is the same. I'm trying with WHILE but not work correct. How can I do it?

Reply
0 Kudos
1 Reply
Highlighted
MVP Esteemed Contributor

If then is tricky with ModelBuilder.

I think the most straightforward way to do this is to do the compare with a Python function inside a Calculate Value tool. Have your function return 1 or 0 and make the returned value a precondition to your append operation.

expression

test_same(r"%Featureclass1%", r"%Featureclass2%")

code block

def test_same(fc1, fc2):
  nm1 = arcpy.Describe(fc1).name.lower()
  nm2 = arcpy.Describe(fc2).name.lower()
  if nm1 == nm2:
    return 1
  else:
    return 0