[GRASS5] New module for lake filling

Māris Nartišs maris.gis at gmail.com
Mon Jan 9 09:18:00 EST 2006

As my first attempt to contact dev list failed (my mail was eaten by
mail daemons ;), I resend my first mail.


I send to You my first peace of C code (after hello world ;). As a
newbie I would like to hear any feedback about this code:
1) Is idea worth to be included in GRASS some day?
2) Any comments about programming in GRASS and C in general.

NAME: r.lake (original ;)

PURPOSE: This module fills lake at given level from start point (seed) on DEM.

HOW it works: it assigns depth value to all cells which are connected
to start point and are below water level. Filling is done by moving
window multiple times (as necessary) across map. Output map depth
values are positive, but it is possible to output negative values
(units below water surface) for visualisation purposes.

- 3d output. Current output is 2d + depth value;
- nice blue gradient for output map;
- documentation with examples - in progress.
- other ideas?

- seed map cannot be negative - cannot use negative lake output maps as input.

HOW to use:
input = DEM
seed = raster with at least one cell below water level with value > 0
lake = new output raster file
wl = water level in DEM units
-n = output map will have negative values
-o = overwrite seedmap instead of using "lake"

Last spring I was working on my master thesis and needed way how to
find lake shape, depth if only single bank point is known. As I could
not find existing method in GRASS, someone on GRASS user list
suggested to use r.mapcalc. I wrote script that calls r.mapcalc and
fills lake cell by cell. On 3 GHz P4 it took about 24 - 48 h to finish
single lake map. This autumn I read "teachyourself C in 24h" and
rewrote it in C. Now - after some testing and improving - here it is
:) Now I can get my lake in less than minute even on my 800 MHz
Celeron :)
There has been request from users for such functionality on GRASS user
list, so, IMHO after this module will be checked, tested etc, it could
be useful for other ppl too.

CHANGES: Added gettext support by Markus Neteler;
-o flag = in/out separated.

Maris Nartiss
-------------- next part --------------
A non-text attachment was scrubbed...
Name: r_lake.zip
Type: application/zip
Size: 3445 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20060109/6ceaff67/r_lake.zip

More information about the grass-dev mailing list