[GRASSLIST:5] Re: r.neighbor - new question

david mahoney mahoneyd at unbc.ca
Mon May 12 11:45:05 EDT 2003


On Friday, May 9, 2003, at 06:11 AM, Daniel Victoria wrote:

> Thanks,
>
> Sometimes there is a simple answer but you just can't
> see it.
> I have another question now. This might sound dumb but
> in the r.neighbor man page it says that it uses a
> moving window in order to do the calculations. Does
> this means that if the window is going from left to
> right for instance, at a ceirtain point r.nieghbor
> will use an already avereged cell in order to
> calculate the new cell or the program only uses the
> original values to calculate the average?

r.mapcalc will only use values sampled from the original map, provided, 
of course, you area not writing out to the same map that you are 
reading from.

Dave Mahoney

>
> --- Glynn Clements <glynn.clements at virgin.net> wrote:
>>
>> Daniel Victoria wrote:
>>
>>> I'm trying to run r.neighbor on selected cells.
>> What I
>>> want to do is to substitute specific cell values
>>> (lower than 10 for instance) with the value
>> produce by
>>> a r.neighbor average. Is there a way to do this in
>>> GRASS?
>>
>> If I understand you correctly, the simplest way to
>> do this is to first
>> create a new map with r.neighbors, then use
>> r.mapcalc to choose
>> between the original map and the new map, e.g.
>>
>> 	r.neighbors input=origmap output=newmap
>> method=average size=7
>> 	r.mapcalc 'result = if(origmap < 10, newmap,
>> origmap)'
>>
>>> I tried r.mapcalc but I got a little confused with
>> the
>>> neighbor operand [r,c]. For a 3x3 window the [r,c]
>> in
>>> r.mapcalc should be easy but for something larger
>>> (7x7) it would be a lot more work. Is there an
>> easyer
>>> way?
>>
>> Re-implementing r.neighbors in r.mapcalc is
>> impractical for large
>> window sizes; there aren't any looping constructs,
>> so there isn't any
>> way of doing it without writing N-squared distinct
>> terms (e.g. 49
>> terms for a 7x7 window).
>>
>> -- 
>> Glynn Clements <glynn.clements at virgin.net>
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com






More information about the grass-user mailing list