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

Moritz Lennert mlennert at club.worldonline.be
Fri Oct 26 00:55:05 PDT 2018



Am 26. Oktober 2018 09:08:11 MESZ schrieb Kalindu Perera <kkc199408 at 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 at club.worldonline.be>
>wrote:
>
>>
>>
>> Am 26. Oktober 2018 06:42:44 MESZ schrieb Kalindu Perera <
>> kkc199408 at 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
>>


More information about the grass-user mailing list