[GRASS-user] r.terraflow usage (segfault)

Markus Neteler neteler at osgeo.org
Fri Nov 14 04:22:03 EST 2008


On Thu, Nov 13, 2008 at 7:23 PM, Massimo Di Stefano
<massimodisasha at yahoo.it> wrote:
> Hi
>
> i'm tring to use "r.terraflow"
>
> following the help page i see :
>
> r.terraflow elev=spearfish filled=spearfish-filled \
>    dir=spearfish-mfdir swatershed=spearfish-watershed \
>    accumulation=spearfish-accu tci=spearfish-tci
>
>
> but i can't find any "spearfish" elevation data in the spearfish dataset
> so i used elevation.dem insted,

I have fixed the nonsense example to

r.terraflow elev=elevation.10m filled=elevation10m.filled \
    dir=elevation10m.mfdir swatershed=elevation10m.watershed \
    accumulation=elevation10m.accu tci=elevation10m.tci


> but i've a segfault :-/

Me, too.

This hack seems to cure the problem:
Index: main.cc
===================================================================
--- main.cc     (revision 34205)
+++ main.cc     (working copy)
@@ -211,7 +211,13 @@
   struct Cell_head cell_hd;
   if (G_get_cellhd (cellname, mapset, &cell_hd) < 0)
     G_fatal_error(_("Cannot read header of [%s]"), cellname);
-
+
+  /* get the current region and dimensions */
+  region = (struct Cell_head*)malloc(sizeof(struct Cell_head));
+  assert(region);
+  if (G_get_set_window(region) == -1) {
+    G_fatal_error("r.terraflow: error getting current region");
+  }
   /* check compatibility with module region */
   if (!((region->ew_res == cell_hd.ew_res)
                && (region->ns_res == cell_hd.ns_res))) {

but I dunno much about C++.

Markus


More information about the grass-user mailing list