r.lake(1grass)
๐ r.lake โ GRASS User's Manual, but make it a group chat ๐
okay so bestie, pull up a chair (or a beanbag, whatever) because we're talking about r.lake, and it's literally the moment. It's a GRASS module. It's one of those 1grass ones. It's giving hydrology. It's giving flood. It's giving iconic.
โจ NAME โจ
r.lake โ fills lake at given point to given level. ๐ซถ
๐ท๏ธ KEYWORDS ๐ท๏ธ
raster, hydrology, hazard, flood โ the whole vibe check passes, no notes. ๐
๐ SYNOPSIS ๐
r.lake
r.lake --help
r.lake [-no] elevation=name water_level=float [lake=name]
[coordinates=east,north] [seed=name] [--overwrite] [--help]
[--verbose] [--quiet] [--ui]
๐ฉ Flags ๐ฉ
-nโ use negative depth values for the lake raster map. yes, negative. we'll get to why, bestie, hold on.-oโ overwrite the seed map with the result (lake) map. spicy, but legal. ๐ฅ--overwriteโ allow output files to overwrite existing files (the classic).--helpโ print usage summary. your bestie when you're lost. ๐ฅบ--verboseโ verbose module output. it will tell you Everything.--quietโ quiet module output. it will tell you Nothing. the duality.--uiโ force launching GUI dialog. for the visual girlies. โจ
๐ Parameters ๐
elevation=name[required] โ name of input elevation raster map. mandatory, bestie, no skipping. โญwater_level=float[required] โ water level. also mandatory. also in DEM units, jsyk.lake=nameโ name for output raster map.coordinates=east,northโ seed point coordinates. either this coordinates pair or a seed map have to be specified โ pick one, you can't have both vibes at once. ๐ธseed=nameโ input raster map with given starting point(s) (at least 1 cell > 0). either this parameter or a coordinates pair have to be specified. same deal. ๐
๐ง DESCRIPTION ๐ง
So r.lake fills a lake to a target water level, starting from a given start point. The way that the user can think of it as r.grow with additional checks for elevation โ like r.grow but with trust issues and a level requirement. ๐ญ
The resulting raster map contains cells with values representing lake depth, and NULL for all other cells beyond the lake. Lake depth is reported relative to the specified water level (specified level = 0 depth). So the water level is like your zero line. clock it. ๐
This module uses a 3x3 moving window approach to find all cells that match three criteria and to define the lake:
- cells are below the specified elevation (i.e., water level);
- cells are connected with an initial cell (seed or coordinates pair value);
- cells are not
NULLor masked.
The water level must be in DEM units. periodt.
๐ NOTES ๐
The seed (starting) point can be a raster map with at least one cell value greater than zero, or a seed point can be specified as an E, N coordinate pair. If the seed is specified as a coordinate pair, an additional check is done to make sure that the target water level is above the level of the DEM. When a raster map is used as a seed, however, no such checks are done. ๐ Specifying a target water level below the surface represented by DEM will result in an empty map (sad, and also literally nothing in it). Note: a raster lake map created in a previous run can also be used as a seed map for a new run to simulate rising water levels. the continuity of it all โจ
The module will create a new map (lake=foo) or can be set to replace the input (seed=bar) map if the -o flag is used. The user can use the -o flag to create animations of rising water level without producing a separate map for each frame. An initial seed map must be created to start the sequence, and will be overwritten during subsequent runs with resulting water levels maps (i.e., a single file serves for both input and output). one file doing both jobs? main character energy. ๐
Negative output (the -n flag) is useful for visualisations in NVIZ. It equals the mapcalc's expression "negative = 0 - positive".
๐งฎ r.mapcalc equivalent - for GRASS hackers ๐งฎ
This module was initially created as a script using r.mapcalc. This had some limitations โ it was slow and no checks where done to find out required iteration count. The shell script code (using r.mapcalc) used in the original script is shown below:
${seedmap} = if( ${dem}, \
if( if( isnull(${seedmap}),0,${seedmap} > 0), ${wlevel}-${dem}, \
if( \
if(isnull(${seedmap}[-1,0]),0, ${seedmap}[-1,0] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[-1,1]),0, ${seedmap}[-1,1] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[0,1]), 0, ${seedmap}[0,1] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[1,1]), 0, ${seedmap}[1,1] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[1,0]), 0, ${seedmap}[1,0] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[1,-1]),0, ${seedmap}[1,-1] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[0,-1]),0, ${seedmap}[0,-1] > 0 && ${wlevel} > ${dem}) ||\
if(isnull(${seedmap}[-1,-1]),0, ${seedmap}[-1,-1] > 0 && ${wlevel} > ${dem}),\
${wlevel}-${dem}, null() )))
The ${seedmap} variable is replaced by seed map names, ${dem} with DEM map name, and ${wlevel} with target water level. To get a single water level, this code block is called with the same level numerous times (in a loop), because the lake grows by single cells during a single run. the patience of it honestly ๐ง
๐จ KNOWN ISSUES ๐จ
bestie. read these. they are not cute. they are just true. ๐ญ
- The entire map is loaded into RAM. all of it. in your memory. be aware. ๐
- A completely negative seed map will not work! At least one cell must have a value
> 0. Output fromr.lake -ncannot be used as input in the next run. (so the negative thing is a one-way trip, lowkey.)
๐ EXAMPLE ๐
Example of small flooding along a street (North Carolina sample dataset):
g.region raster=elev_lid792_1m -p
# water accumulation next to street dam
r.lake elev_lid792_1m coordinates=638759.3,220264.1 water_level=113.4 lake=flooding
# draw resulting lake map over shaded terrain map
r.relief input=elev_lid792_1m output=elev_lid792_1m_shade
d.rast elev_lid792_1m_shade
d.rast flooding
d.vect streets_wake
Small flooding along a street (r.lake, using Lidar 1m DEM). ate, honestly. ๐
๐ SEE ALSO ๐
r.mapcalc, r.grow, r.plane โ the friend group. ๐ซถ
๐ AUTHOR ๐
Maris Nartiss (maris.nartiss gmail.com). thank you for your service. ๐
๐ป SOURCE CODE ๐ป
Available at: r.lake source code (history)
Latest change: Tuesday Feb 18 17:20:26 2025 in commit: 688e625e7db3be9a465ce99ba25f36d2ebdd5aeb
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
okay so that's the whole thing, and now the cute sign-off because you made it to the end: this was the GRASS 8.5.0 Reference Manual, ยฉ 2003-2026 GRASS Development Team, brought to you by GRASS 8.5.0 and that Feb 18 2025 energy. slay, stay flooded, hydrate (ironically), bye bestie ๐โจ๐
๐ฆ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 ยท GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms