[GRASS-user] Patching rasters based on other rasters

Dear GRASS List,

I'm trying to do something in GRASS and can't figure out an efficient way to do it. I'm guessing it is possible with 1-3 lines, but don't know which ones. The algorithm I'm developing would be much more complex, and I hope someone can suggest a shortcut.

I have several satellite products of the same region each day. For simplicity sake lets assume 3 overlapping solar zenith angle (SZA) products, and for each of those a visual image (VIS). I'd like to have one visual raster that, for each pixel, has the minimum SZA.

I can get the minimum SZA for each pixel with

r.mapcalc "SZA_min = min(SZA1,SZA2,SZA3)"

But now I've lost the source of the minimum SZA, and I need it to link SZA1 with VIS1.

I could encode categories for each SZA:
r.category map=SZA1 cats=0-360 values=1
r.category map=SZA2 cats=0-360 values=2
r.category map=SZA3 cats=0-360 values=3

And then

r.mapcalc "SZA_min_cat = min(@SZA1,@SZA2,@SZA3)"

And then use SZA_min_cat (values: 1 to 3) as a lookup to VIS1,VIS2,VIS3. I'm actually not clear how to do this last step, if this is the correct approach. Do I return to r.mapcalc, or is r.univar the right tool?

Any help will be much appreciated.

Thanks,

  -k.
  

Le 17 octobre 2017 13:38:34 GMT+02:00, Ken Mankoff <mankoff@gmail.com> a écrit :

Dear GRASS List,

I'm trying to do something in GRASS and can't figure out an efficient
way to do it. I'm guessing it is possible with 1-3 lines, but don't
know which ones. The algorithm I'm developing would be much more
complex, and I hope someone can suggest a shortcut.

I have several satellite products of the same region each day. For
simplicity sake lets assume 3 overlapping solar zenith angle (SZA)
products, and for each of those a visual image (VIS). I'd like to have
one visual raster that, for each pixel, has the minimum SZA.

I can get the minimum SZA for each pixel with

r.mapcalc "SZA_min = min(SZA1,SZA2,SZA3)"

But now I've lost the source of the minimum SZA, and I need it to link
SZA1 with VIS1.

I could encode categories for each SZA:
r.category map=SZA1 cats=0-360 values=1
r.category map=SZA2 cats=0-360 values=2
r.category map=SZA3 cats=0-360 values=3

And then

r.mapcalc "SZA_min_cat = min(@SZA1,@SZA2,@SZA3)"

And then use SZA_min_cat (values: 1 to 3) as a lookup to
VIS1,VIS2,VIS3. I'm actually not clear how to do this last step, if
this is the correct approach. Do I return to r.mapcalc, or is r.univar
the right tool?

Any help will be much appreciated.

Check r.series, notably the min_raster method.

Moritz

Thanks,

-k.

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Thanks. That helps. I now use the output of that (SZA_lut) and the following:

r.mapcalc --o <<EOF
eval(SZA0 = if(SZA_lut == 0, ${img_arr[0]}),
SZA1 = if(SZA_lut == 1, ${img_arr[1]}),
SZA2 = if(SZA_lut == 2, ${img_arr[2]}),
SZA3 = if(SZA_lut == 3, ${img_arr[3]}),
SZA4 = if(SZA_lut == 4, ${img_arr[4]}),
SZA5 = if(SZA_lut == 5, ${img_arr[5]}))
SZA_min = SZA0+SZA1+SZA2+SZA3+SZA4+SZA5
EOF

-k.

···

On Tue, Oct 17, 2017 at 1:41 PM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Le 17 octobre 2017 13:38:34 GMT+02:00, Ken Mankoff <mankoff@gmail.com> a écrit :

Dear GRASS List,

I’m trying to do something in GRASS and can’t figure out an efficient
way to do it. I’m guessing it is possible with 1-3 lines, but don’t
know which ones. The algorithm I’m developing would be much more
complex, and I hope someone can suggest a shortcut.

I have several satellite products of the same region each day. For
simplicity sake lets assume 3 overlapping solar zenith angle (SZA)
products, and for each of those a visual image (VIS). I’d like to have
one visual raster that, for each pixel, has the minimum SZA.

I can get the minimum SZA for each pixel with

r.mapcalc “SZA_min = min(SZA1,SZA2,SZA3)”

But now I’ve lost the source of the minimum SZA, and I need it to link
SZA1 with VIS1.

I could encode categories for each SZA:
r.category map=SZA1 cats=0-360 values=1
r.category map=SZA2 cats=0-360 values=2
r.category map=SZA3 cats=0-360 values=3

And then

r.mapcalc “SZA_min_cat = min(@SZA1,@SZA2,@SZA3)”

And then use SZA_min_cat (values: 1 to 3) as a lookup to
VIS1,VIS2,VIS3. I’m actually not clear how to do this last step, if
this is the correct approach. Do I return to r.mapcalc, or is r.univar
the right tool?

Any help will be much appreciated.

Check r.series, notably the min_raster method.

Moritz

Thanks,

-k.


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user