[GRASS-user] eliminate isolated pixel groups

Maciej Sieczka tutey at o2.pl
Mon Jan 15 15:15:58 EST 2007


Florian Kindl wrote:
> Hello list!
> 
> I am working on binary (1;null) maps depicting streams.
> What I try to accomplish is a filter which removes isolated groups of
> pixels.
> It is easy to remove a single pixel with r.mapcalc:
> 
> r.mapcalc "$RO= \
> if( \
> ( \
> isnull($RI[-1,-1])&&isnull($RI[-1,0])&&isnull($RI[-1,1])&& \
> isnull($RI[0,-1])&&isnull($RI[0,1])&& \
> isnull($RI[1,-1])&&isnull($RI[1,0])&&isnull($RI[1,1])  \
> ) \
> ,null() \
> ,$RI \
> )"
> 
> - test all 8 neighbours and null() the center pixel or leave it
>   unchanged.
> 
> Now, what if I try to expand this concept:
> 
>   * * * * *
>   * + + + *
>   * + + + *
>   * + + + *
>   * * * * *

Are you trying to remove cell groups of a given area? If so, take a
look at r.clump. It assigns a common value to a group of adjacent,
connected cells, so you can access each clump easily by cell value, not
by coordinates.

Maciek




More information about the grass-user mailing list