# Aspect

Derives aspect from a raster surface. Aspect identifies the downslope direction of the maximum rate of change in value from each cell to its neighbors. Aspect can be thought of as the slope direction. The values of the output raster will be the compass direction of the aspect.

## Usage tips

Command line and Scripting

• Aspect is the direction of the maximum rate of change in the z-value from each cell in a raster surface.

• Aspect is expressed in positive degrees from 0 to 359.9, measured clockwise from north.

• Cells in the input raster of zero slope—for example, flat—are assigned an aspect of -1.

• If the center cell in the immediate neighborhood (3 x 3 window) is NoData, the output is NoData.

• If any neighborhood cells are NoData, they are assigned the value of the center cell; then the aspect is computed.

• The following environment settings affect this tool:

Map Algebra

• Aspect is expressed in positive degrees from 0 to 359.9, measured clockwise from north.

• Cells in the input raster of zero slope (flat) are assigned an aspect of -1.

• If the center cell in the immediate neighborhood (3 x 3 window) is NoData, the output is NoData.

• If any neighborhood cells are NoData, they are assigned the value of the center cell; then the aspect is computed.

ArcObjects

• Aspect is expressed in positive degrees from 0 to 359.9, measured clockwise from north.

• Cells in the input raster of zero slope (flat) are assigned an aspect of -1.

• If the center cell in the immediate neighborhood (3 x 3 window) is NoData, the output is NoData.

• If any neighborhood cells are NoData, they are assigned the value of the center cell; then the aspect is computed.

• Valid input for the geoDataset to ArcObjects is a Raster, RasterDataset, RasterBand, or RasterDescriptor.

• The output from the ArcObjects method is a raster object.

## Syntax

Aspect_sa (in_raster, out_raster)
Parameter Explanation Datatype
Input raster (Required)

Input raster.

Composite Geodataset
Output raster (Required)

The raster to be created.

Raster Dataset
Data types for geoprocessing tool parameters

Script Example

```# Aspect_sample.py
# Description:
#   Derives aspect from a raster surface.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005

# Import system modules
import arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

try:
# Set local variables
InRaster = "C:/data/dem"
OutRaster = "C:/data/aspect"

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

# Process: Aspect
gp.Aspect_sa(InRaster, OutRaster)

except:
# If an error occurred while running a tool, then print the messages.
print gp.GetMessages()

```

## Map Algebra syntax

Aspect(<grid>)

Parameter Explanation
<grid> Any valid combination of rasters, numbers, operators, and functions that produces an output raster.

### Map Algebra example

```aspect(ingrid)
aspect(ingrid) * 5
aspect(ingrid1 + ingrid2)
```

## ArcObjects syntax

ISurfaceOp::Aspect (geoDataset As IGeoDataset) As IGeoDataset

Parameter Explanation
geoDataset An input Raster, RasterDataset, RasterBand, or RasterDescriptor.

### ArcObjects example

```' Create the RasterSurfaceOp object
Dim pSurfaceOp As ISurfaceOp
Set pSurfaceOp = New RasterSurfaceOp

' Declare the input raster object
Dim pInputDataset As IGeoDataset

' Calls function to open a raster dataset from disk
Set pInputDataset = OpenRasterDataset ("D:\SpatialData", "inputraster")

' Declare the output raster object
Dim pOutputRaster As IGeoDataset

' Calls the method
Set pOutputRaster = pSurfaceOp.Aspect (pInputDataset)
```