I want to create a new raster image which meet certain criteria from two underlying images.

I created a dummy raster with each pixel having value = 1.

Raster values are to be set to 0 if underlying pixel values for Raster_1 is between 100 to 110 and Raster_2 is 60 to 80.

I tried to do it with con but it gives a raster with garbage pixel values.

import arcpy

arcpy.gp.RasterCalculator_sa("""Con(("Raster_1.tif" < 1002) & ("Raster_1.tif" > 110) & ("Raster_2.tif" < 62) & ("Raster_2.tif" > 80) ,0)""","RasterOut.tif")

I wonder can I do it using something like `if-else' condition as we do in MATLAB for matrix operation

  • What about it didn't work? Did you get errors? Did it produce something unexpected? Did it do nothing at all? Please edit your question to provide more information. – Midavalo May 12 '17 at 13:48

This logic can equally be done very easily in model builder as shown below:


You don't need to do a reclassification the CON tool can achieve this. A CON tool would be set up as shown below:

Con tool parameters

| improve this answer | |

Use Boolean logic. Reclassify the first raster: 0 for all values in your range and 1 for the rest. Do the same for the second. Then use raster calculator and multiply together and the output will be 0 matching your parameters and 1 for everything else.



| improve this answer | |
  • Great, but in outReclass2 = Reclassify("slope_grd", "Value", RemapRange([[0,10,"NODATA"],[10,20,1],[20,30,2], [30,40,3],[40,50,4],[50,60,5],[60,75,6]])) in while remapping [10,20,1] 10 will be values including 10 and 20 will be remapped as 1 or remap will take place excluding 10 or 20 or both. – Mario May 13 '17 at 5:39

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.