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 with Raster Objects

You've already seen that many of the raster functions return a "Raster Object" that you can store in a variable. You can also just load a raster into a new raster object and then access the raster's properties as below.

TheRaster = Raster("c:/Temp/Tiny.img") 


Then, you can perform mathematric operations on rasters. 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 ArcGIS.

# Mathematical operators
Result=Raster1 * Raster2 # mulitplication
Result=Raster1 / Raster2 # division
Result=Raster1 + Raster2 # addtion
Result=Raster1 - Raster2 # subtraction

# Boolean operations.  These operations produce pixels with a 1 (true) or 0 (false) value
Result=Raster1 | Raster2 # Boolean Or
Result=Raster1 & Raster2 # Boolean And

# comparison operators.   These operations produce pixels with a 1 (true) or 0 (false) value
Result=Raster1 == Raster2 # Equal to
Result=Raster1 != Raster2 # Not equal
Result=Raster1 > Raster2 # Greater than
Result=Raster1 >= Raster2 # Greater than or equal to
Result=Raster1 < Raster2 # Less than
Result=Raster1 <= Raster2 # Less than or equal to

Note: This was discovered by Kris in 318 in the Spring 2020 class

After you are done with the calculations, you can save the raster."C:/Temp/Output.img") 

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:"C:/Temp/FirstRaster.img","C:/Temp/SecondRaster.img")"C:/Temp/Result.img")

Raster Math Functions

Name Description
Arithmetic,InRasterOrContant) Add the two rasters together,InRasterOrContant) Subtract the second raster from the first,InRasterOrConstant) Multiply the first raster by the second,InRasterOrConstant) Divide the first raster by the second,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,InRasterOrConstant) Returns a raster with pixels set to 1,InRasterOrConstant),InRasterOrConstant),InRasterOrConstant),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,RasterOrConstant),RasterOrConstant) Performs a boolean "OR" on the two rasters,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


Working with operators in Map Algebra

© Copyright 2018 HSU - All rights reserved.