

Con ('raster layer' < 0, SetNull ('raster layer'), 'raster layer') Specify the Output raster field.

The remainder of the cells maintain the original values. Bonus: Use the Iterate function to loop through. Con ('raster layer' < 0, 0, 'raster layer') The expression below changes all cells with a value of less than zero to NoData. (Optional) A logical expression that determines which of the input cells are to be true or false. I have two raster 'T' and 'N' which have values ranging from 0 to 1000. Video 33This video shows a simple demo of the Raster Calculator that comes with the ESRI Spatial Analyst extension. It can be an integer or a floating-point raster, or a constant value. Step four: double-click the tool and input your equations. The input whose values will be used as the output cell values if the condition is false.

Now the raster will display nothing in ArcMap where the cell value is 0,0,0. Step two: Search for 'Raster Calculator' in the search window (usually on the left side of the ArcMap Window) Step three: drag the tool into the model builder box. Use the Layers and variables list to select the datasets and variables to use in the expression. In ArcCatalog, right click on the layer and go to properties:Įnter the values then hit OK to dismiss the NoData editor and OK to enforce the change. You can run Con as a tool or in Raster Calculator. The Raster Calculator tool allows you to create and execute a Map Algebra expression that will output a raster.
#Arcmap raster calculator con pick setnull code
If you are using Python, your code should be adjusted to like this outSetNull SetNull('inRaster', 'inRaster', 'VALUE < 128') Try to avoid starting your variable name with number as Python doesnt accept starting variable names with numbers. If you are likely to have more bands (or less) in the same folder then you will have to use arcpy.Describe and the bandCount property to set the null for the correct number of bands: import sys, os, arcpyĪrcpy.SetRasterProperties_management(Ras,nodata="1 0 2 0 3 0 4 0")Īrcpy.SetRasterProperties_management(Ras,nodata="1 0") The above code can be run using Raster Calculator. In python it's a bit tricky: import sys, os, arcpyĪrcpy.SetRasterProperties_management(Ras,nodata="1 0 2 0 3 0")īecause the nodata is way down the list I find it easier to specify that the parameters are Band Value Band Value. This will not create a new raster or even take very long. If the fat table was output from the Combine tool, you may want to skip the Combine tool and do this instead using the five input rasters: Con ('RasterA' > 50, 'RasterA', Con ('RasterB. Start Time: Wednesday, 16 March 2022 18:28:46Ĭon(Raster(r"Presentation MCE: TWI\TWI") 0) & (Raster(r"Presentation MCE: TWI\TWI") = 1) & (Raster(r"Presentation MCE: TWI\TWI") = 2) & (Raster(r"Presentation MCE: TWI\TWI") = 3) & (Raster(r"Presentation MCE: TWI\TWI") = 4) & (Raster(r"Presentation MCE: TWI\TWI") = 5) & (Raster(r"Presentation MCE: TWI\TWI") = 6) & (Raster(r"Presentation MCE: TWI\TWI") = 7) & (Raster(r"Presentation MCE: TWI\TWI") = 8) & (Raster(r"Presentation MCE: TWI\TWI") = 9) & (Raster(r"Presentation MCE: TWI\TWI") =10, 1))ĮRROR 000539: Traceback (most recent call last):įile "", line 5, in rcexec_DC684390_0C54_4F14_9EBF_B34DF3F2E1B1įile "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\ Functions.py", line 1140, in BooleanAndįile "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\ Utils.py", line 55, in swapperįile "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\ Functions.What you want to do is Set Raster Properties in a script or change it manually in ArcCatalog. I agree with Lauren that working with Calculate Field in the raster table may be (much) more efficient, but Im wondering how you got such a 'fat' raster table. Map Algebra expression Con("Presentation MCE: TWI\TWI" 0) & ("Presentation MCE: TWI\TWI" = 1) & ("Presentation MCE: TWI\TWI" = 2) & ("Presentation MCE: TWI\TWI" = 3) & ("Presentation MCE: TWI\TWI" = 4) & ("Presentation MCE: TWI\TWI" = 5) & ("Presentation MCE: TWI\TWI" = 6) & ("Presentation MCE: TWI\TWI" = 7) & ("Presentation MCE: TWI\TWI" = 8) & ("Presentation MCE: TWI\TWI" = 9) & ("Presentation MCE: TWI\TWI" =10, 1)) Am I missing some paranthesis or something? I counted each Con to have the same number of paranthesises.
