laptop and a wrench

Bug

Unable to apply the Mask environment setting when running the Raster Calculator tool using ArcPy.

ArcGIS Pro
Bug ID Number BUG-000160654
SubmittedAugust 15, 2023
Last ModifiedJune 5, 2024
Applies toArcGIS Pro
Version found2.9
Operating SystemN/A
Operating System VersionN/A
StatusWill Not Be Addressed

Additional Information

The Raster Calculator tool is not intended for use in Python. The Raster Calculator tool is used to perform Map Algebra using Python in the User Interface, ie ModelBuilder. Map Algebra in Python can be performed natively. Map Algebra does not need to be wrapped inside a geoprocessing tool like the Raster Calculator tool. Perform Map Algebra like this: from arcpy.sa import * arcpy.env.mask ="C:\\temp\\BUG-000160654\\repro\\ManalData\\blkgrp.shp" ras1 = arcpy.Raster('usgsdem') ras2 = arcpy.Raster('gfchot') myras = ras1*ras2

Workaround

The Raster Calculator tool is not intended for use in Python. The Raster Calculator tool is used to perform Map Algebra using Python in the User Interface, ie ModelBuilder. Map Algebra in Python can be performed natively. Map Algebra does not need to be wrapped inside a geoprocessing tool like the Raster Calculator tool.

Perform Map Algebra like this:

from arcpy.sa import *

arcpy.env.mask ="C:\\temp\\BUG-000160654\\repro\\ManalData\\blkgrp.shp"

ras1 = arcpy.Raster('usgsdem')

ras2 = arcpy.Raster('gfchot')

myras = ras1*ras2

Steps to Reproduce

Bug ID: BUG-000160654

Software:

  • ArcGIS Pro

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options