I want to check if a NumPyArray has values in it that are in a set, and if so set that area in an array = 1. If not set a keepRaster = 2.
numpyArray = #some
Here is one possible way of doing what you whant:
numpyArray = np.array([1, 8, 35, 343, 23, 3, 8]) # could be n-Dimensional array repeatSet = np.array([3, 5, 6, 8]) mask = (numpyArray[...,None] == repeatSet[None,...]).any(axis=-1) print mask >>> [False True False False False True True]