Frequently asked question

Why must arcpy.sa functions be assigned to a variable?

Last Published: April 26, 2020

Answer

The arcpy.sa functions are temporary, therefore, the arcpy.sa function must be assigned to a variable. Otherwise, the output does not persist, and is unusable in scripts.

A variable holds references to data. In this example, the raster object created with an arcpy.sa function is stored in a variable named Solar.


Code:
import arcpy;
from arcpy.sa import *;

arcpy.CheckoutExtension ("Spatial"); #Code used to check the extension in ArcMap

Solar = arcpy.sa.AreaSolarRadiation (inRaster, latitude, time);
# the code segment uses the arcpy.sa



The output raster is temporary by default. Due to the volatile nature of the output raster, it must be assigned to a variable to retain the output raster value.

Article ID:000012410

Software:
  • ArcMap

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options