Category Archives: All

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.


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.

Change Log: 0.6.1

  • Rivers get some random variance in their width along the stream.
  • riversz shapefile also gets the trunk field which contains the id of the trunk river in which this river flows into. The special value -3 denotes that this river flows into the ocean. Currently, rivers in riversz shapefile do not take into account lakes.
  • PNG tiles and shapefiles of Admete planet was updated respectively.

In the next 2-3 posts I will describe the process of river constructing. And for a while the river system will remain as it is. At the beginning of the new year I will try to make the planet continents look more like Earth continents with intermittent mountainous and flat areas, and not with one or two central mountains as it is now. The resolution of the planets will still be small (as it is now), it will be increased only after all the significant problems will be solved.

Change Log: 0.6

Quite a large update changing the rivers generation.

  • Visible river width depends on the streamflow (discharge) of water flowing in it.
  • All geographical features data are now in EPSG:3785 projection (Mercator).
  • In addition to rivers as multipoligons in rivers shapefile, there are also rivers as 3D-multilinestrings with z coordinate in riversz shapefile. The latter is a schematic representation of the river system trees.

New example planet added. Also corrected and expanded the tutorial on making a map in the equirectangular projection.

Site update: planet views

Finally, I came to use maps for planet modeling. Using a popular tree.js library I intend to show all new planet maps on the sphere model, along with the flat tile map. Textures for spherical models are made from image maps in the equirectangular projection. Texture files are located in the appropriate planet directories (/planets/<planetNo>/equirectangular.png and /planets/<planetNo>/equirectangular-big.png).

In the tutorials section I added a new tutorial on making maps in the equirectangular projection.

Also, for people who want to do planet modeling with javascript, I made simple helper functions.

Change Log: 0.5

The changes mainly relate to the generation of the relief.

  • The way of local relief generation in rhombuses is changed. This significantly reduces the likelihood of undesirable crevices and ridges.
  • Vertical relief scaling; relief features are of different size depending on the height of the terrain. The parameters of the fractal are still constant everywhere.
  • Eartherization process now done separately for each landmass, and not for the whole planet. (Eartherization is making the statistical distribution of planet heights close to that on Earth)
  • The maximum height on each landmass is defined by the function of the landmass size. Currently it is the square root of the landmass size.
  • New color map style.
  • Fixed bug with rivers because of which strange lakes near the rivers were made.
  • Fixed bug in sea coastline making which manifested itself in cutting off coasts.