Slope and aspect are terrain characteristics derived from elevation. Slope describes the terrain’s steepness. Aspect describes the direction the downhill slope faces. Both are derived from elevation differences among neighboring cells, so their results depend on surrounding elevation values and the input raster’s resolution. Together, they can help identify terrain that meets criteria for uses such as agriculture, route planning, or site assessment.

Animated slope and aspect results for the same terrain on the Isle of Arran, Scotland.

Both operations are methods on ContinuousFieldFunction. They compose new field functions, so you can combine their results with other map algebra operations before evaluating the final result.

Slope

Slope measures terrain steepness in degrees from 0 (flat) to 90 (vertical). The slope at each point is derived from elevation change between nearby points, so the result depends on surrounding elevation values and the resolution of the original raster data set being analyzed.

Slope is expressed in degrees, but it can also be expressed in percent rise using map algebra. To calculate percent rise from a slope field, multiply the slope values by pi / 180 to convert degrees to radians, apply tangent, and multiply by 100: percent rise = 100 * tan(slope * pi / 180). This creates a new field function that applies the conversion to each slope value when evaluated. For example, a 45-degree slope has a 100 percent rise.

Aspect

Aspect identifies the compass direction that the downhill slope faces. Aspect is measured in degrees from 0 up to, but not including, 360, clockwise from the positive Y axis. On a north-aligned grid, 0, 90, 180, and 270 indicate grid north, east, south, and west. These directions are relative to the grid and are not necessarily true-north bearings. Flat terrain has an aspect of -1.

Because aspect is circular, a range that crosses north must be expressed as two ranges joined with a logical OR. For example, to select directions from 350 through 10 degrees, select aspect values greater than or equal to 350, or values greater than or equal to 0 and less than or equal to 10. Include the lower bound of 0 in the second range so flat terrain (-1) is not selected.

Prepare elevation data

Although ContinuousFieldFunction can represent any continuous measurement, this topic focuses on deriving slope and aspect from elevation. Slope can also help identify sharp spatial changes in other continuous data. For example, applying slope to temperature data could highlight transition zones between warmer urban surfaces and cooler surrounding areas. For non-elevation data, interpret the results in the context of the input values and their scaling relative to horizontal distance, rather than as terrain steepness.

Slope and aspect require a shape-preserving (conformal) projected coordinate system. Geographic and Web Mercator spatial references are not supported by the API; attempting slope or aspect analysis with either throws an exception. Choose a suitable local conformal projection with low distortion across the elevation extent. For terrain analysis, elevation units must match the horizontal units of the projected coordinate system; convert the elevation values if necessary.

When selecting terrain by compass direction, account for the difference between grid north and true north. Aspect angles are measured clockwise from the projected coordinate system’s positive Y axis.

Prepare the input elevation data in the required spatial reference before analysis. When creating a continuous field from raster files, ContinuousField.createFromFiles() can project the raster content into a specified spatial reference. This changes the horizontal coordinates, not the elevation values. Changing only the map or view’s spatial reference does not reproject the analysis field.

Make sure the elevation data covers the area of interest and check for NoData gaps. NoData input locations remain NoData in the result. Since slope and aspect use neighboring elevation values, gaps can also limit where valid results are produced.

Example

Identify terrain that meets suitability criteria

For example, identify terrain that meets all of the following criteria:

  • South-facing, with aspect from 160 through 200 degrees.
  • Slope no greater than 35 degrees.
  • Elevation at or above sea level.

Excluding cells below sea level is not a general water mask. When distinguishing land and water matters, use categorical land-cover data.

This example uses an elevation raster dataset that meets the requirements described in Prepare elevation data. Ensure it is prepared in a suitable conformal projected spatial reference with matching horizontal and elevation units.

  1. Load the raster into a ContinuousField using a suitable conformal projected spatial reference. In this example, the continuous field and map use WGS 84 / UTM zone 30N (WKID 32630), matching the raster’s coordinate system.

  2. Create a ContinuousFieldFunction from the elevation field, then derive named slope and aspect functions from the unmasked elevation. Combine any exclusion criteria afterward; masking the elevation field first can remove neighboring values needed to derive gradients.

  3. Both slope and aspect produce continuous field functions. Display slope using a stretch renderer and color ramp. For aspect, use map algebra to group angles into categories, then convert the result to a discrete field function and assign each category a color using a color map. Keep flat terrain in a separate category. Display the results in separate field analysis objects.

  4. Define which terrain meets the suitability criteria. Use the continuous slope and aspect functions to create Boolean criteria for south-facing terrain with aspect from 160 through 200 degrees and slope of 35 degrees or less. For this example, also exclude cells below sea level; this is not a general water mask.

  5. Combine the Boolean criteria with logical AND and display the suitability result with distinct colors for matching and nonmatching cells. NoData remains transparent.

  6. Optionally, save the suitability result as GeoTIFF raster files for later use. Evaluate the final suitability function, then export the resulting field. Intermediate functions do not need to be evaluated or exported separately.

Display and export results

Add a FieldAnalysis to an AnalysisOverlay to display a composed function dynamically. The field analysis evaluates the function for display, so you do not need to call BooleanFieldFunction.evaluate() unless you need a persistent result.

Choose a renderer that makes each result easy to interpret:

  • Display slope as a continuous field with a stretch renderer and a meaningful range, such as 0 to 90 degrees.
  • Display aspect in directional categories as a discrete field, with a distinct category for flat terrain (aspect -1). Since aspect wraps at 360 degrees, a continuous stretch can make directions near north appear far apart.
  • Display suitability with different colors for true and false. Keep false areas visually distinct from NoData, which is transparent.

Threshold values are part of the composed expression, not settings on a parameter object. To change them, rebuild the criteria and combined function, then create a new FieldAnalysis for the updated result.

To save the suitability result as GeoTIFF files, call BooleanFieldFunction.evaluate() on the final function, then call BooleanField.exportToFiles() on the resulting field. See Export analysis results for details.

Interpret results and limitations

Slope and aspect are derived from local elevation differences, so noise or artifacts in the elevation data can create misleading gradients or direction changes. Raster resolution also affects which terrain features are represented; see Slope and Prepare elevation data.

Locations with NoData in the input also have NoData in the result. The result’s extent equals the input function’s extent. The output extent does not mean that every position in the output field contains a valid result. Since the calculations use neighboring elevation values, NoData gaps and dataset edges can limit the neighborhood available for a result. These methods do not expose a setting to change the neighborhood size. A false suitability value is a valid result that did not meet the criteria; it is distinct from NoData.