Raster Paths

The Manifold Path template in the Transform pane works with a map containing a raster image and a vector drawing that contains starting points.   The template finds a path from each starting pixel in the drawing layer to every pixel in the raster layer based on different ways of reckoning path distance, such as straight line distance or lowest cost from pixel to pixel.  The template calculates a solution for all pixel locations in a raster at once, saving the result as a new raster.  The number put into each pixel in the output raster is the result of the transform.

 

For inputs, starting points used in path computations can be restricted to only those selected, using the Start from selection only check box.  The Channel to use in the raster can be specified for multichannel images.   

 

The Path transform can be used with raster data of all kinds and not just terrain elevation data, so long as we can work on a single, specified channel at a time.  Given the intuitive understanding for most people of how a single channel in a raster can represent terrain elevation, this documentation uses terrain elevation data for examples.

 

If we are leveraging familiarity with ESRI tools, the Path template provides a Manifold implementation of functionality similar to the Distance tools in ESRI's Spatial Analyst toolset.   ESRI refers to pixels as cells in their tools.  Manifold uses pixels and cells as synonyms in raster analytics.  Manifold also uses the words raster and image as synonyms, sometimes even using the redundant term raster image.  ESRI refers to the points in the drawing as sources.  Manifold uses points and sources as synonyms in these transform templates.

Path Options

The Path template provides three basic Path type options. Each Path type option has three different Output type options, providing a total of nine different combinations of Path type and Output type.   

 

Path type options:

 

 

Output type options:

 

 

Each of the nine option combinations makes a calculation for each pixel in the raster, where the calculation is based on the path between that pixel and the point in the drawing that is closest to that pixel by the given criteria.  That is why the transform template is named Path, since each option in the template bases its calculation for a particular pixel in connection with the path to the closest point.  

 

Nomenclature:  Manifold topics for Transform and Select operations refer to the name of the template using shortcut nomenclature like that in the most recently used list of templates.   The name of the template is followed by colon : characters and options.  Path : Euclidean : value means the Path template using the Euclidean path type option and the value output option.

Example -  Path : Euclidean : value

The Path :  Euclidean :  value transform creates a new raster where the value of each pixel is the value of the point closest to that pixel, either attribute value or sequential value, with closest being measured by simple, straight-line, Euclidean distance.   That is why the path type option is called an Euclidean path type.    The transform is a way of assigning pixels to a region where each pixel in that region is closer to the region's point than to any other point.  When using the Euclidean path type, such regions end up being Voronoi regions for each point.

 

 

Suppose we have a map with a Raster image showing terrain elevation as seen above.   The map also includes a Points drawing layer, where each point has a Height value.  A Labels layer reports the height of each point in the map.

 

 

In the example above, we have copied the terrain elevation at the location of each point into the Height attribute for that point.

 

With the focus on the map, in the Transform pane we choose the Raster layer and the Tile field.   We double-click the Path template to choose it.

 

 

In the Path template, we choose channel 0 for the Channel and Euclidean as the Path type.  If desired, we can check the Use barriers box to compute straight-line (Euclidean) paths around barriers, which are indicated by pixels with NULL values.  PIxels with NULL values are rendered as invisible pixels. This data set has no barriers, so we leave that box unchecked.

 

The Points drawing will automatically be loaded into the Start from box, since that is the only drawing in the map.    For Output type we choose value, and then in the Value box we choose the Height field.

 

For the Result destination, we choose New Field and then enter Tile euclidean value as the name of the new tile field, and then Euclidean value as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview, if we would like a preview.   There is no requirement to do a preview, but it can be wise to see a preview before transforming data, as a quick check that we have set up parameters as we have desired, in case a preview shows a totally unexpected result will happen.

 

 

The preview shows in shades of blue preview color how new zones will be created, with a blue preview caption bar at the top of the window reporting the name of the template being previewed.  

 

Previews are drawn on top of all other layers.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

 

To see both the preview and layers below the preview, we can right-click the caption bar and choose 50% opacity for the preview, so layers below are visible.

 

 

If we like, we can right-click on the caption bar and choose Left or Right to provide a split-screen display with the preview appearing on the left or the right side of the window.  We can drag the thin blue vertical separator line to the left or right to adjust the width of the preview part of the screen.

 

If we like what we see, we can press Transform to apply the transform. 

 

A new image called Euclidean value appears in the Project pane.   We drag and drop the new Euclidean value image into the map as a layer:

 

 

Running the Path : Euclidean : value transform with the options specified creates a new raster where each pixel in the raster gets the Height attribute value of the point closest to that pixel.  We have styled the new Euclidean value layer using the same thematic formatting as used in the Raster image.  

 

 

One way of looking at what the Path transforms do is to imagine the starting raster being chopped up into a Voronoi diagram of regions subject to each point in the drawing.  The transform applies to pixels within each region and computes their relationship (direction, distance, or source value) with the closest pixel.

 

 

In the case of the Path : Euclidean : value transform, Voronoi regions are computed using straight line, Euclidean distance, and pixels within each Voronoi region get the value of the point in that Voronoi region.  That is a conceptually simple function, compared to other Path operations.  

Three Path Types

The nine Path options are divided into three Path type options based upon how they reckon distances between pixels and the closest point:  

 

 

 

 

Within each Path option there are three Output options for what to save into each result pixel:

 

 

 

 

In addition, the Path transforms have a check box option to calculate least cost paths using equal or varying per-pixel costs.

Euclidean Path type

Euclidean distances mean straight-line distances.  The Euclidean path type reckons distances from each raster pixel to the nearest point in the drawing over a straight line from the center of the pixel to the nearest point.

 

 

The Euclidean path type calculates straight line distances from pixel to point.  The direction for each result pixel is the direction in degrees of the first segment.  By default, the first segment is the only segment, the straight line from that pixel to the closest point.  When the Use barriers box is checked, there may be more than one straight segment to route around barriers.

 

 

Euclidean templates by default ignore pixel values, including NULL pixels, between the context pixel and the closest point.   When the Use barriers box is checked, Euclidean templates will find the shortest route using straight line segments which avoid NULL pixels, called barriers, .

 

Given a specified channel in the image, and choosing a drawing with points as the Start from drawing, the Euclidean path type option creates a new, single-channel image of the same dimension and pixel size where the value of each pixel gives the result of the transform, as follows:

 

Euclidean : direction

The value of each pixel gives the straight-line (Euclidean) direction in degrees from that pixel to the point in the drawing that is closest to that pixel.   

Euclidean : distance

The value of each pixel gives the straight-line (Euclidean) distance in native units of the image from that pixel to the point in the drawing that is closest to that pixel.  

Euclidean : value

The value of each pixel is loaded with either a sequential number (the Sequential Values choice) or with the content of an attribute field in the points drawing table that provides a value for each point.  Each result pixel is loaded with the value for the point in the drawing that is closest to that pixel.  

 

Example -  Path : Euclidean : direction

The Path : Euclidean : direction transform creates a new raster where the value of each pixel is the direction in degrees to the point closest to that pixel, with closest being measured by simple, straight-line, Euclidean distance.  

 

 

We start with a map with two layers: a Raster image showing terrain elevation as seen above, and a Points drawing that contains eight points.

 

With the focus on the map, in the Transform pane we choose the Raster layer and the Tile field.   We double-click the Path template to choose it.

 

 

In the Path template, we choose channel 0 for the Channel and Euclidean as the Path type.  If desired, we can check the Use barriers box to compute straight-line (Euclidean) paths around barriers, which are indicated by pixels with NULL values. This data set has no barriers, so we leave that box unchecked.

 

The Points drawing will automatically be the Start from selection, since that is the only drawing in the map.    For Output type we choose direction.

 

For the Result destination, we choose New Field and then enter Tile euclidean direction as the name of the new tile field, and then Euclidean direction as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview.

 

 

The preview shows the image that will be created, previewing the direction values that will be in each pixel using a range of blue preview colors, from dark blue to white.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

 

To see the relationship between the preview and the original Raster, we can right-click the caption bar and choose 50% opacity.

 

To apply the transform template, press Transform.  

 

A new image called Euclidean direction appears in the Project pane.   We drag and drop the new Euclidean direction image into the map as a layer:

 

 

The resulting raster is seen above, dropped into the map and Styled using the CB spectral palette on Channel 0 (the only channel in a single-channel result raster) to thematically format the pixel values from 0 to 360.  The 0 to 360 value in each pixel gives the direction from that pixel to the closest green point.   Remember:  the direction is toward the green point, and not a compass direction away from the green point.   The direction value of a pixel that is located to the North of a green point, with pixels colored in shades of yellow, is about 180, that is, one must head in a direction of South to go toward the point.

 

Since Euclidean, straight line distances are used, the pixels end up being grouped into Voronoi regions, as with the Euclidean value example at the beginning of this topic.   There is a discontinuity in color between red and blue in the color wheel because the thematic format jumps abruptly from red to blue when compass directions jump abruptly from 360 to 0, as seen in the Style pane at left below.

 

 

We can adjust that to a smooth color transition by changing the color of the last box's interval from red to purple, the same as the first box.  We can choose the same color as the first box when specifying the color for the last box by using the color picker tool to "pick" the color from the first box.

 

 

That provides a smoother interpolation when transitioning from 359 degrees to 0 degrees.  This technique depends on having enough intervals in the thematic format so that the last color well can be made the same color as the first color well, and yet provide a smooth color wheel transition.  In the example above 14 intervals are used, which is enough when using the CB Spectral palette for a purple color, midway between red and blue in a color wheel, to appear and thus be available as a good color choice for both the first and the last box.

 

To see the above display in context, we will use the Layers pane to reduce the opacity of the Euclidean direction layer, allowing some of the hill shaded terrain below to become visible.

 

 

First, we will add a grayscale version of the Raster layer to the map.   To create a grayscale version, we copied and pasted the Raster layer in the project, naming the copy Raster Gray.  We then styled the Raster Gray layer with a thematic format using two intervals, from light gray to white.    The resulting neutral, colorless version of the hill shaded terrain display will make a good background for a partially transparent Euclidean direction layer while allowing that layer's colors to remain unchanged by the color of the background terrain.

 

 

The illustration above shows the map with 60% opacity used for Euclidean direction layer.   We have also added a Voronoi Lines drawing layer, the same one used in the Euclidean value example at the beginning of this topic.   The Voronoi regions are the same since in both examples Euclidean, straight line distance determines which green point is the closest to any given pixel.

Example -  Path : Euclidean : distance

The Path : Euclidean : distance  transform creates a new raster where the value of each pixel is the distance in native units of the image from that pixel to the point in the drawing that is closest to that pixel, with closest being measured by simple, straight-line, Euclidean distance.  

 

 

As before, we start with a map with two layers: a Raster image showing terrain elevation as seen above, and a Points drawing that contains eight points.

 

With the focus on the map, in the Transform pane we choose the Raster layer and the Tile field.   We double-click the Path template to choose it.

 

 

In the Path template, we choose channel 0 for the Channel and Euclidean as the Path type.  If desired, we can check the Use barriers box to compute straight-line (Euclidean) paths around barriers, which are indicated by pixels with NULL values, which are rendered as invisible pixels. This data set has no barriers, so we leave that box unchecked.

 

The Points drawing will automatically be the Start from selection, since that is the only drawing in the map.    For Output type we choose distance.

 

For the Result destination, we choose New Field and then enter Tile euclidean distance as the name of the new tile field, and then Euclidean distance as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview.

 

 

The preview shows the image that will be created, previewing the distance values that will be in each pixel using a range of blue preview colors, from dark blue to white.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

 

Right-clicking the preview caption bar and choosing 75% opacity (we want greater opacity since gradations in the preview are harder to see), we can see the relationship between the preview and the underlying points and rasters.   Seen in shades of blue preview color the presentation is difficult to read, but it nonetheless shows we have not inadvertently failed to choose a desired option.   We can style the final result as we like for a clearer presentation.

 

Press Transform.  

 

A new image called Euclidean distance appears in the Project pane.   We drag and drop the new Euclidean distance image into the map as a layer:

 

 

The resulting raster is seen above, dropped into the map, before styling.  In this example we will show how to style the raster.  We can give it a more useful appearance using the Style pane.

 

 

In the Style pane we choose Channel 0 in the channel selector, since that is the only channel in the single-channel result raster.  We then use the CB spectral palette in reverse order with 8 breaks and interpolating fill colors.  The raster is in Universal Transverse Mercator Zone 10 (N) projection, which uses meters as units, so the values in the intervals are meter distances from each pixel to the closest green point.

 

 

Since Euclidean, straight line distances are used, the pixels end up being grouped into Voronoi regions, as with the Euclidean value example at the beginning of this topic.   

 

 

We can add a Voronoi Lines drawing layer, the same one used in the Euclidean value example at the beginning of this topic, to better show the borders between regions closest to each green point.   The Voronoi regions are the same since in both examples Euclidean, straight line distance determines which green point is the closest to any given pixel.

 

 

As with the prior example, we can add a grayscale version of the terrain elevation raster, to provide a color-neutral hill shaded terrain background, and change the opacity of the Euclidean distance layer to 80% to allow some of the background to show through for context.

 

The Euclidean options in the Path template are fairly simple tools.  The cost and cost for slope options are conceptually more complex, because of instead of using straight line distances they use pixel-to-pixel paths.

Cost Path type

Paths generated using the cost path type are the least total cost pixel-to-pixel paths that avoid pixels with NULL values.  Checking the Use equal costs box (the default) uses the same cost for all pixels.  The overall length of the path is thus the cost of the path, with the shortest pixel-to-pixel path being the least cost.  Unchecking the Use equal costs box counts the value of each pixel as the cost of that pixel, and adds up the costs of pixels that the path goes through to get the total cost of the path.   

 

For example, if the value of each pixel is the slope of the terrain at that pixel, with steep terrains having high slope, a path that goes through the a given number of pixels in steep terrain will have a higher total cost that a path which goes through the same number of pixels in flat (low slope values) terrain.   Travelling through flat terrain will have a lower cost than travelling through steep terrain.

 

 

With Path templates, the distance of the path is the total distance from pixel to pixel over the path.  The more direct path in the illustration at left above has a shorter length than path at above right, which routes around NULL pixels.

 

 When using cost path type, the Path template always routes around NULL pixels.  That is different from using Euclidean path type, which provides a Use barriers check box to route around NULL pixels, if desired.

 

Paths using cost path type are calculated to be the least cost path from context pixel to point.   Checking the Use equal costs box, the default, uses the same cost for each pixel.  The path that goes through the least number of pixels is the lowest cost path, so the lowest cost path is also the shortest length overall.  Unchecking the Use equal costs box uses whatever is the value of each pixel as the cost of going through that pixel.  The total cost of the path will be the sum of the costs of all the pixels in the path.  

 

 

The illustration at left above shows a path from the starting pixel to the closest green point using equal costs, that is, checking the Use equal costs box.  In effect, it is a pixelated path version of an Euclidean straight line from the pixel to the point.   The illustration at right above unchecks the Use equal costs box, to count the value of each pixel as the cost, with lighter colored pixels having a lower cost.   The least cost path follows the lighter pixels as much as possible, and then tries to avoid the darker colored row of pixels just below the destination point.   That results in a path with more pixels but with a lower total cost.

 

 

When using cost path type, the direction for each result pixel is always the direction from that pixel to the very next pixel in the path.   The direction value for the starting pixel in the illustration at left above is 90 degrees, while the direction value for the starting pixel in the illustration at right above is 90 degrees.    

 

Given a specified channel in the image, and choosing a drawing with points as the Start from drawing, the cost path type option creates a new, single-channel image of the same dimension and pixel size where the value of each pixel gives the result of the transform, as follows:

 

cost : direction

The value of each pixel gives the direction in degrees from that pixel to the next pixel in the least cost path to the point in the drawing that is closest, by least cost path, to that pixel.  

 

The direction from each pixel to an adjacent pixel can be only one of eight possible directions, 45, 90, 135, 180, 225, 270, or 315, or 360 degrees,  since adjacent pixels can only be to the left or right, above or below, or at one of four diagonal directions in between.  Direction values will be restricted to those eight values, plus 0 for the pixel coincident with the nearest point.

cost : distance

The value of each pixel gives the distance in native units of the image from that pixel via the least-cost path to the point in the drawing that is closest, by least cost path, to that pixel.  

cost : value

The value of each pixel is loaded with either a sequential number (the Sequential Values choice) or with the content of an attribute field in the points drawing table that provides a value for each point.  Each result pixel is loaded with the value for the point in the drawing that is closest, by least cost path, to that pixel.  

 

A Raster Approach to Paths

Paths are normally thought of as vector data, for example, the line of a road or a trail between two locations, but rasters can be a better way of conveying information about the costs of travel through a region when routes are not constrained to roads and any path is possible.

 

 

Consider the above illustration, where green points in a drawing are joined by road lines in another drawing.  The background is a raster giving terrain elevation.  A third drawing shows a base point, a magenta square, that is located on the road network.  

 

A classic vector task in GIS is to find the green point closest to the base point when travelling through the road network.   A related task is to find the green point which has the lowest cost to reach, if travelling over the road network has higher costs over certain road segments, for example, when climbing to higher altitudes.

 

The green point on the high ridge nearest the base point is clearly the closest by road distance, but any of the three green points on or near the low, flat valley would probably be easier to reach when walking.   Most people would rather walk three miles on flat land than climb two miles up to a high ridge.

 

Computing such cost tradeoffs using vectors, such as road networks, depends upon having vector data that is structured so it provides a representative cost value for whatever criterion is considered "higher cost" when travelling over any given section of road.  The road network might be structured as many different line objects, one after another, where each line object represents a portion of the road with a particular cost, such as a particular slope, toll, or other cost.  Where the slope changes, a new line object takes over with a new cost attribute.

 

Suppose we do not have such an orderly and usefully provisioned collection of road lines, with each portion of road correctly marked as to slope?  We may need to compute such data based on underlying information in a raster, such as a raster giving terrain elevation at each pixel location, or a raster giving the slope of terrain at each pixel location.

 

 

What if we have no roads at all, and the task is to find the "closest" green point by any route, as if we were walking in terrain with no roads?   What if "closest" depends on specific technical criteria, for example, what is closest by straight-line Euclidean distance, as in siting radio antennae, or what is least-cost "distance" by some criterion, such as avoiding higher terrain?

 

The cost path type can help find an answer, by simultaneously computing for all pixel locations in the raster a measure of "closest" in relation to the "closest" green point.   The natural way to report the result of such a computed measure for each pixel is to create a new raster, with the same dimensions and pixel size as the starting raster, that in each pixel stores the value of the computed measure.

Example -  Path : cost : distance

We can see how the cost path type option works by trying a simple example using the map above.

 

With the focus on the map, in the Transform pane we choose the Raster layer and the Tile field.   We double-click the Path template to choose it.

 

 

In the Path template, we choose channel 0 for the Channel and cost as the Path type.  

 

 For this example, we will uncheck the Use equal costs box.   If we had left the box checked, the results of the transform would be similar to the Euclidean : distance transform, since the lengths of the paths would work out to be very similar to Euclidean, straight-line distances.   By unchecking the Use equal costs box we will use the height values in the terrain raster as costs.  Travelling over higher terrain will involve higher costs, and thus a path which travels over higher altitudes will have a higher total cost than a path which traverses lower altitudes.

 

The Points drawing will automatically be the Start from selection, since that is the only drawing in the map.    For Output type we choose distance.

 

For the Result destination, we choose New Field and then enter Tile cost distance as the name of the new tile field, and then Cost distance as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview.   

 

 

The preview shows the image that will be created, previewing the cost distance values that will be in each pixel using a range of blue preview colors, from dark blue to white.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.   We will not bother applying partial opacity to the preview and instead will go straight to styling the final result.

 

Press Transform.  

 

A new image called Cost distance appears in the Project pane.   We drag and drop the new Cost distance image into the map as a layer:

 

 

The display above has been thematically formatted using the CB Spectral palette in 20 intervals using a Fill setting of closest lower value, to give a quantized look to the display. Pixels shown in deep blue have shorter least cost path lengths to their closest green point, while yellowish green pixels have greater path lengths.   A small amount of hill shading has been used, so the "home" regions closest to each of the green points are more apparent due to gradations of shading.

 

The illustration above shows the result of the Path : cost : distance transform template, operating on the Raster image and using the Points drawing as a source, using the height values of pixels in the Raster layer as the cost to travel through each pixel.  The value of each pixel in the resulting raster gives the total distance over the least cost path from that pixel to the nearest green point.  

 

The Cost distance raster simultaneously reports, for each pixel in the entire raster, the least cost path length from that pixel to the nearest point.  

 

The original Raster layer is an image that is 1121 pixels by 1403 pixels, so the Cost distance raster is also 1121 pixels by 1403 pixels in size, over 1.5 million pixels.   Because the value of each pixel in the Cost distance raster is the computed least cost path length from that pixel to the "closest" (by lowest total cost path) green point, the Cost distance raster simultaneously reports the results of over 1.5 million path distance calculations, a very dense display of very many path cost and length computations.

 

 

The illustration above shows the Cost distance layer with 80% opacity and using a color-neutral, grayscale layer underneath called Raster Gray.  Using partial opacity allows the thematic coloring to be visible while also allowing the gray, hill shaded terrain to show through to provide visual context.   We can infer that the shortest path from the starting square to the nearest green point is to go slightly North and then East along the ridge, which will be a lower cost path than a straight-line path.

 

Where terrain is very flat, such as surrounding the green point farthest to the West, the distances are visibly quantized to the eight directions that are possible from pixel to pixel.  Although we can see how pixels are grouped into "closest" regions surrounding each green point, the regions are no longer simple Voronoi regions, since the measure of "closest" to each point is no longer simple, straight line distance.

 

The above example is somewhat contrived, because the smoothness of terrain changes in the original raster tends to result in smoother paths from pixel to pixel when using terrain elevation as a proxy for cost.  Normally, the slope of terrain or other computed value is used as a proxy for cost.  

Example -  Path : cost : distance Using a Slope Surface

Let us repeat the above example using the slope of the terrain, for a more real-life example.    See the video version of this example in the Closest Rasters - Paths video.

 

Slope is a measure of how tilted terrain is at any given location.  Travelling over terrain that is steeply tilted, with steep valleys and hills, is more difficult, more "costly," than travelling over flat terrain.   In this example we will first compute a slope raster for the terrain, and then we will apply the Path : cost : distance transform to that slope raster, using slope values as costs.   

 

This is a non-directional use of slope: the same value of slope is used as a per-pixel cost regardless of whether we are going uphill or downhill.  It makes sense to use such calculations when travelling through uneven terrain if we wish to avoid the most uneven parts.  For a directional use of slope, where the computation can reckon going downhill as having a lower cost than going uphill, we can use the transforms discussed later in this topic, the Path : cost for slope transforms.  Those transforms automatically compute, on the fly, the slope for each pixel starting with the original terrain elevation raster, and then they use those slope values for directional path computations, counting downhill travel as lower cost than uphill travel.

 

 

As before, we start with a map that has a Raster image and a Points drawing that contains eight points.   We will leave the Base Point layer that shows a third point, to provide visual reference.   We will first create a slope raster.

 

With the focus on the map, in the Transform pane we choose the Raster layer and the Tile field in that layer.   We then double-click the Slope template to launch it.

 

 

In the Slope template we choose channel 0 as the Channel, and slope as the Operation.   We use a Radius of 5 so that the slopes we compute will be averaged over five pixels.

 

For the Result destination we choose New Field and use a name of Tile slope for that new field.   We enter Slope as the name of the new image to be created.   

 

We press Preview to see a preview.

 

 

The preview is seen above after right-clicking the preview caption bar and choosing 75% opacity.

 

 

Above, we have right-clicked the caption bar and chosen Left for a split-screen preview.  We have dragged the separator line slightly to the right to show more of the preview side of the split screen.

 

Press Transform.

 

A new Slope image appears in the Project pane.  We drag and drop it into the map:

 

 

We use Style to format the Slope raster so pixels in regions with low slope values (flatter terrain) are colored blue and pixels in regions with high slope values (steeper terrain) are colored yellow to red.   We have turned off the original Raster layer tab.

 

We now can compute cost : distance paths using the Slope raster, so that paths will use the slope of each pixel as the cost of that pixel.

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile slope as the field.    

 

We created the Slope raster by adding a new tile field, called Tile slope, to the table for the Raster layer, so we can either pick the Slope layer and choose Tile slope as the field or we can pick the Raster layer and choose Tile slope as the field, since both the Slope layer and the Raster layer are created from the same table, just from two different tile fields in that table.

 

We double-click the Path template to launch that template in the Transform pane.

 

 

In the Path template we choose channel 0 as the Channel and for Path type we choose cost.   

 

 We uncheck the Use equal costs box, so the system will compute lowest cost paths by adding the values of each pixel in the path as costs.  Since the pixels in the Slope layer have the slope of the terrain as their value, that will result in total path costs that are higher for paths that go through steeply sloped terrain, and total path costs that are lower for paths that go through less sloped, flatter terrain.

 

We choose Points as the Start from drawing.   For the Output type we choose distance.

 

We choose New Field for the Result and enter the name Tile slope cost distance for the name of the new tile field we will add to the table.   For the New image name to visualize that tile field, we enter Slope cost distance.

 

Press Preview.

 

 

The preview shows the image that will be created, previewing the cost distance values using the slope that will be in each pixel using a range of blue preview colors, from dark blue to white.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

Press Transform.

 

A new Slope cost distance image appears in the Project pane.  We drag and drop it into the map:

 

 

The resulting raster is seen above, styled using closest lower value for Fill in the Style pane, to provide a quantized map of least cost paths from each pixel to the closest (by least cost path) green point.   Regions of purple pixels show the very lowest cost paths, and regions of red pixels show the highest cost paths from those pixels to their closest green point.

 

This is a considerably more complicated display than the cost : distance display based on terrain heights.  It contains a tremendous amount of information about the least cost paths from any spot in the image to the closest green point.

 

For example, we can intuitively guess that if we start at the magenta Base Point square, the closest (by lowest cost) green point is the point by the left edge of the window.   We can travel from the magenta Base Point to that green point via very low cost paths that are almost all in purple, the lowest cost paths.

 

But suppose we do not want to intuitively guess about where lowest paths may be?  Suppose we would like to know for sure what are the least cost, pixel-by-pixel paths from any location to a closest green point?   Suppose we do not want to guess exactly which green point is the "closest" by least cost path?    We can sharpen our insight using Manifold's handy set of tools and capabilities for doing data science.

 

 

We first will use Style to change the Fill method to interpolate and to add hill shading to the Slope cost distance image.  The result is what looks like a hill shaded terrain, but what we see is not a terrain elevation surface but instead an abstract cost surface:   what seem to be higher spots are regions where each pixel has a high cost path to the closest green point.   What seem to be low spots are regions where each pixel has a low cost path to the closest green point.   If we start at any given pixel and then we always go next to whatever adjacent pixel has the lowest path cost, we will always stay on the lowest cost path to the closest green point.

 

But that is exactly what water does when it flows downhill from higher terrain to lower terrain: the water always flows next to whatever is a lower spot.  In an abstract terrain where apparent "heights" are total costs of shortest paths, if we want to find the lowest cost path from any spot to the closest green point, we simply do what water does and "flow downhill" to the least cost path adjacent pixel.   We can use Manifold's Watershed template to do that for us automatically.

Create Watershed Lines

With the focus on the map, in the Transform pane we choose the Raster layer and Tile slope cost distance as the field.    

 

We created the Slope cost distance raster by creating a new tile field, called Tile slope cost distance, within the table for the Raster layer, so we can either pick the Slope cost distance layer and choose Tile slope cost distance as the field or we can pick the Raster layer and choose Tile slope cost distance as the field, since both the Slope cost distance layer and the Raster layer are created from the same table, just from two different tile fields in that table.

 

We double-click the Watershed template to launch that template in the Transform pane.

 

 

In the Watershed template we choose channel 0 as the Channel and for Output type we choose lines.   We enter 800 as the Minimum flow, to provide a reasonable number of watershed lines to see what is going on but not too many for an overly busy display.   We picked the number 800 by trying different values more or less and choosing the one which in the preview gave a nice display.  

 

We choose New Table for the Result and enter the name Slope cost watersheds for the name of the new drawing, with an analogous name for the new table.  

 

Press Preview.   

 

 

The preview shows the watershed lines that will be created, in blue preview color.  As before, there is no need to do a preview before applying the transform, but it can be wise to try a preview to make sure we have the template parameters set up the way we like.  When creating watershed lines, it can be helpful to try a few different Minimum flow settings to see what is best for the result we seek.

 

Press Transform.

 

A new Slope cost watersheds drawing appears in the Project pane.  We drag and drop it into the map, and format it to use green lines:

 

 

Right away, we can see a representative sample of lowest cost paths from various locations to their closest (by lowest cost path) green points.  The watershed lines show how a drop of water falling on any pixel in the surface would flow, "downhill," that is down to ever lower cost path pixels, to the green point which is the sink for the path cost terrain surface.  Each such watershed line is the lowest cost path from the pixel at the very tip of the line through all pixels on the line, to the green point that is the sink for the line.

 

We can get more detailed insight into least cost paths through the raster by creating watershed lines with lower values of Minimum flow, to create finer, more detailed networks of watershed lines.   However, suppose we would like to create crisp boundaries between regions that are "closest" to the various green points, similar to the precise boundaries of Voronoi regions that apply to Euclidean path types in the Path template?    We can do that using the Path : cost : value transform, along with a few simple applications of other Manifold tools.

Example - Path : cost : value

We continue the example by creating a Path : cost : value raster using the Slope raster, which provides a slope value in each pixel.

 

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile slope as the field.     We created the Slope raster by creating a new tile field, called Tile slope, within the table for the Raster layer, so we can either pick the Slope layer and choose Tile slope as the field or we can pick the Raster layer and choose Tile slope as the field, since both the Slope layer and the Raster layer are created from the same table, just from two different tile fields in that table.

 

We double-click the Path template to launch that template in the Transform pane.

 

 

In the Path template we choose channel 0 as the Channel and for Path type we choose cost.   

 

 We uncheck the Use equal costs box, so the system will compute lowest cost paths by adding the values of each pixel in the path as costs.  Since the pixels in the Slope layer have the slope of the terrain as their value, that will result in total path costs that are higher for paths that go through steeply sloped terrain, and total path costs that are lower for paths that go through less sloped, flatter terrain.

 

We choose Points as the Start from drawing.  For the Output type we choose value.  For the Value we choose the Height field.  

 

We choose New Field for the Result and enter the name Tile slope cost value for the name of the new tile field we will add to the table.   For the New image name to visualize that tile field, we enter Slope cost value.

 

Press Preview.

 

 

The preview shows in shades of blue preview color how new slope cost zones will be created.  Previews are drawn on top of all other layers, so we cannot see the points and base point below.   We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

 

If we would like to see what is underneath the preview, we can right-click the blue preview caption bar at the top of the window and choose 75% opacity.

 

 

 

We can also right-click the blue preview caption bar at the top of the window and choose Left or Right, and then drag the vertical splitter line left or right to show less or more of the preview in the split-screen display.

 

Press Transform.

 

A new Slope cost value image appears in the Project pane.  We drag and drop it into the map:

 

 

The resulting raster, seen above as a layer in our map, saves the Height value of each green point into those raster pixels that are closest, by least cost path using the Slope layer, to that point.   In the illustration above we have Styled the raster using the same thematic format that was used to color the Path : Euclidean : value result raster in that example.  

 

Copying style is a simple matter of launching the Properties dialog for the Path : Euclidean : value raster and Copying the value of the StylePixel property.   We can then Paste that same value into a StylePixel property we create in the Properties dialog for the Slope cost value raster.  

 

We can compare that raster to the Path : Euclidean : value result raster:

 

 

The Path : Euclidean : value raster organized result pixels into obvious Voronoi regions.   Our Path : cost : value raster has more complex regions that are delineated by least cost path lengths determined by the pixel by pixel cost of traversing more sloped or less sloped terrain.

 

 

If we add the Slope cost watersheds drawing as a layer above our Slope cost value raster, we can see how the Slope cost value raster groups pixels into regions that are the drainage regions for the watershed lines.   

Trace Areas

However, what we have so far is a raster image, not a vector drawing of crisp boundary lines between such regions.   To get boundary lines we can create a vector drawing of areas from the Slope cost value raster.   That is easy to do, using the Trace transform template, as illustrated in the Example: Trace Vector Areas from Raster Pixels topic.

 

 

With the focus on the map, in the Transform pane we choose Raster as the layer and Tile slope cost value as the field.   

 

In the Path series of examples we have been creating results rasters by adding new fields to the same Raster Tiles table that originally just hosted a single tile field for the Raster layer.    By now we have seven or eight additional tile fields in that table, one of which is the Tile slope cost value added in the prior step.   Whether we prefer to save results as a new tile field in the same table, or as an entirely separate table is often a matter of preference.  

 

In a case where all of the results are closely related, just different variations of options within the same Path template, it can be convenient to save all the results into the same table.   Manifold is extremely efficient at storing data in tables, whether that is an additional field in the same table or in a new table, so there is no significant performance reason for choosing one way or the other.

 

Double-click on the Trace template to launch that template in the Transform pane.

 

 

In the Trace template we choose 1 for Similarity.   Each pixel in the Slope cost value raster has exactly the Height value of the closest (by least cost path) green point, so we choose 1 to get exact matches, in case any of the regions have pixel values that are close together.    We check the Split into shapes option so that non-contiguous regions that have the same pixel values will become separate area objects, and not just different branches of the same area object.

 

New Table is the only choice for the Result since creating a new drawing from an image requires adding a new component and not just another field to the image table.   We enter the name Slope cost value areas for the name of the new drawing, with an analogous name for the new table.   We can use whatever names we like, but it is wise to choose names that remind us what those layers are.

 

Press Preview.  

 

 

The preview shows the vector (drawing) layer that will be created, with the area objects shown in blue preview color.

 

 

To see in the preview how those areas relate to the regions of pixels from which they were traced, we can right-click the blue preview caption bar at the top of the window and choose 75% opacity.

 

 

 

If we like, we can also right-click the caption bar and choose Left to show the preview only on the left side of the window, and then we can drag the vertical splitter line left and right to show less or more of the preview as we like.

 

Press Transform.

 

A new Slope cost value areas drawing appears in the Project pane.  We drag and drop it into the map:

 

 

The Slope cost value areas drawing shows the area objects that have been created, using default gray formatting.  Our next step is to use Style to make the fill color transparent, so we can see layers below.

 

 

We Style the Slope cost value areas drawing to use transparent background color for areas.  That represents the areas using only their border outlines, as seen above.  We also delete unused layers from the map and add the Slope cost distance layer.  This provides a clear, and visually appealing, display that shows the borders between regions in the least cost path "terrain" that "drain" into each closest green point.   

 

The display above makes it obvious, with no need to refer to nearby watershed lines, that the least cost path from the magenta square to the closest (by least cost path) green point leads to the green point by the left edge of the window.

 

 

We can add the Slope cost watersheds lines layer to see the relationship of the watershed lines to the boundaries of "drainage" regions, using the Layers pane to reduce opacity to 70% for the Slope cost watersheds lines layer to make the lines slightly less obtrusive.  

 

The display above provides a huge amount of information for over 1.5 million raster pixel locations.  For each such location, we can visually see what is the closest, by least cost path, green point.  We know for sure without guessing because we have crisp boundaries, as vector area boundaries in a drawing, that without any fuzziness delineate one green point's region of pixel proximity from another green point's region.

 

In addition, we have a pattern of watershed lines that we can use as a guide to estimate what the least cost path will be from any pixel in the display to its closest point.   If we would like more detailed guidance, we can create watershed lines using a smaller Minimum flow value for greater detail.

 

Cost for slope Path Type

Path : cost for slope operations are like Path : cost transforms applied to a slope surface, but also using the uphill or downhill direction of slope at any given pixel to compute costs.   The cost for slope path type begins by calculating slopes for the raster, and then computes  lowest cost path distances using the slope for each pixel, where going downhill on a slope has lower cost than going uphill.

 

That is a more sophisticated operation than using Path : cost transforms created on a slope surface from the original raster, as seen in the prior examples, because those examples only reckoned the degree of slope and not the directionality of travel.   Averaged over a large distance, it is true that travel over a route with large slope angles will be more costly than over a flat route.  But when computing the costs of paths in more local regions the direction of travel over slope, whether it is downhill or uphill, can be a critical factor.  The cost for slope path type option automatically incorporates directionality of slope (uphill or downhill) into cost computations.

 

Given a specified channel in the image, and choosing a drawing with points as the Start from drawing, the cost for slope path type option creates a new, single-channel image of the same dimension and pixel size where the value of each pixel gives the result of the transform, as follows:

 

cost for slope : direction

The value of each pixel gives the direction in degrees from that pixel to the next pixel in the least cost slope path to the point in the drawing that is closest, by least cost directional slope path (uphill or downhill), to that pixel.  

 

The direction from each pixel to an adjacent pixel can be only one of eight possible directions, 45, 90, 135, 180, 225, 270, or 315, or 360 degrees,  since adjacent pixels can only be to the left or right, above or below, or at one of four diagonal directions in between.  Direction values will be restricted to those eight values, plus 0 for the pixel coincident with the nearest point.

cost for slope : distance

The value of each pixel gives the distance in native units of the image from that pixel via the least-cost slope path to the point in the drawing that is closest,  by least cost directional slope path (uphill or downhill), to that pixel.  

cost for slope : value

The value of each pixel is loaded with either a sequential number (the Sequential Values choice) or with the content of an attribute field in the points drawing table that provides a value for each point.  Each result pixel is loaded with the Value for the point in the drawing that is closest, by least cost directional slope path (uphill or downhill), to that pixel.  

Controls

The parameters we specify for a cost for slope path type will have a significant effect on the result.

 

 

Low slope, High slope

Allowed minimum and maximum slopes in degrees.   The path will be routed around any pixels that have a slope value less than the minimum slope or greater than the maximum slope.  The slope of a given pixel can be interpreted as a negative slope or a positive slope depending on the direction we are travelling.  

 

The default values of -90 and 90 mean to use pixels with all slopes.  A more realistic scenario is not to walk off a cliff (-90) or to attempt to scale a cliff (90).   We can specify the minimum and maximum slopes acceptable, such as not descending by any slopes steeper than -30 degrees, or ascending by any slopes greater than 30 degrees.  

Low slope cost, Flat cost, High slope cost

The cost of a pixel in the path, based on the slope of the pixel and the Low slope cost, Flat cost, and High slope cost values.   The Low slope cost value is the cost for pixels that have the specified Low slope value of slope.   The High slope cost value is the cost for pixels that have the specified High slope value of slope.  The Flat cost is the cost of a path over flat, that is, zero slope, terrain.   The costs of all other pixels are interpolated, based on their slopes, between the Low slope cost and High slope cost values.

 

The default value of 0 for Low slope cost in most cases will be replaced by 1, so that all pixels have at least some cost.   The default value of 2 for High slope cost in most cases will be replaced by a larger number, such as 100, to allow for a greater range of values between minimum and maximum costs.  It makes sense to make Flat cost about halfway between the Low slope cost and High slope cost values.

Reverse path

Paths in the cost for slope path type are computed by default from each Start from point to each raster pixel in the point's domain.  Checking the Reverse path box switches directionality to compute paths from raster pixels in each point's domain to each Start from point.   Directionality of paths does not matter when using Euclidean or cost path types, but it matters when using cost for slope, because a downward slope path is lower cost than the reverse upward path.

Start from

Choose a drawing layer in the same map that provides starting points for paths.

Start from selection only

When checked, use only selected Start from points in the computation.

Output

Output type:  choose from direction, distance, or value.

Value

Appears when value has been chosen for Output type.   Choose either an attribute field giving the value to use for each Start from point, or choose Sequential Values to automatically assign a unique, sequential number as the value for each Start from point.

Result

Choose a Result destination for the results of the computation.   Choose from Same Field, choose any tile field already in the table, New Field to create a new tile field in the same table along with a New image to visualize that field, or New Table to create a new table to host the result along with a New image to visualize that tile field.

Resources

Choose any constraints, if desired, on CPU parallelism or GPU parallelism.  Everyone simply leaves this at the default setting, all CPU cores, all GPU cores.   We must, of course, have a GPGPU-capable NVIDIA GPU in our computer to use GPU parallelism.  

 

Example - Path : cost for slope : distance

We generate a Path : cost for slope : distance raster using the map below.

 

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile as the field.  

 

We double-click the Path template to launch that template in the Transform pane.

 

 The Path template using cost for slope path type uses a terrain elevation raster layer.  The cost for slope path type operation does not use a slope surface.  Slope values which the operation uses are internally computed on the fly from the terrain elevation raster.

 

 

In the Path template, we choose channel 0 for the Channel and cost for slope as the Path type.    

 

Using Low slope of -30 and High slope of 30 prevents the path from traversing any pixels where the slope of the terrain is less than -30 degrees (too steep downhill) or greater than 30 degrees (too steep uphill).   A range of 1 to 100 for Low slope cost to High slope cost provides a wider range of values, while a Flat cost of 50 is in the middle of that range, to use for zero slope pixels, that is, those in flat regions.

 

The Points drawing will automatically be in the Start from box, since that is the only drawing in the map.    For Output type we choose distance.

 

For the Result destination, we choose New Field and then enter Tile cost for slope distance as the name of the new tile field, and then Cost for slope distance as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview.

 

 

The preview shows the image that will be created, previewing the cost for slope distance values that will be in each pixel using a range of blue preview colors, from dark blue to white.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

Press Transform.  

 

A new image called Cost for slope distance appears in the Project pane.   We drag and drop the new Cost for slope distance image into the map as a layer:

 

 

The result is shown above, Styled with a thematic format using the CB Spectral palette, with hill shading turned on.   Regions of blue show lower cost slope path distances from each pixel to the "closest" point, with blue to yellow to red colors indicating higher cost, that is "longer," paths.   In all cases, the paths are computed only through pixels where no slope in the pixel is greater than 30 degrees or less than -30 degrees.  The apparent ridges in the illustration above divide the region into the equivalent of slope path distance Voronoi cells for each point.

 

The costs of paths are computed considering the direction of travel, since downhill travel over exactly the same pixel costs less than uphill travel through that pixel.  That is a different way to compute path distance than in the example using Path : cost : distance based on a Slope surface.

 

In that example, we first computed a Slope surface on the raster and then we computed cost : distance on that slope surface.   That computation assigned a higher cost to higher slopes, which are always positive values in a slope surface.   The earlier example treats all pixels with steep slopes as higher cost, not considering if the path is headed downhill or uphill.

 

If our objective is to avoid hilly terrain when traversing a region with many changes in elevation up and down, that calculation provides a good result.   However, if we are looking at paths in a region where there is predominant trend to slope, such as plains blending into foothills that blend into mountainous terrain, and we want to incorporate the effects of directionality going uphill or downhill in paths, then we should use cost for slope : distance calculated on the original terrain elevation raster and not cost : distance calculated on a slope surface built from the original terrain elevation raster.

Create Watershed Lines

We can get a visual guide to least cost slope paths from any pixel to that pixel's "nearest" point by creating watershed lines using the Tile cost for slope distance field.

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile cost for slope distance as the field.    

 

We double-click the Watershed template to launch that template in the Transform pane.

 

 

In the Watershed template we choose channel 0 as the Channel and for Output type we choose lines.   We enter 800 as the Minimum flow, to provide a reasonable number of watershed lines to see what is going on but not too many for an overly busy display.   We picked the number 800 by trying different values more or less and choosing the one which in the preview gave a nice display.  

 

New Table is the only choice for the Result.  We enter the name Cost for slope watersheds for the name of the new drawing, with an analogous name for the new table.  

 

Press Preview.

 

 

The preview shows the watershed lines that will be created, in blue preview color.  As before, there is no need to do a preview before applying the transform, but it can be wise to try a preview to make sure we have the template parameters set up the way we like.  When creating watershed lines, it can be helpful to try a few different Minimum flow settings to see what is best for the result we seek.

 

Press Transform.

 

A new Cost for slope watersheds drawing appears in the Project pane.  We drag and drop it into the map:

 

 

We use the Style it to format the new drawing, to provide watershed lines in green, as seen below.  

 

 

From the display of watershed lines we can infer what the least cost, that is, "shortest," slope path is from any pixel to the "nearest" point.   In terrain that is between two green points, the least cost slope paths will be those that balance a greater distance to travel with a more downhill or less uphill path.

 

 

We can see how that works by turning off the watershed lines layer, by turning off hill shading in the Cost for slope distance layer, and by making that layer 80% opaque, so the layer underneath can be seen.  We add a Raster Gray layer, which shows the original terrain in hill shaded gray scale.  The result is a display which preserves the colors showing relative cost of slope paths, while also showing the original terrain elevation surface in hill shaded relief.

 

We can see that the terrain between the point at elevation 165 and the point at elevation 237 is mostly flat, with the terrain starting to rise up nearer to the 237 point.  The dividing "ridge" between the 165 point and the 237 point is closer to the 237 point, thus allocating more terrain to be "nearer", that is connected by lower cost slope paths, to the 165 point.  When calculating total cost, counting both added cost for uphill travel and added cost for a longer path over flat terrain, the added cost of some slight uphill travel near point 237 counts for as much as a greater distance over flat land to point 165.  

 

 

We can turn on the watershed lines layer to help us visualize lowest cost slope paths.

 

 

To see that in the context of the original terrain, we turn off the Cost for slope distance layer, we turn on the original Raster layer, and we add a layer that shows the borders between slope path source regions, which we create in the next example below.

 

This shows how the relative balance in adding up costs from a longer path or a more uphill path affect allocation of shortest paths between point 165 and point 237.  We can also see how least cost slope paths from pixels in the higher terrain surrounding point 346 naturally follow more downhill paths to the point, especially for pixels in the higher terrain to the Northeast of the point.

Example - Path : cost for slope : value

We created the illustration above using borders that were generated using a cost for slope : value operation.  To create a cost for slope : value path type raster we start with the map below.

 

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile as the field.  

 

We double-click the Path template to launch that template in the Transform pane.

 

 The Path template using cost for slope path type uses a terrain elevation raster layer.  The cost for slope path type operation does not use a slope surface.  Slope values which the operation uses are internally computed on the fly from the terrain elevation raster.

 

 

In the Path template, we choose channel 0 for the Channel and cost for slope as the Path type.    

 

Using Low slope of -30 and High slope of 30 prevents the path from traversing any pixels where the slope of the terrain is less than -30 degrees (too steep downhill) or greater than 30 degrees (too steep uphill).   A range of 1 to 100 for Low slope cost to High slope cost provides a wider range of values, while a Flat cost of 50 is in the middle of that range, to use for zero slope pixels, that is, those in flat regions.

 

The Points drawing will automatically be in the Start from box, since that is the only drawing in the map.    For Output type we choose value.   In the Value box, we choose the Height field to provided a value for each point..

 

For the Result destination, we choose New Field and then enter Tile cost for slope value as the name of the new tile field, and then Cost for slope value as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview.

 

 

The preview shows in shades of blue preview color how new zones will be created, with a blue preview caption bar at the top of the window reporting the name of the template being previewed.  

 

Previews are drawn on top of all other layers.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

Press Transform.  

 

A new image called Cost for slope value appears in the Project pane.   We drag and drop the new Cost for slope value image into the map as a layer:

 

 

The resulting raster, seen above as a layer in our map, saves the Height value of each green point into those raster pixels that are closest, by least cost for slope path, to that point.   In the illustration above we have Styled the raster using the same thematic format that was used to color the Path : Euclidean : value result raster in a prior example. 

 

Copying style is a simple matter of launching the Properties dialog for that result raster and Copying the value of the StylePixel property.   We can then Paste that same value into a StylePixel property we create in the Properties dialog for the Cost for slope value raster.  

Trace Areas

The display above shows a raster image, not a vector drawing of crisp boundary lines between regions in which all the pixels have the same value.   To get boundary lines we can create a vector drawing of areas from the Cost for slope value raster.   We can do that using the Trace transform, as illustrated in the Example: Trace Vector Areas from Raster Pixels topic.

 

With the focus on the map, in the Transform pane we choose Raster as the layer and Tile cost for slope value as the field.   

 

Double-click on the Trace template to launch that template in the Transform pane.

 

 

In the Trace template we choose 1 for Similarity.   Each pixel in the Cost for slope value raster has exactly the Height value of the closest (by least cost for slope path) green point, so we choose 1 to get exact matches, in case any of the regions have pixel values that are close together.    We check the Split into shapes option so that non-contiguous regions that have the same pixel values will become separate area objects, and not just different branches of the same area object.

 

We choose New Table for the Result and enter the name Cost for slope value areas for the name of the new drawing, with an analogous name for the new table.   We can use whatever names we like, but it is wise to choose names that remind us what those layers are.

 

Press Preview.

 

 

The preview shows the vector (drawing) layer that will be created, with the area objects shown in blue preview color.

 

 

To see in the preview how those areas relate to the regions of pixels from which they were traced, we can right click the blue preview caption bar at the top of the window and choose Left to show the preview only on the left side of the window, and then we can drag the vertical splitter line left and right to show less or more of the preview as we like.

 

Press Transform.

 

A new Slope cost value areas drawing appears in the Project pane.  We drag and drop it into the map:

 

 

We Style the Slope cost value areas layer to use transparent background color for areas.  That represents the areas using only their border outlines, as seen above.   This provides crisp, black, vector borders between each region of the same Height value pixels.  

 

 

We can see the relationship of the watershed lines to the boundaries of the regions by adding the Cost for slope watersheds drawing.

 

 

To see how the boundaries and watershed lines relate to the least cost, "closest," slope path from each pixel to the green point for each region, we can remove the Cost for slope value layer and add the Cost for slope distance layer.

 

 

Last, to see how boundaries and watershed lines for least cost, "closest," slope path from each pixel relate to the original terrain, we can turn off the Cost for slope distance layer so the original Raster terrain elevation layer can be seen.

 

As with prior illustrations, the display above provides a huge amount of information for over 1.5 million raster pixel locations.  For each such location, we can visually see what is the closest green point by least cost for slope path, computed by taking into account the direction of paths, which cost less going downhill as compared to uphill.   The crisp boundaries, as vector area boundaries in a drawing, exactly delineate each green point's region of pixel slope path proximity from another green point's region.

 

In addition, we have a pattern of watershed lines that we can use as a guide to estimate what the least cost slope path will be from any pixel in the display to its closest point.   If we would like more detailed guidance, we can create watershed lines using a smaller Minimum flow value for greater detail.

Example - Path : cost for slope : direction

The Path template using cost for slope path type with direction output provides the direction from each point to the next point in the least cost for slope path to the "nearest" green point.

 

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile as the field.  

 

We double-click the Path template to launch that template in the Transform pane.

 

 The Path template using cost for slope path type uses a terrain elevation raster layer.  The cost for slope path type operation does not use a slope surface.  Slope values which the operation uses are internally computed on the fly from the terrain elevation raster.

 

 

In the Path template, we choose channel 0 for the Channel and cost for slope as the Path type.    

 

Using Low slope of -30 and High slope of 30 prevents the path from traversing any pixels where the slope of the terrain is less than -30 degrees (too steep downhill) or greater than 30 degrees (too steep uphill).   A range of 1 to 100 for Low slope cost to High slope cost provides a wider range of values, while a Flat cost of 50 is in the middle of that range, to use for zero slope pixels, that is, those in flat regions.

 

The Points drawing will automatically be the Start from selection, since that is the only drawing in the map.    For Output type we choose direction.

 

For the Result destination, we choose New Field and then enter Tile cost for slope direction as the name of the new tile field, and then Cost for slope direction as the name of the new image to show that new tile field.  We could use whatever names we wanted 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 Preview.

 

 

The preview shows the image that will be created, previewing the cost for slope distance values that will be in each pixel using a range of blue preview colors, from dark blue to white.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

 

Right-clicking the caption bar and choosing 50% opacity, we can see the complex relationship between the result and the underlying terrain.

 

Press Transform.  

 

A new image called Cost for slope direction appears in the Project pane.   We drag and drop the new Cost for slope direction image into the map as a layer:

 

 

We Style the Cost for slope direction raster the same as the Euclidean direction layer shown in a prior example, using the CB spectral palette on Channel 0 (the only channel in a single-channel raster) to thematically format the pixel values from 0 to 360.  The 0 to 360 value in each pixel gives the direction from that pixel to the closest green point.   Remember:  the direction is toward the green point, and not a compass direction away from the green point.   The direction value of a pixel that is located to the North of a green point, with pixels colored in shades of yellow, is about 180, that is, one must head in a direction of South to go toward the point.

 

 

We can provide crisp borders between regions by adding the Cost for slope value areas layer.  

 

The above display is typical of direction rasters for path distance or slope path distance. The color values are quantized to being one of eight values, because the direction must be one of eight values, since the direction of the path from each pixel to the next pixel can only go to one of four pixels to the left, right, up, or down, or to one of the four pixels at a 45 degree angle.

Reverse path

Paths in cost for slope operations are computed by default from each Start from point to each pixel in that point's domain.  Checking the Reverse path box switches directionality to compute paths from pixels in a point's domain to each Start from point.  The direction matters because a downward slope path is shorter, that is, lower cost, than the reverse upward path.

 

 

With the focus on the map, in the Transform pane we choose the Raster layer and Tile as the field.   We double-click the Path template to launch that template in the Transform pane.  

 

 

In the Path template, we choose channel 0 for the Channel and cost for slope as the Path type.    We use default settings for the various slope and cost boxes.   For Output type we choose distance.

 

We run the template twice, without and with the Reverse path box checked.   When the box is not checked we name the new image Start from points distance, since the default is to compute paths starting from points and proceeding to pixels.   When the Reverse path box is checked we name the new image Start from pixels distance.

 

Comparing the results using identical thematic format to color and hill shade the resulting cost for slope distance rasters, we can see the difference, subtle at times, between default direction and checking Reverse path:

 

 

For example, in the default Start from points distance raster, the region above and to the right of point 346 has a relatively narrow extension.

 

 

Checking the Reverse path box to create the Start from pixels distance raster, the same region above and to the right of point 346 has a wider extension.

 

The illustrations above show cost for slope distance between each pixel and the closest by cost for slope green point.    If we start walking from any pixel in the raster, the Start from pixels distance raster illustration above tells us which green point we can reach with the lowest total cost expenditure, considering that walking downhill on a slope costs us less than walking uphill.

 

If the region illustrates terrain in a forest of sugar maple trees and each green point marks a collection point for sap, we might use the Start from pixels distance surface to plan a network of tubes that deliver sap from each individual maple tree to the "closest" (lowest cost to reach) collection point.

 

The default Start from points distance raster shows directions from each green point to pixels in that point's domain.   If we start walking from one of the green points, the Start from points distance raster tells us which pixels in the raster we can reach at a lower cost than the cost of reaching those pixels from one of the other green points.   

 

If the region illustrates terrain in a truffle plantation of hazel nut and oak trees inoculated with black truffle mycelium, and each green point marks an irrigation source, we might use the Start from points distance surface to plan a network of irrigation lines that deliver water from each irrigation source to individual trees in the "closest" (lowest cost to reach) domain of that  irrigation source.

Sequential Values

When using the value Output type for Euclidean, cost, or cost for slope Path type we can assign a value to every pixel in each Start from point's domain by either taking the value from an attribute field for each point, or by assigning a unique, sequential number (sequential value) for each point.    We can use the Sequential Value choice when we do not care about having a specific value for pixels in each point's domain but we simply want each domain marked with a different number for the pixels in that domain.

 

 

We start with a sample map that has a Raster layer containing a terrain elevation raster, and a Points layer containing points.

 

 

Each point has an attribute field called Height that gives the height of that point.  Heights were computed for each point based on the height of the terrain in the Raster layer at that point's location.  

 

With the focus on the map, in the Transform pane we choose the Raster layer and the Tile field in that layer.   We double-click the Path template to launch it in the Transform pane.

 

 

We choose channel 0 for the Channel and  Euclidean for the Path type.  We could use either cost or cost for slope for the path type, but we use Euclidean for a simple illustration.  The Start from drawing is Points, the only drawing we have in the map.

 

For Output type we choose value.   We now run the transform twice, first choosing the Height field as the Value for the output, and then we run the transform again choosing Sequential Values for the Value.    In both cases we choose New Field to add a new tile field to the table, and we choose names for the new field and the new image that match what we chose as a Value option, using the names Height values and Sequential values, so we can easily know what we did to produce the two different results images.

 

 

The Height values result image assigns the value of the Height field from each point to every pixel in that point's domain.   We can Style the Height values image the same as the raster from which it was created.   All of the pixels in each domain region have the same value, with their color being taken by interpolation from the thematic format shown in the Style pane illustration based on where the domain point's Height value falls within the thematic formatting intervals.

 

 

The Sequential values image does not use Height field values for each pixel in each point's domain.  Instead, it simply assigns a sequential integer number, starting with 0, to each point and then uses that number as the value for all pixels in that point's domain.   For example, the point labeled 561 was assigned a value of 0 and thus all pixels in that point's domain have been assigned a value of 0.   The point labeled 449 was assigned a value of 1 and thus all pixels in that point's domain have been assigned a value of 1.    We have styled the Sequential values image using a thematic format for unique values, since each pixel in the Sequential values image has a value from 0 to 7 inclusive.

 

 

If we like, we can style the Height values image using a thematic format for unique values, since each pixel in the Height values image has one of the values found in the Height field in the points table.  In the illustrations above we have manually assigned colors to the eight intervals generated by unique values that match the interval colors used in the original thematic format for the Raster layer.   The colors for regions in the Height values image end up slightly different than in the prior illustration for the Height values image, because now each color is exactly assigned and is not interpolated depending on where the exact height value falls within the range of thematic formatting intervals.

 

The rule of thumb is to use Sequential Values when we do not care what value gets assigned to pixels in each point's domain, but we simply want the values for different regions of pixels to be different.

 

Notes

Faster than reading - However long it takes to read this topic the first time, the astonishing thing about Manifold is how the examples in this topic can be done, start to finish, in just a few minutes in real life. See how fast the workflow can be in the Closest Rasters - Paths  video.   Manifold is stunningly fast with raster calculations as used in this topic, so we can do Slope calculations in seconds,  Path transforms in a few seconds, and also Watershed Lines and Trace in just a few seconds each as well, even with impressively large rasters.

 

Add 1 to Slopes - In our workflow for examples above where we computed Path transforms on a slope that we created from the terrain elevation raster, we missed a slight nuance.  When computing paths through pixels with the Use equal costs box not checked, that is, where the value of each pixel is a cost, it is best to use nonzero values in pixels.   If there is a great swath of pixels that are all zero valued then all distances through that swath are the same, which can lead to ambiguous results.   Instead, make sure the value of each pixel is non-zero, including for all slopes.  This is easy to do: use the Add transform template for images to add a small, non-zero amount, such as 1, to each value.  That will ensure all formerly zero pixels now at least have a value of 1, while all other pixels are shifted upward slightly the same way.  The cost for slope transforms handle this automatically by allowing a value for Flat cost, which is nonzero by default.

 

A very raster approach - Contemporary GIS tends to be more vector oriented than the greater raster emphasis GIS might have had in the past.  The Path template and classic analogs in ESRI's Distance tools might seem unusual for such a raster-oriented approach to analytics.  But when raster data is the best way to capture information that covers an entire region, raster analytics combined with vectors can be the best way to gain insight and to solve problems.

 

Indexes and Interpolation - If we try this topic at home, we might be surprised when redoing the Path : Euclidean : direction transform example to see vertical lines appear in the resulting raster when thematically formatting it, as seen below:

 

 

Vertical lines appear under some of the green points, with more or fewer vertical lines appearing depending on zoom level.

 

 

 

 

If we zoom far enough, all of them disappear.  Why do such vertical lines appear, when they do not appear in the raster generated and styled in this topic, as seen below?

 

 

The illustrations in this topic also show smoother transitions between Voronoi regions of different color.   Why is that?    The answer is that the illustrations used in this example do not show an extra step taken to eliminate the vertical lines.   That same extra step provides smoother transitions at some zoom levels.   

 

 

Consider the raster image seen above, with the Index on tiles from the Schema dialog for that image's table shown below.

 

 

When Manifold transforms build rasters, by default the raster's tile table is created with an X_Y_Tile_x index that uses a TILEREDUCE setting of average.   We can see that by opening the raster's tile table, launching the Schema dialog, and double-clicking the X_Y_Tile_x index to see the parameters with which it was created.   The Reduce box will show a setting of average, as illustrated above.

 

The TILEREDUCE setting specifies how pixel values will be interpolated when the display is zoomed out so that a single screen pixel covers a region with multiple data pixels.   Choosing the average value of pixels to be interpolated into a single screen pixel provides a better visual interpolation for most raster data, but it is not the best when raster data values are compass directions and pixels suddenly jump from 360 degrees to 1 degree.  

 

Suppose we zoom our Euclidean direction raster so a single pixel on screen covers two data pixels, right at the transition from 360 to 0 degrees: one data pixel might have a value of 1 and the other might have a value of 360.  Our thematic format would use a purple color for each.  However, if the on-screen interpolated chooses the average value of 360 and 1, that arithmetic average is 180, a color value which our thematic format renders as yellow color.  

 

That is why in some cases in the display above there is a vertical line of yellow color within a zone of purple color.   The pixels in those lines are interpolated averages, where more than one pixel from the data was interpolated down into a single pixel for display on the screen, and the arithmetic result of averaging values near 0 and values near 360 were values near 180: shades of yellow.

 

 

Consider a different raster image seen above, with the Index on tiles from the Schema dialog for that image's table shown below.

 

 

The trick we used for illustrations in this topic is that after the raster was created, using default settings, we opened the Schema dialog for the raster's tile table and we deleted the X_Y_Tile_x index that was created by default.  We then manually recreated the X_Y_Tile_x index, but choosing indexed for the Reduce parameter, as shown by the arrow in the dialog illustration above.  

 

Choosing indexed instead of average forces a choice of one of the existing pixel values that are interpolated down into whatever pixel appears on screen.   If two pixels must be interpolated into a single display pixel, and those two pixels have values of 1 and 360, either the 1 value or the 360 value will be picked.   Our thematic format colors both values as purple, so no matter which one is picked the pixel that appears on screen will be purple as well.

 

If we are in an SQL frame of mind, we can see how transform templates create by the default  X_Y_Tile_x index:  choose the transform template desired and then press the Edit Query button to see the SQL the template uses.    In the CREATE TABLE statement, the index is created in the line:

 

  INDEX [X_Y_Tile_x] RTREE ([X], [Y], [Tile] TILESIZE (128, 128) TILETYPE FLOAT64),

 

By default, no TILEREDUCE parameter is specified, so the index is created as if a TILEREDUCE of 'AVERAGE' was specified.    If we wanted an indexed Reduce, we could manually change that one line in the SQL to add a TILEREDUCE specification:

 

  INDEX [X_Y_Tile_x] RTREE ([X], [Y], [Tile] TILESIZE (128, 128) TILETYPE FLOAT64 TILEREDUCE 'INDEXED'),

 

That will create the tile table for the raster using an indexed Reduce.   

 

It would have been smarter for this topic, to have created the Euclidean direction raster by making that slight addition to the SQL generated by the Path : Euclidean : direction template.  Since we can use the Query Builder in the Command Window to add TILEREDUCE 'INDEXED' with a few clicks, that is much easier than the extra clicks, keyboarding, and thought involved in opening the Schema dialog, deleting an index, and then manually recreating it to use an indexed Reduce.

 

It should be emphasized that the default choice of templates to build tile indices using an average Reduce is a good thing.  Only in rare situations such as averaging compass degrees along discontinuous boundaries does indexed Reduce provide better visuals.  It is possible that future builds may detect when templates place compass direction values into pixels, and automatically use TILEREDUCE 'INDEXED' when creating the tile index for tile tables.  Until then, we now know how to do that manually, if desired.

Videos

Closest Rasters - Paths - See how Manifold's new "Closest" tools compare to ESRI's "Distance" tools in Spatial Analyst.  Starting with a map that has a terrain elevation raster and a drawing with eight point objects, in a mere five minutes of actual GIS work we create a slope surface from a terrain elevation surface,  and we create a least cost path from every pixel to the closest point counting slope values as costs. Next we create watershed lines we can use to visualize those paths.  We then generate a least cost source raster, from which we create a drawing of area borders that delineate each source point's region. Wow!  All that in five minutes!  Add a few minutes of tips and explanations and you can see how Manifold can do in minutes what takes hours in other packages.  Works in the free Viewer, too!

 

Manifold vs Arc - Costs and Paths - 9 seconds vs 12 minutes - An ambitious video comparing four Spatial Analyst geoprocessing tools - Cost Back Link, Cost Distance, Cost Allocation, and Path Distance with Vertical Factor - to equivalent tools in Manifold using a 5300 x 5300 terrain elevation raster. Works in the free Viewer, too! Manifold takes only three or four seconds to produce what requires two minutes in ArcMap with Spatial Analyst to produce using the first three tools. The big surprise is how Manifold takes less than 9 seconds for the Path Distance computation, while Spatial Analyst takes over twelve minutes.  Arc users will often use Manifold as a power processor for big data crunching that takes too long in Spatial Analyst: it is far quicker to export data to Manifold, do the job in seconds and then import it back into Arc, than it is to wait for long jobs in Arc.

 

Manifold vs Arc - Paths around Barriers - 7 seconds vs 8 minutes -  Computing Path Distances and Costs around barriers in rasters is a complex task for any high-end GIS.  We compare Manifold System Release 9 to ESRI's Spatial Analyst running in ArcMap, using the geoprocessing tools Cost Back Link, Cost Distance, and Path Direction using Vertical Factor.   Manifold is fully parallel and runs all 48 threads in the machine at 100% utilization, while the ESRI toolset is only partially parallel, running a maximum of 9 instances with less than 30% utilization.  The result is Manifold can do in 3 seconds what takes Arc 25 seconds, with Path Distance taking 7 seconds in Manifold but 8 minutes in Spatial Analyst.  Whoa!  That's 70 times faster for Manifold.   Everything shown in the video works in the free Manifold Viewer, too!

 

Manifold vs Arc - Euclidean Barriers - 7 seconds vs 1 minute -  Calculating Euclidean Distances around barriers is a brand new feature in ESRI's Spatial Analyst, so cool and useful that Manifold has implemented Euclidean computations around barriers as well, but in fully parallelized form that runs significantly faster than Spatial Analyst, typically taking 7 seconds for what requires a full minute with ESRI.  The video shows Euclidean Allocation, Euclidean Distance, and Euclidean Back Direction compared to Manifold Release 9, with all calculations working around barriers in both cases.  Works in the free Viewer, too!  Download Viewer and see the incredible speed of Manifold on your own computer!

See Also

Tables

 

Maps

 

Drawings

 

Images

 

Labels

 

Style

 

Style: Thematic Formatting

 

Transform Pane

 

Transform Topics

 

Transform Reference

 

Transform - Tiles

 

Watersheds

 

Example: Trace Vector Areas from Raster Pixels - We use the Trace Areas template in the Transform pane for images to create a drawing with vector areas covering regions of similarly-colored pixels.  Next, we use a simple query to add classification codes from a USGS table of classes to the resulting drawing, using a simple INNER JOIN SQL statement.