Snap Raster (Environment setting)

Tools that honor the Snap Raster environment will adjust the extent of output rasters so that they match the cell alignment of the specified snap raster.

A Snap Raster is typically used where inputs to tools:

Learn more about how Snap Raster works

Usage notes

Dialog syntax

Snap Raster—Sets a raster that is used to define the cell alignment of an output raster.

Scripting syntax

arcpy.env.snapRaster = raster

Parameter

Explanation

raster

The raster to be used as the snap raster.

snapRaster syntax

Script example

This example demonstrates how to set the snap raster environment before executing a ArcGIS Spatial Analyst extension tool.

import arcpy

# Set workspace and extent environments
arcpy.env.workspace = "C:/workspace"
arcpy.env.extent = "C:/data/studyArea"

# Set Snap Raster environment
arcpy.env.snapRaster = "C:/data/my_snapraster"

# Set local variables
InZones = "C:/data/parcels.shp"
InZoneField = "Parcel_ID"
InValueRaster = "C:/data/Slope"

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

# Process: Calculate the mean slope of each parcel area.
out = arcpy.sa.ZonalStatistics(InZones, InZoneField, InValueRaster, "MEAN","DATA")
out.save("mean_ParSlp")

Related Topics

3/3/2014