d8_flow_direction#

Signature#

d8_flow_direction(elevation) → Field#

Determine direction each cell drains towards

Parameters:

elevation (Field) – Floating point array

Returns:

New integral array

Description#

Focal operation for determining the direction each cell drains towards. Directions are encoded by an integral number. Each number represents one of eight flow directions and the sink “direction”:

code

direction

7

↖ north-west

8

↑ north

9

↗ north-east

4

← west

5

■ sink

6

→ east

1

↙ south-west

2

↓ south

3

↘ south-east

No-data handling#

A cell containing a no-data value in the input array results in a no-data value in the corresponding output array. No new no-data values are generated.

Example#

LUE_Field* elevation = lue_from_gdal(elevation_array_pathname);
LUE_Field* flow_direction = lue_d8_flow_direction(elevation);

lue_to_gdal(flow_direction, flow_direction_array_pathname, NULL);

lue_destruct(elevation);
lue_destruct(flow_direction);
Field const elevation = from_gdal(elevation_array_pathname);
Field const flow_direction = d8_flow_direction(elevation);

auto written = to_gdal(flow_direction, flow_direction_array_pathname);
elevation = lfrx.from_gdal(str(elevation_array_path))
flow_direction = lfrx.d8_flow_direction(elevation)

lfrx.to_gdal(flow_direction, str(flow_direction_array_path))

elevation

flow_direction

elevation

flow_direction

Source code: C, C++, Python

See also#

  • …