In Raster Calculator I need to apply the next expression:

Con("raster1%","field3")==Integer, Lookup("%raster2%","field3"),Lookup("raster1%","field3"))

or more specifically:


The "%raster2%","field3" and "raster1%","field3" are categorical values so I need to get those values (form "%raster2%","field3" and "raster1%","field3") in the output raster cells. The problem is that the results is just one numerical field (no other fields with categorical).

I have already checked Specify a field in attribute table with raster calculator and the answer about the lookup tool has very promising but didn't work.


1 Answer 1


Assuming your "field3" columns are string/text format...

Your Lookup is working, but the text values are getting dropped in the Con output.

Another way to get your desired result is to use the Combine tool then Add Join and Calculate Field tools.

Below is the sequence (as python just to demonstrate, you'll probably need to run the tools manually to make sure all the parameters, especially the field calculator expression, are correct):

r3 = arcpy.sa.Combine("r1;r2")

arcpy.management.AddField("r3", "Field3", "TEXT", None, None, None, None, "NULLABLE", "NON_REQUIRED", None)    
arcpy.management.AddJoin("r3", "r1", "r1", "Value", "KEEP_ALL")
arcpy.management.AddJoin("r3", "r2", "r2", "Value", "KEEP_ALL")    
arcpy.management.CalculateField("r3", "VAT_r3.Field3", "!VAT_r1.Field3! if !VAT_r1.Value! == 8 else !VAT_r2.Field3!", "PYTHON3", None)

arcpy.management.RemoveJoin("r3", "VAT_r1")
arcpy.management.RemoveJoin("r3", "VAT_r2")

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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