[GRASS-user] Exporting set of raster cells with different values as one layer

Dear all,

I’m doing wildfire simulations in the Grass. I need to calculate the area of only the wildfire spread from the simulation. For that, I need to take only the wildfire spread as a separate layer. But the drawback is the values of the cells in the spread is different from point to point. But it has a range. As an example, the values of cells inside the spread are ranging from 1-90. The other cells in the map show values more than that.
Can I write a mapcalc command for a range like this to output these cells as one layer?

@Nikos has sent me this mapcalc command and from that, we can take only cells with one value as a layer.

r.mapcalc “category_3 = if(spread_time_observed == 3, 3, null())”

instead of that one value(3) in this can we input a range as above(1-90) and get all those cells with different values as one layer?

Thank You
Best Regards
Kalindu Perera

Am 26. Oktober 2018 06:42:44 MESZ schrieb Kalindu Perera <kkc199408@gmail.com>:

Dear all,

I'm doing wildfire simulations in the Grass. I need to calculate the
area
of only the wildfire spread from the simulation. For that, I need to
take
only the wildfire spread as a separate layer. But the drawback is the
values of the cells in the spread is different from point to point. But
it
has a range. As an example, the values of cells inside the spread are
ranging from 1-90. The other cells in the map show values more than
that.
Can I write a mapcalc command for a range like this to output these
cells
as one layer?

@Nikos has sent me this mapcalc command and from that, we can take only
cells with one value as a layer.

r.mapcalc "category_3 = if(spread_time_observed == 3, 3, null())"

instead of that one value(3) in this can we input a range as
above(1-90)
and get all those cells with different values as one layer?

You can use >/< and the && (logical AND) to select all pixels within a range in r.mapcalc.

But you could also use r.reclass or r.recode.

Moritz

Thanks a lot Moritz…!!!

Can you just send me one example command?..I’m not sure I understood it in the way that you explained

Thanks again for the quick reply
Best regards
Kalindu Perera

On Fri, 26 Oct 2018 at 11:46, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Am 26. Oktober 2018 06:42:44 MESZ schrieb Kalindu Perera <kkc199408@gmail.com>:

Dear all,

I’m doing wildfire simulations in the Grass. I need to calculate the
area
of only the wildfire spread from the simulation. For that, I need to
take
only the wildfire spread as a separate layer. But the drawback is the
values of the cells in the spread is different from point to point. But
it
has a range. As an example, the values of cells inside the spread are
ranging from 1-90. The other cells in the map show values more than
that.
Can I write a mapcalc command for a range like this to output these
cells
as one layer?

@Nikos has sent me this mapcalc command and from that, we can take only
cells with one value as a layer.

r.mapcalc “category_3 = if(spread_time_observed == 3, 3, null())”

instead of that one value(3) in this can we input a range as
above(1-90)
and get all those cells with different values as one layer?

You can use >/< and the && (logical AND) to select all pixels within a range in r.mapcalc.

But you could also use r.reclass or r.recode.

Moritz

Am 26. Oktober 2018 09:08:11 MESZ schrieb Kalindu Perera <kkc199408@gmail.com>:

Thanks a lot Moritz....!!!!!!!!

Can you just send me one example command?..I'm not sure I understood it
in
the way that you explained

Please do read the r.mapcalc manual, but here's an example:

r.mapcalc "category_range = if(spread_time_observed >= 1 && spread_time_observed <= 90
, 1, null())"

If there are no values below 1 in spread_time_observed, then this can be simplified to

r.mapcalc "category_range = if(spread_time_observed <= 90
, 1, null())"

The result of each command is a map with pixel values of 1 where the condition is met and null where not.

Moritz

Thanks again for the quick reply
Best regards
Kalindu Perera

On Fri, 26 Oct 2018 at 11:46, Moritz Lennert
<mlennert@club.worldonline.be>
wrote:

Am 26. Oktober 2018 06:42:44 MESZ schrieb Kalindu Perera <
kkc199408@gmail.com>:
>Dear all,
>
>I'm doing wildfire simulations in the Grass. I need to calculate the
>area
>of only the wildfire spread from the simulation. For that, I need to
>take
>only the wildfire spread as a separate layer. But the drawback is

the

>values of the cells in the spread is different from point to point.

But

>it
>has a range. As an example, the values of cells inside the spread

are

>ranging from 1-90. The other cells in the map show values more than
>that.
>Can I write a mapcalc command for a range like this to output these
>cells
>as one layer?
>
>@Nikos has sent me this mapcalc command and from that, we can take

only

>cells with one value as a layer.
>
>r.mapcalc "category_3 = if(spread_time_observed == 3, 3, null())"
>
>instead of that one value(3) in this can we input a range as
>above(1-90)
>and get all those cells with different values as one layer?

You can use >/< and the && (logical AND) to select all pixels within

a

range in r.mapcalc.

But you could also use r.reclass or r.recode.

Moritz

Thanks a lot Moritz…!!!

I got it and I’ll read the mapcalc manual as well.

Thanks again
Best regards
Kalindu Perera

On Fri, 26 Oct 2018 at 13:25, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Am 26. Oktober 2018 09:08:11 MESZ schrieb Kalindu Perera <kkc199408@gmail.com>:

Thanks a lot Moritz…!!!

Can you just send me one example command?..I’m not sure I understood it
in
the way that you explained

Please do read the r.mapcalc manual, but here’s an example:

r.mapcalc “category_range = if(spread_time_observed >= 1 && spread_time_observed <= 90
, 1, null())”

If there are no values below 1 in spread_time_observed, then this can be simplified to

r.mapcalc “category_range = if(spread_time_observed <= 90
, 1, null())”

The result of each command is a map with pixel values of 1 where the condition is met and null where not.

Moritz

Thanks again for the quick reply
Best regards
Kalindu Perera

On Fri, 26 Oct 2018 at 11:46, Moritz Lennert
<mlennert@club.worldonline.be>
wrote:

Am 26. Oktober 2018 06:42:44 MESZ schrieb Kalindu Perera <
kkc199408@gmail.com>:

Dear all,

I’m doing wildfire simulations in the Grass. I need to calculate the
area
of only the wildfire spread from the simulation. For that, I need to
take
only the wildfire spread as a separate layer. But the drawback is
the
values of the cells in the spread is different from point to point.
But
it
has a range. As an example, the values of cells inside the spread
are
ranging from 1-90. The other cells in the map show values more than
that.
Can I write a mapcalc command for a range like this to output these
cells
as one layer?

@Nikos has sent me this mapcalc command and from that, we can take
only
cells with one value as a layer.

r.mapcalc “category_3 = if(spread_time_observed == 3, 3, null())”

instead of that one value(3) in this can we input a range as
above(1-90)
and get all those cells with different values as one layer?

You can use >/< and the && (logical AND) to select all pixels within
a
range in r.mapcalc.

But you could also use r.reclass or r.recode.

Moritz