[GRASS-user] identifying diagonal clumps

Milton Cezar Ribeiro miltinho.astronauta at gmail.com
Mon Sep 15 09:51:00 EDT 2008


Dear Glynn and Manning
Your tips solved my problem.

Many thanks for both.

Best wishes

miltinho

2008/9/15 Glynn Clements <glynn at gclements.plus.com>

>
> Milton Cezar Ribeiro wrote:
>
> > I tryed your suggestion and notice that the F8 solution
> > simulate a dilatation of 1pixels on everyside of patches.
> > But, if I am not wrong, when I have a patch separated by
> > 2 pixels, the F8 solution will join these patches on only one.
> >
> > But I can preserve the patches separated, and only
> > consider as one patches those pixels that can be joined
> > on the rule 8. I don´t know if I am so clear, but I would
> > like to request a little more time of you on this regard.
> >
> > I run the folowwing commands:
> >
> > r.mapcalc "F8 = (A*A[-1,-1]) * (A*A[-1,0]) * (A*A[1,-1]) * (A*A[0,-1]) *
> (A*A[0,1]) * (A*A[-1,1]) * (A*A[1,1])"
> > r.clump input=F8 output=F8_clump
>
> The r.mapcalc command will perform "thinning". The result will be one
> if all nine cells (the centre and all eight surrounding cells) are
> one, and zero if any of the nine cells are zero).
>
> [Actually, you're missing A[1,0].]
>
> For "fattening", you should use e.g.:
>
> r.mapcalc "F8 = A[-1,-1] || A[-1,0] || A[-1,1] || A[0,-1] || A || A[0,1] ||
> A[1,-1] || A[1,0] || A[1,1]"
>
> [For 0/1, multiplication is equivalent to the "&&" operator (logical
> conjunction).]
>
> Another option, which should only fill in the cells necessary to make
> r.clump recognise diagonal adjacency, is:
>
> r.mapcalc "AF = A || A[0,1] && A[1,0] || A[0,-1] && A[1,0] || A[0,1] &&
> A[-1,0] || A[0,-1] && A[-1,0]"
>
> This will only set the centre cell if two diagonally-adjacent
> neighbours are both set.
>
> It may even suffice to use:
>
> r.mapcalc "AF = A || A[0,1] && A[1,0] || A[0,-1] && A[1,0]"
>
> This will only fill the cell on one side of a pair of diagonally
> adjacent cells.
>
> --
> Glynn Clements <glynn at gclements.plus.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20080915/3530b6e0/attachment.html


More information about the grass-user mailing list