6. Fill Sinks and Calculate Flow Direction

6.4. Styling the Flow Direction Layer using a Circular Color Ramp

A flow direction layer indicates the direction of flow for each pixel. Direction can be expressed as compass direction, however we can not store text in a raster. Compass direction can also be expressed by degrees on a circle where north is 0 degrees, east is 90 degrees, etc. To store 360 degrees we would need more than 8 bits (0-255), which would increase the file size. In addition the D8 method uses discrete directions to the surrounding pixels. Therefore, GIS software recodes the 8 directions. Each software, however, does it in their own way. The PCRaster LDD format uses the values of the numeric keypad for the directions.

Besides knowing the encoding of the compass directions in the raster, we also need to apply a directional or circular color ramp instead of a linear one that we have used until now for continuous rasters. In this section, we will define a circular color ramp to intuitively show southern oriented flows with warm colors and northern facing flows with cool colors.

We will use the Raster Attribute Table for that.

1. Open the Layer Styling panel for the flowdirection layer.

2. Change the renderer to Paletted/Unique values, because the flow directions are encoded in discrete values from 1 to 9. Click Classify to assign random colors to the cell values.

3. Right-click on flowdirection in the Layers panel and choose Create Raster Attribute Table.


4. In the New Attribute Table pop-up choose the default Managed by the data provider, which is the GDAL auxiliary XML format, and click OK.


Now you'll see the new raster attribute table.

5. Toggle on the editing of the attribute table by clicking  .

6. Edit the values in the Class field to reflect the compass directions as text.

7. Change the colors in the Color field by clicking on the colors and using the RGB values from this figure:



8. Toggle off the editing and save the changes. Click Classify to apply the changes and click Close to close the attribute table.

When you blend the flowdirection layer with the hillshade layer the result looks like this:

Flow Direction with a Circular Color Ramp