[GRASS5] [GRASSLIST:1551] Use of neighbourhood operator in r.mapcalc
Hamish
hamish_nospam at yahoo.com
Tue Oct 28 20:35:35 EST 2003
> > One moderately important caveat:
> > For correct results I found I had to alternate the sign of the
> > [-1,0]'s(search order) after each iteration in order for it to make
> > it around certain corners and/or fill in some pixels which only have
> > data on one adjoining side. I cycled the search order but maybe
> > randomly is more appropriate.
>
> I don't understand what you are talking about here. The only
> difference that the ordering will make is that it determines *which*
> non-NULL neighbour fills in a given NULL cell.
Ok, this was a problem with the r.mapcalc solution:
> r.mapcalc buffmap = if(oldmap, oldmap, \
> if(oldmap[0,-1], oldmap[0,-1] \
> if(oldmap[0,1], oldmap[0,1] \
> if(oldmap[-1,0], oldmap[-1,0] \
> if(oldmap[1,0], oldmap[1,0])))))
If you had:
(* = NULL, 0 is cell to be filled, 1 is a value)
111
*0*
***
The 0 would be set to NULL (if(oldmap[0,-1]); I reset the 0 base-map at
each iteration to remove these NULLs; and continuing the loop, the cell
would never get a value. Only changing the search order so oldmap[-1,0]
came first would fill the cell correctly.
That was one problem, the other was when two categories met, the
0-valued cell would be consistently filled by one of the categories over
the other based on their position relative to the target cell, due to
the search order always testing for say the left hand cell first.
I think the attached PNG is showing a combination of this and the NULL
problem mentioned above, but it has been 6 months and I think I fixed
the worst of it by hand, so it isn't the most informative example,
sorry.
[purple started growing from off screen SW, green from off screen NE,
they meet in the middle]
Summary: I think a constant search order leads to undesirable artifacts.
I haven't studied r.grow2 to comment on how it would act.
> Do you have some non-NULL cells which are being plotted in the same
> colour as NULLs? That could result in confusion.
No.
regards,
Hamish
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grow_biased.png
Type: image/png
Size: 537 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20031029/1c661b61/grow_biased.png
More information about the grass-dev
mailing list