# Rivers And Lakes

This is the first of three posts, where I will describe the process of creating river systems in the project. In this post the algorithm for constructing and smoothing rivers will be described, in general terms. The second post will contain information on how to make river banks more realistic. And the third post will be with the program code, which is used to create the final river form.

## Lakes

Firstly, some information about the lakes. In the procedural generation of maps, as a rule, lakes are formed at the moment when sea level is defined. Areas below a certain height is considered water, higher areas are land. Isolated parts of water are lakes.

But in this case we do not take into account all hollows (pits) in the terrain which are above sea level. In nature there can be lakes in such places and rivers can flow into these lakes.

In the project I make a lake in almost each terrain pit, sometimes there is a large lake covers a few pits. It is possible to regulate the limits of absolute or relative depth (in relation to the depth of the pit) of lakes. At the moment, the amount of water flowing into the lake does not affect the size of it and there are no outflowing rivers from lakes. Implementation of these features seems rather complicated, so I postponed it for later. ðŸ™‚

Those lakes that are obtained by setting the sea level are also present in the project and are called lowlakes.

## River systems

As you can learn from previous posts, the relief is constructing on some two-level regular lattice of points. At the lower level, these are the points inside a rhomb on the projection cone.

At first the river is made as some curved line on the lattice points. The resulting line is called the river line. To put simply, the algorithm for creating a river line is as follows:

• In each rhomb we randomly select the source point of the new river and then choose the random outflow point on the rhomb edge. Here we must ensure that the height of the outflow point is less than the height of the source point. In the next versions of the project there will be several river sources for a rhomb and their number will vary depending on the type of the terrian and, possibly, the type of the biome.
• The line inside the rhomb is drawn by the brownian motion simulation method (not exactly what’s on the link but close). Possible loops are eliminated.
• In subsequent rhombs we draw a line from the source, which corresponds to the outflow point in the previous romb, to the new outflow point.
• This process continues until we flow into either the ocean, or in a lake pit, or into another already made river (trunk).

There is the special order in drawing river lines, firstly we should draw rivers which have source far from the ocean and in the mountains. By this we achieve what is observed in the Earth rivers: the most big rivers begin in the mountains or far from the ocean.

The river line is far from what we would want to see on the map. To represent the river on the map few more things are required.

• Smoothing of the river line.
• Giving the river a width and turning it into a polygon.

In the project I use a simple and effective method of smoothing, which consists in aligning each point as a midpoint between the previous point (already aligned) and the next point (not yet aligned). To better preserve the characteristic behavior of the original line we can pre-insert additional midpoints in the original line, and then make smoothing.

The images of the original (typical) river line and line recieved after smoothing are on this picture.

As it turned out, with the increase in the ‘thickness’ of the river, additional points become excessive, and for the thickest rivers even the initial points of the river line are too many; such rivers become more like a long caterpillar. Therefore, for wide rivers, some points are firstly evenly removed, and the remaining ones are smoothed.

How to draw a line of a suitable width from a thin river line we will study in the third post. Now you can just look at the results on the three pictures below.

On the first picture a river of minimum width of those that are currently depicted on the planets. The second and third pictures show rivers which are by two and four times wider than the first. Respectively, there are only every second and every fourth point remains in them, remainder points are aligned. For rivers with an intermediate width, the uniform elimination of points on the interval can be applied.