Masthead

Additional ArcGIS Pro Functions

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. However, there are a huge number of functions available. Sometimes you just have to do things differently than you might first expect. For example:

Below are some of the functions I use with ArcGIS Pro. Reference Esri's online information for more details and examples.

Raster Math

The functions below perform "math" on rasters. 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.

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. The output raster can then be saved to a file as:

OutRaster=arcpy.sa.Plus("C:/Temp/FirstRaster.img","C:/Temp/SecondRaster.img")
OutRaster.save("C:/Temp/Result.img")

Raster Math Functions

Name Description
Arithmetic  
arcpy.sa.Plus(InRasterOrConstant,InRasterOrContant) Add the two rasters together
arcpy.sa.Minus(InRasterOrConstant,InRasterOrContant) Subtract the second raster from the first
arcpy.sa.Times(InRasterOrConstant,InRasterOrConstant) Multiply the first raster by the second
arcpy.sa.Divide(InRasterOrConstant,InRasterOrConstant) Divide the first raster by the second
arcpy.sa.FloatDivide(InRasterOrConstant,InRasterOrContant) Divides the first raster by the second (not sure when this is needed, for floating-point rasters?)

Conditional Operations

These functions return a boolean raster based on a comparison between two other rasters.

Name Description
arcpy.sa.EqualTo(InRasterOrContsant,InRasterOrConstant) Returns a raster with pixels set to 1
arcpy.sa.GreaterThan(InRasterOrContsant,InRasterOrConstant)  
arcpy.sa.GreaterThanEqual(InRasterOrContsant,InRasterOrConstant)  
arcpy.sa.LessThan(InRasterOrContsant,InRasterOrConstant)  
arcpy.sa.LessThanEqual(InRasterOrContsant,InRasterOrConstant)  

Boolean Operations

These operations work with rasters that have pixels set to 0 ("false") or 1 ("true"). These are also known as "bit masks" or "boolean rasters" and can be used to manipulate areas within a raster.

Name Description
arcpy.sa.BooleanAnd(RasterOrConstant,RasterOrConstant)  
arcpy.sa.BooleanNot(InRaster)  
arcpy.sa.BooleanOr(RasterOrConstant,RasterOrConstant) Performs a boolean "OR" on the two rasters
arcpy.sa.Con(ConditiontalRaster,InTrueRaster,InFalseRaster) Performance a conditional operation. The resulting raster will have values from the "true" raster where the pixels in the ConditionalRaster are true and values from the "false" raster where pixels in the Conditional raster are false.

 

Other Raster Operations

Vector Operations

© Copyright 2018 HSU - All rights reserved.