# Transform - Tiles: Slope

The Slope template appears in the template list when a raster tile field, of type Tile, has been picked in the Transform pane.  The template computes slope and other characteristics related to tilt, aspect and curvature of a surface. Tech Tip:  Manifold runs CPU parallel and also GPU parallel, as discussed in the GPGPU topic.   Having a GPU can make a huge difference in speed for many transforms that work with raster images, for example, when computing Curvature or Slope or Aspect using a radius of 3 or more.  Manifold running without a GPU installed will automatically use CPU parallelism instead for spectacular parallel speed, but with a GPU installed Manifold can often run dramatically faster.    Installing at least one, inexpensive NVIDIA GPU card in our systems allows such operations to run with astonishing speed, at times reducing computations from minutes to seconds or from hours to seconds.  A wide range of GPU cards costing from under \$100 to around \$250 will make a spectacular difference.

 Slope Transforms for computing slope and other characteristics related to tilt, aspect and curvature of a surface, treating pixel values as heights that imply the surface.  The Channel to use may be specified in multi-channel images.  Templates typically provide a Radius value that sets the number of pixels from the center pixel to the edge of the matrix used to compute the filter:  A Radius of 1 results in a 3x3 pixel array.     aspect - Compute the direction in which the slope of the terrain faces and save as a pixel value using the desired Unit of angular measure.  When using degrees,  0 to 180 degrees represent the Eastern semicircle and -1 to -179 degrees the Western semicircle.   gaussian curvature - Compute Gaussian curvature of the terrain surface at each pixel of a surface, computed over a square matrix of the given radius.  Gaussian curvature is the product of the curvature in the direction of greatest curvature and the curvature in the direction of least curvature.   mean curvature - Compute mean curvature of the terrain surface at each pixel of a surface, computed over a square matrix of the given radius.  Mean curvature is the average of the curvature in the direction of greatest curvature and the curvature in the direction of least curvature.   plan curvature - Compute planform curvature of the terrain surface at each pixel of a surface, computed over a square matrix of the given radius.  Planform curvature computes curvature perpendicular to the direction of maximum slope.  Plan curvature brings out ridges and valleys in a surface.  See the ESRI blog entry for a good discussion. profile curvature - Compute profile curvature of the terrain surface at each pixel of a surface, computed over a square matrix of the given radius.  Profile curvature computes curvature parallel to the direction of maximum slope. Profile curvature brings out terrace effects in a surface.  See the ESRI blog entry for a good discussion. slope - Compute the inclination of the surface at each pixel position expressed using the specified Unit of angular measure.  When using degrees, the slope will vary in the range 0 to 90.   The Unit of measure to be used for the result can be picked from Arc Minute, Arc Second, Degree, Grade or Radian.   Arc Minute, Arc Second, Degree, Radian -  Standard units of angular measure. The angle of the slope surface to the horizontal. Grade - A percentage, 100 * (rise/run), which is equivalent to the tangent of the angle of the slope surface to the horizontal.   Caution: Slight increases in Radius can cause disproportionately large increases in the computation time required.  Without a GPU a Radius of 3 is slow but tolerable because Manifold will run CPU parallel for better speed.   With a GPU, even incredibly large computations involving a Radius of 7 or even 8 are possible on a desktop machine, as Manifold will automatically GPGPU parallelize the aspect calculation.   Without a GPU, start with a Radius of 1 and then scale up slowly to see where patience ends.   As a practical matter, there is not much gain in accuracy of aspect computation when increasing Radius beyond 4 or 5.   GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images.   Launch the template by choosing a Tile field and then double-clicking the Slope template.  When the template launches we can specify options. Slope : aspect Treating the pixel values in the specified Channel as heights to imply a surface, compute the direction in which the slope of the terrain faces and save as a pixel value that direction in the given angular units of measure, with positive values representing the Eastern semicircle and negative values the Western semicircle.   The direction is computed by comparing heights of a square array of pixels within a given radius.     The Radius value sets the number of pixels from the center pixel to the edge of the matrix used to compute the aspect direction:  A Radius of 1 results in a 3x3 pixel array.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images. With the focus on the Elevation Raster image, in the Transform pane we choose the Tile field and then the Slope template. In the Slope template, we choose channel 0 for the Channel and aspect as the Operation.  We enter 8 as the Radius.  We have a GPU in our machine, so we need not fear a large computation.     For the Result destination, we choose New Field and then enter Tile aspect 8 as the name of the new tile field to add to the table.  For the new image name we enter Elev aspect 8.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.   Press Transform.     A new image called Elev aspect 8 appears in the Project pane.   We drag and drop the new Elev aspect 8 image into the Elevation Raster window as a layer.   Comparing the original image to the result:  The values resulting from aspect are no longer heights but are angular units of compass orientation.  The result at above right has been styled to use oranges to yellows for aspect values to the West, and blue to violet for aspect values to the East.   It makes little sense to apply hill shading to a raster display of aspect values. so shading has not been applied. Slope : gaussian curvature Treating the pixel values in the specified Channel as heights to imply a surface, compute the Gaussian curvature of the terrain surface at each pixel of the surface, computed over a square matrix of the given radius.   The gaussian curvature operation computes curvature as the product of the curvature in the direction of greatest curvature and of the curvature in the direction of least curvature.     The Radius value sets the number of pixels from the center pixel to the edge of the matrix used to compute the curvature:  A Radius of 1 results in a 3x3 pixel array.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images. With the focus on the Elevation Raster image, in the Transform pane we choose the Tile field and then the Slope template. In the Slope template, we choose channel 0 for the Channel and gaussian curvature as the Operation.  We enter 5 as the Radius.  We have a GPU in our machine, so we need not fear a large computation.     For the Result destination, we choose New Field and then enter Tile gaussian curve as the name of the new tile field to add to the table.  For the new image name we enter Elev gaussian curv.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.   Press Transform.     A new image called Elev gaussian curv appears in the Project pane.   We drag and drop the new Elev gaussian curv image into the Elevation Raster window as a layer.       Comparing the original image to the result:  We use Style to apply medium Autocontrast to the new layer.  The illustration at above right shows a typical use for curvature results.  The original image is shown in the upper Layer with 80% opacity, allowing the curvature image to partially show through.  The blended result emphasizes details in a subtle manner.  Multiple layers combining the results of different curvature transforms with different transparencies can be combined this way.   See the Speed Demo with 1280 GPU Cores video for an example using a Curvature filter.  See also the Example: Enhance Terrain with Curvatures  topic. Slope : mean curvature Treating the pixel values in the specified Channel as heights to imply a surface, compute the mean curvature of the terrain surface at each pixel of the surface, computed over a square matrix of the given radius.   The mean curvature operation computes curvature as the average of the curvature in the direction of greatest curvature and the curvature in the direction of least curvature.     The Radius value sets the number of pixels from the center pixel to the edge of the matrix used to compute the curvature:  A Radius of 1 results in a 3x3 pixel array.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images. With the focus on the Elevation Raster image, in the Transform pane we choose the Tile field and then the Slope template. In the Slope template, we choose channel 0 for the Channel and mean curvature as the Operation.  We enter 5 as the Radius.  We have a GPU in our machine, so we need not fear a large computation.     For the Result destination, we choose New Field and then enter Tile mean curve as the name of the new tile field to add to the table.  For the new image name we enter Elev mean curv.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.   Press Transform.     A new image called Elev mean curv appears in the Project pane.   We drag and drop the new Elev mean curv image into the Elevation Raster window as a layer.       Comparing the original image to the result:  We use Style to apply medium Autocontrast to the new layer.  The illustration at above right shows a typical use for curvature results.  The original image is shown in the upper Layer with 80% opacity, allowing the curvature image to partially show through.  The blended result emphasizes details in a subtle manner.  Multiple layers combining the results of different curvature transforms with different transparencies can be combined this way.   See the Speed Demo with 1280 GPU Cores video for an example using a Curvature filter.  See also the Example: Enhance Terrain with Curvatures  topic. Slope : plan curvature Treating the pixel values in the specified Channel as heights to imply a surface, compute the planform curvature of the terrain surface at each pixel of the surface, computed over a square matrix of the given radius.   The plan curvature (short for planform) operator computes curvature perpendicular to the direction of maximum slope.  Planform curvature brings out ridges and valleys in a surface.  See the ESRI blog entry for a good discussion.   The Radius value sets the number of pixels from the center pixel to the edge of the matrix used to compute the curvature:  A Radius of 1 results in a 3x3 pixel array.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images. With the focus on the Elevation Raster image, in the Transform pane we choose the Tile field and then the Slope template. In the Slope template, we choose channel 0 for the Channel and plan curvature as the Operation.  We enter 5 as the Radius.  We have a GPU in our machine, so we need not fear a large computation.     For the Result destination, we choose New Field and then enter Tile plan curve as the name of the new tile field to add to the table.  For the new image name we enter Elev plan curv.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.   Press Transform.     A new image called Elev plan curv appears in the Project pane.   We drag and drop the new Elev plan curv image into the Elevation Raster window as a layer.       Comparing the original image to the result:  We use Style to apply medium Autocontrast to the new layer.  The illustration at above right shows a typical use for curvature results.  The original image is shown in the upper Layer with 80% opacity, allowing the curvature image to partially show through.  The blended result emphasizes details in a subtle manner.  Multiple layers combining the results of different curvature transforms with different transparencies can be combined this way.   See the Speed Demo with 1280 GPU Cores video for an example using a Curvature filter.  See also the Example: Enhance Terrain with Curvatures  topic. Slope : profile curvature Treating the pixel values in the specified Channel as heights to imply a surface, compute the profile curvature of the terrain surface at each pixel of the surface, computed over a square matrix of the given radius.   The profile curvature operator computes curvature parallel to the direction of maximum slope. Profile curvature brings out terrace effects in a surface.  See the ESRI blog entry for a good discussion.   The Radius value sets the number of pixels from the center pixel to the edge of the matrix used to compute the curvature:  A Radius of 1 results in a 3x3 pixel array.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images. With the focus on the Elevation Raster image, in the Transform pane we choose the Tile field and then the Slope template. In the Slope template, we choose channel 0 for the Channel and profile curvature as the Operation.  We enter 5 as the Radius.  We have a GPU in our machine, so we need not fear a large computation.     For the Result destination, we choose New Field and then enter Tile profile curve as the name of the new tile field to add to the table.  For the new image name we enter Elev profile curv.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.   Press Transform.     A new image called Elev profile curv appears in the Project pane.   We drag and drop the new Elev profile curv image into the Elevation Raster window as a layer.       Comparing the original image to the result:  We use Style to apply medium Autocontrast to the new layer.  The illustration at above right shows a typical use for curvature results.  The original image is shown in the upper Layer with 80% opacity, allowing the curvature image to partially show through.  The blended result emphasizes details in a subtle manner.  Multiple layers combining the results of different curvature transforms with different transparencies can be combined this way.   See the Speed Demo with 1280 GPU Cores video for an example using a Curvature filter.  See also the Example: Enhance Terrain with Curvatures  topic. Slope : slope Treating the pixel values in the specified Channel as heights to imply a surface, compute the inclination of the surface at the pixel's position in the specified angular units and save as a pixel value, from 0 to 90 if degrees are used and an analogous amount in other angular units. The inclination of the surface is computed by comparing heights of a square array of pixels within a given radius.   The Radius value sets the number of pixels from the center pixel to the edge of the matrix used to compute the aspect direction:  A Radius of 1 results in a 3x3 pixel array.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  GPU parallelism switches to CPU parallelism at a Radius of 9 or greater, so it makes sense to use a Radius of 8 or less with bigger images. With the focus on the Elevation Raster image, in the Transform pane we choose the Tile field and then the Slope template. In the Slope template, we choose channel 0 for the Channel and slope as the Operation.  We enter 5 as the Radius.  We have a GPU in our machine, so we need not fear a large computation.   We use Degree as the Unit.   For the Result destination, we choose New Field and then enter Tile slope as the name of the new tile field to add to the table.  For the new image name we enter Elev slope.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.   Press Transform.     A new image called Elev slope appears in the Project pane.   We drag and drop the new Elev slope image into the Elevation Raster window as a layer.       Comparing the original image to the result:  The values resulting from Slope are no longer heights but are degrees of inclination.   We style the Elev slope image using a thematic format using the CB Spectral palette so steeper slopes are red and less steep slopes are blue.

## Notes

Sample image - Many illustrations for transforms for raster images use an Elevation Raster sample image, a version of the formatted example of importing an SDTS format DEM from the Example: Import DDF SDTS DEM Raster File  topic.   The example project may be downloaded from the Downloads page on the Manifold web site.

Everything Math - For a handy reference to anything in mathematics, see the Wolfram MathWorld site.   Thank you, Wolfram!

Transform Pane

Transform Reference

Transform - Tiles

Example: Enhance Terrain with Curvatures -  We enhance a terrain showing Crater Lake, Oregon, by using mean curvature calculation to bring out details.   The example uses a 4 GB project containing a large terrain elevation surface.  Using a point-and-click dialog with no SQL, we apply automatic CPU parallelism and GPU parallelism to absolutely crush a task in two and a half minutes that would take non-parallel software days.