Reputation: 701
I am attempting to create a raster based on input from another raster. If a raster value is equal to a number included in a set() than I want it to be 1, else 0
I've attempted the following:
ConfusedRaster = arcpy.Con(inraster in repeatSet, 1, 0)
and
ConfusedRaster = arcpy.Con(inraster, 1, 0, "inraster in repeatSet")
Neither of these work. I believe they don't work because the where clause only accepts Map Algebra expressions: ArcGIS Help
There are two other ways I can think of doing this. One being converting it to a NumPyArray and working with that. The other is looping through the set and creating a raster object for each value in the set. After the loop has finished merge them.
Does anyone have any suggestions or comments on how to go about this?
Thank you
Upvotes: 4
Views: 1705
Reputation: 4613
I was searching for an answer to the similar issue and developed a way using the SQL clause in 'ExtractByAttributes'.
repeatList = list(repeatSet)
ras1 = arcpy.sa.ExtractByAttributes(inraster, 'VALUE IN (' + str(repeatList).strip('[]') + ')')
ConfusedRaster = arcpy.sa.Con(arcpy.sa.IsNull(ras1) == 0, 1, 0)
Upvotes: 1