Skip To Content

Create Constant Raster

Available with Spatial Analyst license.


Creates a raster of a constant value within the extent and cell size of the analysis window.


Create Constant raster illustration
OutRas = CreateConstantRaster(2)


  • The Create Constant Raster tool assigns the specified value to every cell in the output raster.

  • The constant value must be a numeric value. Scientific notation is acceptable (for example, 3.048e-4 for 0.003048).

  • The Output cell size parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn’t been explicitly specified as the parameter value, it is derived from the Cell Size environment if it has been specified. If the parameter cell size or the environment cell size has not been specified, but the Snap Raster environment has been set, the cell size of the snap raster is used. If nothing is specified, the cell size is 1.

  • If the cell size is specified using a numeric value, the tool will use it directly for the output raster.

    If the cell size is specified using a raster dataset, the parameter will show the path of the raster dataset instead of the cell size value. The cell size of that raster dataset will be used directly in the analysis, provided the spatial reference of the dataset is the same as the output spatial reference. If the spatial reference of the dataset is different than the output spatial reference, it will be projected based on the selected Cell Size Projection Method.

  • Since the tool does not have any input, the output spatial reference is derived from other settings in a particular order. First, the Output Coordinate System environment will be used, if specified, followed by the coordinate system of the map view. If neither of these conditions are met, the output spatial reference will be set to Unknown.

  • Based on the cell size, the default output extent is computed to create a raster of 250 rows and 250 columns. Thus, for the default cell size of 1, the Output extent is (0, 0, 250, 250). The extent value is adjusted based on the Cell Size, Snap Raster, and Output Coordinate System environments, if specified.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.


CreateConstantRaster (constant_value, {data_type}, {cell_size}, {extent})
ParameterExplanationData Type

The constant value with which to populate all the cells in the output raster.


Data type of the output raster dataset.

  • INTEGERAn integer raster will be created.
  • FLOATA floating-point raster will be created.

If the specified data type is Float, the values of the cells in the output raster will only be accurate to the constant value of 7 decimal places, regardless of the output format.


The cell size of the output raster that will be created.

This parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn't been explicitly specified as the parameter value, the environment cell size value will be used if specified; otherwise, additional rules will be used to calculate it from the other inputs. See the usage for more detail.

Analysis Cell Size

The extent for the output raster dataset.

The Extent is a Python class.

In this tool, it is in the form Extent(XMin, YMin, XMax, YMax)

  • where XMin and YMin define the lower left coordinate of the extent, and XMax and YMax define the upper right coordinate.

The coordinates are specified in the same map units as the Output Coordinate System environment setting.

The extent will be the value in the environment if specifically set. If not specifically set, the default is 0, 0, 250, 250.


Return Value

NameExplanationData Type

The output raster for which each cell will have the specified constant value.


Code sample

CreateConstantRaster example 1 (Python window)

This sample creates a float raster of a particular value at the defined cell size and extent.

import arcpy
from arcpy import env
from import *
env.workspace = "C:/sapyexamples/data"
outConstRaster = CreateConstantRaster(12.7, "FLOAT", 2, Extent(0, 0, 250, 250))"C:/sapyexamples/output/outconst2")
CreateConstantRaster example 2 (stand-alone script)

This sample creates an integer raster of a particular value at the defined cell size and extent.

# Name:
# Description: Creates a raster from a constant value
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from import *

# Set local variables
constantValue = 12
cellSize = 2
outExtent = Extent(0, 0, 250, 250)

# Execute CreateConstantRaster
outConstRaster = CreateConstantRaster(constantValue, "FLOAT", cellSize,

# Save the output"C:/sapyexamples/output/outconst")

Licensing information

  • Basic: Requires Spatial Analyst
  • Standard: Requires Spatial Analyst
  • Advanced: Requires Spatial Analyst

Related topics