[GRASS-user] r.neighbors modal filter for two raster layers

Hi,

Any ideas in doing this:

I want to get the mode of raster categorical values for a defined
window based on 2 raster layers.
For example, I set a window of 5x5, so I get mode value from 50 pixels
(25 for raster a and 25 for raster 2).

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

What operator in mapcalc should I use to evaluate a mode from a given window:
r.mapcalc "test_andmode = mode (map1[-1,-1] && map1[-1,0] &&
map1[-1,1] && map1[0,-1] && \
map1[1,-1] && map1[1,1] && map1[0,0] && map1[0,1] && map1[-1,0] &&
map2[-1,-1] && map2[-1,0] && \
map2[-1,1] && map2[0,-1] && map2[1,-1] && map2[1,1] && map2[0,0] &&
map2[0,1] && map2[-1,0])"

Is the && correct to list values?

On Fri, Jan 30, 2009 at 11:53 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any ideas in doing this:

I want to get the mode of raster categorical values for a defined
window based on 2 raster layers.
For example, I set a window of 5x5, so I get mode value from 50 pixels
(25 for raster a and 25 for raster 2).

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

Well, it should be ","

r.mapcalc "test_andmode = mode (map1[-1,-1] , map1[-1,0] , map1[-1,1]
, map1[0,-1] , map1[1,-1] , map1[1,1] , map1[0,0] , map1[0,1] ,
map1[-1,0] , map2[-1,-1] , map2[-1,0] , map2[-1,1] , map2[0,-1] ,
map2[1,-1] , map2[1,1] , map2[0,0] , map2[0,1] , map2[-1,0])"

On Fri, Jan 30, 2009 at 2:16 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

What operator in mapcalc should I use to evaluate a mode from a given window:
r.mapcalc "test_andmode = mode (map1[-1,-1] && map1[-1,0] &&
map1[-1,1] && map1[0,-1] && \
map1[1,-1] && map1[1,1] && map1[0,0] && map1[0,1] && map1[-1,0] &&
map2[-1,-1] && map2[-1,0] && \
map2[-1,1] && map2[0,-1] && map2[1,-1] && map2[1,1] && map2[0,0] &&
map2[0,1] && map2[-1,0])"

Is the && correct to list values?

On Fri, Jan 30, 2009 at 11:53 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any ideas in doing this:

I want to get the mode of raster categorical values for a defined
window based on 2 raster layers.
For example, I set a window of 5x5, so I get mode value from 50 pixels
(25 for raster a and 25 for raster 2).

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

Revisiting this thread, how do I add in the r.mapcalc command:

where if a pixel in the window contains a NULL value, do not count the
NULL in computing the mode

For example if map 1 has many NULL values while map2 has valid
values, juts count the mode within map2. This way I can patch areas
where map1 has NULLs. And vise-versa if map2 has many NULLs.

The command below is OK when both maps have few NULL values.

On Fri, Jan 30, 2009 at 3:31 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Well, it should be ","

r.mapcalc "test_andmode = mode (map1[-1,-1] , map1[-1,0] , map1[-1,1]
, map1[0,-1] , map1[1,-1] , map1[1,1] , map1[0,0] , map1[0,1] ,
map1[-1,0] , map2[-1,-1] , map2[-1,0] , map2[-1,1] , map2[0,-1] ,
map2[1,-1] , map2[1,1] , map2[0,0] , map2[0,1] , map2[-1,0])"

On Fri, Jan 30, 2009 at 2:16 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

What operator in mapcalc should I use to evaluate a mode from a given window:
r.mapcalc "test_andmode = mode (map1[-1,-1] && map1[-1,0] &&
map1[-1,1] && map1[0,-1] && \
map1[1,-1] && map1[1,1] && map1[0,0] && map1[0,1] && map1[-1,0] &&
map2[-1,-1] && map2[-1,0] && \
map2[-1,1] && map2[0,-1] && map2[1,-1] && map2[1,1] && map2[0,0] &&
map2[0,1] && map2[-1,0])"

Is the && correct to list values?

On Fri, Jan 30, 2009 at 11:53 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any ideas in doing this:

I want to get the mode of raster categorical values for a defined
window based on 2 raster layers.
For example, I set a window of 5x5, so I get mode value from 50 pixels
(25 for raster a and 25 for raster 2).

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

Again (doh!) answering to my own query.

use r.series method=mode

my grass module of the day!

On Thu, Apr 16, 2009 at 4:51 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Revisiting this thread, how do I add in the r.mapcalc command:

where if a pixel in the window contains a NULL value, do not count the
NULL in computing the mode

For example if map 1 has many NULL values while map2 has valid
values, juts count the mode within map2. This way I can patch areas
where map1 has NULLs. And vise-versa if map2 has many NULLs.

The command below is OK when both maps have few NULL values.

On Fri, Jan 30, 2009 at 3:31 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Well, it should be ","

r.mapcalc "test_andmode = mode (map1[-1,-1] , map1[-1,0] , map1[-1,1]
, map1[0,-1] , map1[1,-1] , map1[1,1] , map1[0,0] , map1[0,1] ,
map1[-1,0] , map2[-1,-1] , map2[-1,0] , map2[-1,1] , map2[0,-1] ,
map2[1,-1] , map2[1,1] , map2[0,0] , map2[0,1] , map2[-1,0])"

On Fri, Jan 30, 2009 at 2:16 PM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

What operator in mapcalc should I use to evaluate a mode from a given window:
r.mapcalc "test_andmode = mode (map1[-1,-1] && map1[-1,0] &&
map1[-1,1] && map1[0,-1] && \
map1[1,-1] && map1[1,1] && map1[0,0] && map1[0,1] && map1[-1,0] &&
map2[-1,-1] && map2[-1,0] && \
map2[-1,1] && map2[0,-1] && map2[1,-1] && map2[1,1] && map2[0,0] &&
map2[0,1] && map2[-1,0])"

Is the && correct to list values?

On Fri, Jan 30, 2009 at 11:53 AM, maning sambale
<emmanuel.sambale@gmail.com> wrote:

Hi,

Any ideas in doing this:

I want to get the mode of raster categorical values for a defined
window based on 2 raster layers.
For example, I set a window of 5x5, so I get mode value from 50 pixels
(25 for raster a and 25 for raster 2).

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------