[GRASS-user] help to use r.mapcalc with decimal/binary (modisdata)

Markus Neteler neteler at itc.it
Mon Jun 4 12:05:33 EDT 2007


On Mon, May 28, 2007 at 02:52:39AM +0100, Glynn Clements wrote:
...
> First, binary numbers are normally written with the bit 0 (the "units"
> digit) on the right, so "band 1 quality = missing input" would be:
> 
> 	1 1 1 1 1 1
> 	5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
> 
> 	* * * * * * * * 1 0 1 1 * * * *
> 
... 
> A shell script which uses r.mapcalc to split a QC map given as its
> first argument into separate maps for each field:
> 
> #!/bin/sh
> src=$1
> r.mapcalc <<EOF
> $src.modland    = ($src / 1    ) %  4
> $src.cloud      = ($src / 4    ) %  4
> $src.band1qual  = ($src / 16   ) % 16
> $src.band2qual  = ($src / 256  ) % 16
> $src.atmos_corr = ($src / 4096 ) %  2
> $src.adj_corr   = ($src / 8192 ) %  2
> $src.diff_orbit = ($src / 16384) %  2
> $src.unused     = ($src / 32768) %  2
> EOF
>

A related proposal: it would be nice to have support for
literal bitpattern strings and a related operator.

[ MODIS LST QA (Land Surface Temperature)
  http://www.icess.ucsb.edu/modis/LstUsrGuide/usrguide_1dtil.html#qa
]

Consider answering to the following question: Give me a map
with Mandatory QA good quality data, or "other quality, 
recommend examination of more detailed QA", with Data Flag
at 00 or 01.

Suggestion (written by my colleague Antonio Galea):

 "lst_filt = (lstmap ~ [XX XX XX 00]) || (lstmap ~ [XX XX 0X 01])"

- with '~' new bitpattern operator
- [XX ...] literal bitpattern, indicated with []

The ~ operator could be implemented with something like

  lstmap ~ [XX XX 01 XX]  =>  ( lstmap.cell & 00001100 ) == 00000100

Like this the application of QA bitpatterns would become more intuitive.

Markus




More information about the grass-user mailing list