Arcmap raster calculator con pick setnull10/11/2023 NameĪrcpy.sa.BooleanAnd(RasterOrConstant,RasterOrConstant)Īrcpy.sa.BooleanOr(RasterOrConstant,RasterOrConstant) These are also known as "bit masks" or "boolean rasters" and can be used to manipulate areas within a raster. These operations work with rasters that have pixels set to 0 ("false") or 1 ("true"). NameĪrcpy.sa.EqualTo(InRasterOrContsant,InRasterOrConstant)Īrcpy.sa.GreaterThan(InRasterOrContsant,InRasterOrConstant)Īrcpy.sa.GreaterThanEqual(InRasterOrContsant,InRasterOrConstant)Īrcpy.sa.LessThan(InRasterOrContsant,InRasterOrConstant)Īrcpy.sa.LessThanEqual(InRasterOrContsant,InRasterOrConstant) These functions return a boolean raster based on a comparison between two other rasters. Subtract the second raster from the firstĪrcpy.sa.Times(InRasterOrConstant,InRasterOrConstant)Īrcpy.sa.Divide(InRasterOrConstant,InRasterOrConstant)Īrcpy.sa.FloatDivide(InRasterOrConstant,InRasterOrContant)ĭivides the first raster by the second (not sure when this is needed, for floating-point rasters?) The output raster can then be saved to a file as: OutRaster=arcpy.sa.Plus("C:/Temp/FirstRaster.img","C:/Temp/SecondRaster.img")Īrcpy.sa.Plus(InRasterOrConstant,InRasterOrContant)Īrcpy.sa.Minus(InRasterOrConstant,InRasterOrContant) You can pass in a file path, name of a raster in the workspace (after workspace is set), or a current raster for the input raster in these functions. In other words, if you multiple two rasters together, each pixel will be the result of multiplying the pixel from the first raster that is in the same location as the resulting pixel with a pixel in the second rasters that is also in the same spatial location. The functions below perform "math" on rasters. Raster1.save("C:/Temp/Output.img") Raster Math Note: This was discovered by Kris in 318 in the Spring 2020 classĪfter you are done with the calculations, you can save the raster. Result=Raster1 <= Raster2 # Less than or equal to Result=Raster1 >= Raster2 # Greater than or equal to These operations produce pixels with a 1 (true) or 0 (false) value Result=Raster1 * Raster2 # mulitplication The result will be a new raster where the opeation is applied to each matching pixel in the two rasters, just as with Raster Calculator in ArcMap. Then, you can perform mathematric operations on rasters. You can also just load a raster into a new raster object and then access the raster's properties as below. You've already seen that many of the raster functions return a "Raster Object" that you can store in a variable. Reference Esri's online information for more details and examples. You just need to make one call for each element of your equation.īelow are some of the functions I use with ArcGIS Pro. However, all the Raster calculator functions (Add, Subtract, etc.) are available. Raster calculator is not available from Python outside of ArcGIS.Sometimes you just have to do things differently than you might first expect. However, there are a huge number of functions available. More information on conditional statements is available here.Sometimes it can be a challenge to find the right ArcGIS Pro functions and not everything you're familiar with the ArcGIS interface is readily available in Python. You could just use the reclassify tool to convert the null values to 0 before running the raster calculator, but that's an extra step. This works for ArcGIS Desktop 10.5 and you probably need the Spatial Analyst extension to be able to use the Raster Calculator. So, if you want to sum two raster layers with null values and want to substitute zeros for the nulls, do this:Ĭon(IsNull("raster_layer_1"), 0, "raster_layer_1") +Ĭon(IsNull("raster_layer_2"), 0, "raster_layer_2") The way around this is to use a conditional statement.Ĭon( condition, value if true, value if false )įor example, to check if a cell value is null and reassign that cell value to zero if it is null:Ĭon(isNull("raster_layer"), 0, "raster_layer") If one of the rasters has a cell with a null value, then when that cell is added to values from other cells it still equals null. I got stuck adding together multiple raster layers with null values in ArcMap. The Raster Calculator can do a lot, but the documentation is pretty scarce.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |