ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Create Constant Raster

Available with Spatial Analyst license.

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code Sample
  • Environments
  • Licensing Information

Summary

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

Illustration

Create Constant raster illustration
OutRas = CreateConstantRaster(2)

Usage

  • 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).

  • Some typical reasons for creating a raster of all the same values include the following:

    • A Mask environment has been set and you want a raster identifying all unmasked cells to use in a variety of other tools (for example, as a condition raster in the Con tool).
    • You want all the values in an output raster from a mask or some selection process to be classified as a single value.
    • You want to apply a constant value in an analysis to all cell locations in another raster—for example, you want to add five decibels to each location in a noise pollution raster.
  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Syntax

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

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

Double
data_type
(Optional)

Data type of the output raster dataset.

  • INTEGER — An integer raster will be created.
  • FLOAT — A 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.

String
cell_size
(Optional)

The cell size for the output raster dataset.

This is the value in the environment if specifically set. If not specifically set, it is the shorter of the width or height of the environment extent in the output spatial reference, divided by 250.

Analysis Cell Size
extent
(Optional)

The extent for the output raster dataset.

The Extent is a Python class.

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

  • where XMin and YMin define the lower left coordinate of the extent, with XMax and YMax defining 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.

Extent

Return Value

NameExplanationData Type
out_raster

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

Raster

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 arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outConstRaster = CreateConstantRaster(12.7, "FLOAT", 2, Extent(0, 0, 250, 250))
outConstRaster.save("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: CreateConstantRaster_Ex_02.py
# Description: Creates a raster from a constant value
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy.sa import *

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

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

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

# Save the output 
outConstRaster.save("C:/sapyexamples/output/outconst")

Environments

  • Auto Commit
  • Cell Size
  • Compression
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Mask
  • Output CONFIG Keyword
  • Output Coordinate System
  • Raster Statistics
  • Scratch Workspace
  • Snap Raster
  • Tile Size

Licensing Information

  • ArcGIS for Desktop Basic: Requires Spatial Analyst
  • ArcGIS for Desktop Standard: Requires Spatial Analyst
  • ArcGIS for Desktop Advanced: Requires Spatial Analyst

Related Topics

  • An overview of the Raster Creation toolset
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal