Aspect Transformation
Summary
Generates one or more transformations of an aspect raster at once: directional reclassifications, in which each cell is assigned a named direction class written to a Class attribute table, and trigonometric transforms, which turn the circular aspect angle into a continuous number that statistics and habitat models can use: northness, eastness, and the deviation from a chosen compass bearing. Built for aspect, it also accepts D-infinity flow-direction rasters, and it requires no Spatial Analyst.
Why transform aspect at all
Aspect, the compass direction a slope faces, is circular: 359° and 1° are neighbors, not opposites, so the raw angle cannot go into a regression, a mean, or a suitability score as it stands. It becomes more useful for traditional statistical analyses once it is either grouped into a few named classes or converted to a linear number. This tool offers both, and can write several transformations in a single run, each as its own raster in the chosen output location, named from a base name plus a suffix.
Because the tool makes up the names, it never overwrites an existing raster, whatever the geoprocessing overwrite setting. If a name is already taken in the output location, the new raster gets a number added instead: a second run with the base name Grand_Canyon writes Grand_Canyon_NS_2, a third Grand_Canyon_NS_3, and so on, leaving the earlier rasters in place. To replace an earlier result, delete it first, or give the new run a different base name.
Every output arrives in the map already symbolized: each reclassification with a unique-values color scheme keyed to its class names (the eight directions in the colors of the aspect color wheel, Flat in pale tan), and each continuous raster with a diverging blue–white–red stretch. The scheme is also saved as a layer file beside each raster, so it can be reapplied later.
Reclassifications produce integer rasters with a Class attribute table. The classes are numbered 1 upward in the order listed (North = 1, South = 2, and so on; in the eight-direction raster North = 1 through Northwest = 8), the name of each is in the table's Class field, and flat cells, when kept, are the class −1, named Flat:
- North / South. North for cells with a northward component (cosine of aspect at or above 0), South otherwise. Cells facing exactly east or west go to North.
- East / West. East for cells with an eastward component (sine of aspect at or above 0), West otherwise. Cells facing exactly north or south go to East.
- North / East / South / West. 90-degree classes centered on the cardinal directions: North 315–45, East 45–135, South 135–225, West 225–315.
- Eight directions. 45-degree classes centered on the eight cardinal and intercardinal directions.
Trigonometric transforms produce continuous double-precision rasters:
- Northness, the cosine of the aspect: 1 due north, 0 due east or west, −1 due south.
- Eastness, the sine of the aspect: 1 due east, 0 due north or south, −1 due west. Northness and eastness together decompose aspect into its north–south and east–west components.
- Trigonometric deviation from a bearing, the cosine of the difference between the aspect and a target bearing: 1 facing exactly the bearing, 0 at 90° from it, −1 facing directly away.
- Numeric deviation from a bearing, simply the angular difference in degrees between the aspect and the target bearing, from 0 (facing the bearing) to 180 (facing directly away); the same transform the Polar Plots extension for ArcMap offered (Jenness 2014). The Polar Plots tool in this add-in draws the distribution of an aspect raster's directions, before or after a transformation.
One difference between the two kinds of trigonometric transform matters for statistics. The numeric deviation keeps a constant interval: a change of one degree means the same thing at 5° as at 175°. Sines and cosines do not. Jenness (2012) gives the figures: a one-degree change in direction moves the sine by about 0.00015 near 90° but by about 0.017 near 180°, more than a hundred times as much. That is harmless for a habitat score and for most models, but it matters for a method that assumes its predictors are interval-level, in which case the numeric deviation transform is the safer choice.
Both numeric and trigonometric deviation transforms follow the approach Trimble and Weitzman (1956) introduced for site-productivity research, whose original transform gave its maximum to the northeast because that is where the best upland oaks grew, and which Beers, Dress and Wensel (1966) generalized to any optimum bearing. The target bearing therefore defaults to 45° and can be set to whatever direction is most meaningful for your study. The Normalize Existing HSM page turns a numeric deviation from 45° into a 0–100 habitat factor as its worked example.
Flat cells (aspect −1) have no direction. The trigonometric transforms always write them as NoData, because −1 would be indistinguishable from a real value there. For the reclassifications, the Flat cells option decides whether they get their own Flat class (value −1) or are dropped to NoData.
D-infinity flow direction. A D-infinity flow-direction raster is essentially an aspect raster, the direction of steepest descent, but in the mathematical convention (0 = east, counter-clockwise) rather than compass. Set the input convention to Mathematical and the tool converts to compass before every transformation; it suggests this automatically when it detects a D-infinity raster, and warns when a raster's values fall outside the aspect range, which usually means the input is not aspect at all. A standard D8 flow-direction raster stores flow codes 1 to 128, not degrees, and is not valid input.
A tour of the dialog
The tool holds the whole raster in memory at once, so the memory it needs grows with the number of cells. On most rasters that is no concern. On a very large one the tool may need more memory than your computer has free, and then one of two things happens: Windows starts using the disk as overflow memory and the tool slows to a crawl, or the tool stops with an out-of-memory error. There is no fixed limit; it depends on how much memory your computer has free. If a raster is too large, clip it to the area you need first.
ModelBuilder
Every raster the run writes comes out of the tool twice in a model. Output rasters holds all of them as one list, which suits a tool that takes several rasters at once, such as Composite Bands or Cell Statistics. Each transformation also has an output of its own, from North / South raster through Numeric deviation raster, so a model can connect a single transformation, such as the northness raster, directly to the next tool. The outputs for transformations that were not chosen stay empty.
Parameters
| Label | Explanation | Data type |
|---|---|---|
| Input aspect raster (single band)Required · in_raster | A single-band aspect raster in degrees, 0–360 clockwise from north, with −1 for flat cells. A D-infinity flow-direction raster is also valid; set the input convention to Mathematical for it. | Raster Layer |
| TransformationsRequired · transformations | One or more transformations to generate, each written
as its own raster: the four reclassifications and the four
trigonometric transforms described above. In a script the
option strings are exactly Reclassify: North /
South, Reclassify: East / West,
Reclassify: North / East / South / West,
Reclassify: 8 directions (N / NE / E / SE / S / SW / W /
NW), Northness (cosine of aspect; 1 = north, -1 =
south), Eastness (sine of aspect; 1 = east, -1 =
west), Trigonometric deviation from a bearing (1
= toward, -1 = away) and Numeric deviation from a
bearing (degrees, 0 - 180). The dialog remembers the
last selection, the target bearing and the flat-cells
choice. |
Multiple Value |
| Output location (folder or geodatabase)Required · out_workspace | The folder or geodatabase the output rasters are written to. Defaults to the input raster's workspace. | Workspace |
| Output base nameOptional · base_name | The base name for the outputs; each transformation
adds a suffix (_NS, _8Dir,
_Northness, _TrigDev45, and so
on). Defaults to the input raster's name. Names are made
valid for the output location, and an existing raster is
never overwritten: if a name is taken, a number is added to
the new one (_NS_2, _NS_3, and so
on). |
String |
| Target bearing (deg, for the deviation transforms)Optional · target_bearing | The reference bearing, 0–360°, for the two deviation transforms: the direction that scores 1 (trigonometric) or 0 (numeric). Default 45°, northeast, the optimum in Trimble and Weitzman's oak study. Used only when a deviation transform is selected. | Double |
| Input aspect conventionRequired · input_convention | Compass (0 = north, clockwise) for an ordinary aspect raster; Mathematical (0 = east, counter-clockwise) for a D-infinity flow-direction raster. | String |
| Flat cellsRequired · flat_handling | For the reclassifications: keep flat cells as their own
Flat class (value −1) or drop them to NoData. The
trigonometric transforms always write flat cells as NoData.
The two options are Reclassifications keep a Flat class
(trig transforms are NoData at flat cells) and
All transforms: flat cells -> NoData; the
default is the second. |
String |
| Output rastersDerived · out_rasters | Every raster written, as one list, for a tool that takes several rasters at once. | Raster Dataset |
| North / South raster, East / West raster, North / East / South / West raster, 8-direction raster, Northness raster, Eastness raster, Trigonometric deviation raster, Numeric deviation rasterDerived · out_ns, out_ew, out_nesw, out_8dir, out_northness, out_eastness, out_trigdev, out_numdev | One output per transformation, holding that transformation's raster when it was chosen and empty otherwise, so a model can connect a single transformation to the next tool. | Raster Dataset |
This tool honors no geoprocessing environments; the raster is processed in its own coordinate system and never projected.
Python
import arcpy
arcpy.ImportToolbox(r"C:\path\to\JennessEnterprisesTools.pyt") # your install path
result = arcpy.jenness.AspectTransformation(
in_raster=r"D:\tutorial.gdb\Aspect",
transformations=["Northness (cosine of aspect; 1 = north, -1 = south)",
"Numeric deviation from a bearing (degrees, 0 - 180)"],
out_workspace=r"D:\tutorial.gdb",
base_name="Black_Bear_Aspect",
target_bearing=45,
input_convention="Compass (0 = north, clockwise)",
flat_handling="All transforms: flat cells -> NoData")
northness = result.getOutput(4) # the northness raster
deviation = result.getOutput(7) # the numeric deviation
every_raster = result.getOutput(8).split(";") # all rasters written
The tool returns a Result object, and
result.getOutput(n) gives the path of any of
its outputs. These are the actual paths written, including any
number the tool added to keep from overwriting an earlier raster,
so they are safer than rebuilding the names in the script. An
output for a transformation that was not chosen returns an empty
string. Wrap a path in arcpy.Raster() to use it in map
algebra.
| Index | Output |
|---|---|
| 0 | North / South raster |
| 1 | East / West raster |
| 2 | North / East / South / West raster |
| 3 | 8-direction raster |
| 4 | Northness raster |
| 5 | Eastness raster |
| 6 | Trigonometric deviation raster |
| 7 | Numeric deviation raster |
| 8 | Output rasters: every raster written, as one string separated by semicolons |
Recommended citation
Credits and references
By Jeff Jenness, Jenness Enterprises (www.jennessent.com).
- Beers, T. W., P. E. Dress, and L. C. Wensel. 1966. Aspect transformation in site productivity research. Journal of Forestry 64:691–692. doi.org/10.1093/jof/64.10.691
- Jenness, J. 2012. Issues with directional data. Remotely Wild, newsletter of the Spatial Ecology and Telemetry Working Group of The Wildlife Society. PDF
- Jenness, J. 2014. Polar plots for ArcGIS. Jenness Enterprises. jennessent.com/arcgis/polar_plots.htm
- Trimble, G. R., Jr., and S. Weitzman. 1956. Site index studies of upland oaks in the northern Appalachians. Forest Science 2:162–173. doi.org/10.1093/forestscience/2.3.162
Licensing information
Works at every ArcGIS Pro license level (Basic, Standard, Advanced). No extension licenses are required.
Related tools and pages
- About Aspect — why aspect matters, and why it needs circular arithmetic.
- Aspect Focal Statistics — circular statistics over a neighborhood of cells.
- Extract Aspect Values to Points — aspect at point locations, with circular interpolation.
- Aspect Zonal Statistics as Table — circular statistics by zone.
- Polar Plots — circular plots and statistics of an aspect raster's directions.
- Normalize Existing HSM — turns a deviation-from-a-bearing raster into a 0–100 habitat factor.
- Combine Habitat Factors — where such a factor joins a habitat model.