<P>thanks glynn.</P><P>I think I have understood your suggestions. But i am still struggling with the mask creation.</P><P>The raster map <FONT FACE="Monospace,Courier">"sur_refl_qc_250" contains a decimal representation of the 16 unsigned band</FONT></P><P><FONT FACE="Monospace,Courier">when I run r.report map=sur_refl_qc_250 null=* nsteps=255 i get the following output.</FONT></P><P><FONT FACE="Monospace,Courier">|2995|</FONT></P><P><FONT FACE="Monospace,Courier">|4096|</FONT></P><P><FONT FACE="Monospace,Courier">|4100|</FONT></P><P><FONT FACE="Monospace,Courier">|4104|</FONT></P><P><FONT FACE="Monospace,Courier">|4305|</FONT></P><P><FONT FACE="Monospace,Courier">|4309|</FONT></P><P><FONT FACE="Monospace,Courier">|4313|</FONT></P><P><FONT FACE="Monospace,Courier">|7425|</FONT></P><P><FONT FACE="Monospace,Courier">|7633|</FONT></P><P><FONT FACE="Monospace,Courier">|7637|</FONT></P><P><FONT FACE="Monospace,Courier">|7641|</FONT></P><P><FONT FACE="Monospace,Courier">|7687|</FONT></P><P><FONT FACE="Monospace,Courier">|7691|</FONT></P><P><FONT FACE="Monospace,Courier">|7687|</FONT></P><P> </P><P>when i try and create a mask using this raster i use the </P><P><FONT FACE="Monospace,Courier">r.mapcalc MASK="if(sur_refl_qc_250 & 0x00F0 == 0x00B0 , 1, null())"</FONT></P><P><FONT FACE="Monospace,Courier">and i get the following error</FONT></P><P><FONT FACE="Monospace,Courier">syntax error, unexpected NAME, expecting ')'</FONT></P><P><FONT FACE="Monospace,Courier">parse error</FONT></P><P> </P><P><FONT FACE="Monospace,Courier">I am assuming that is because the hex code is assuming the data is in binary when in fact it is in decimal.</FONT></P><P><FONT FACE="Monospace,Courier">As you can see im getting a bit confused.</FONT></P><P><FONT FACE="Monospace,Courier">Any help would be greatly appreciated.</FONT></P><P> </P><P><FONT FACE="Monospace,Courier">best regards</FONT></P><P><FONT FACE="Monospace,Courier">Andrew</FONT></P><P> </P><P><FONT FACE="Monospace,Courier">I am running grass6.3 (CVS)</FONT></P><P><FONT FACE="Monospace,Courier">on Suse 10.2</FONT></P><P> </P><P> </P><P><BR><BR><FONT SIZE=2 STYLE=font-size:9pt><B>Glynn Clements <glynn@gclements.plus.com></B></FONT><BR><FONT SIZE=2 STYLE=font-size:9pt>05/25/2007 01:01 AM CET</FONT><BR><BR> <FONT SIZE=2 STYLE=font-size:9pt>To</FONT> <FONT SIZE=2 STYLE=font-size:9pt>andrew.haywood@poyry.com</FONT><BR> <FONT SIZE=2 STYLE=font-size:9pt>cc</FONT> <FONT SIZE=2 STYLE=font-size:9pt>grassuser@grass.itc.it</FONT><BR> <FONT SIZE=2 STYLE=font-size:9pt>bcc</FONT> <BR> <FONT SIZE=2 STYLE=font-size:9pt>Subject</FONT> <FONT SIZE=2 STYLE=font-size:9pt>Re: [GRASS-user] help to use r.mapcalc with decimal/binary (modis data)</FONT><BR> <BR><BR></P><P><FONT FACE="Monospace,Courier">andrew.haywood@poyry.com wrote:<BR></FONT><BR><FONT FACE="Monospace,Courier">> i am having some issues with analysing MOD09 modis data in grass. I<BR>> would like to mask out the cloud pixels using the below quality control<BR>> band.<BR>> when i import this band the unsigned 16bit integer is converted in decimal<BR>> and I am unsure how to use r.mapcalc to create a mask based on the<BR>> different bits.<BR>><BR>> I am unsure how I should go about this (see *** section below). I would<BR>> like to try different selections to see which would make the best mask but<BR>> i am unsure how to do this against a binary field<BR>><BR>> eg. r.mapcalc MASK="if(sur_refl_qc_250 == **** clear state **** , 1,<BR>> null())"<BR>><BR>> how do I select out the different bits to create the mask?<BR>><BR>> At this stage i am thinking of trying to convert the decimal back to<BR>> binary (not sure how to do this ) and then subselect columns (bits) eg 0-1<BR>> or 2-3 and the placing an if statement (eg. if column01 == "00" or if<BR>> column23 = "00").<BR></FONT><BR><FONT FACE="Monospace,Courier">Use<BR></FONT><BR><FONT FACE="Monospace,Courier">r.mapcalc MASK="if(sur_refl_qc_250 & 3 == 0 , 1, null())"<BR></FONT><BR><FONT FACE="Monospace,Courier">For the<BR></FONT><BR><FONT FACE="Monospace,Courier">Given your description of the various bits, the coresponding masks are:<BR></FONT><BR><FONT FACE="Monospace,Courier">BitsMask<BR>0-10x0003<BR>2-30x000C<BR>4-70x00F0<BR>8-110x0F00<BR>120x1000<BR>130x2000<BR>140x4000<BR>150x8000</FONT><BR><BR><FONT FACE="Monospace,Courier">The value to compare will need to be shifted into the correct range,<BR>e.g. for "band 1 quality = missing input":<BR></FONT><BR><FONT FACE="Monospace,Courier">r.mapcalc MASK="if(sur_refl_qc_250 & 0x00F0 == 0x00B0 , 1, null())"<BR></FONT><BR><FONT FACE="Monospace,Courier">If you're unfamiliar with binary arithmetic, there's some information<BR>at:<BR></FONT><BR><FONT FACE="Monospace,Courier"><A HREF=http://en.wikipedia.org/wiki/Binary_numeral_system>http://en.wikipedia.org/wiki/Binary_numeral_system</A><BR></FONT><BR><FONT FACE="Monospace,Courier">--<BR>Glynn Clements <glynn@gclements.plus.com></FONT></P><BR>
This email and any files transmitted with it are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any use, distribution, or reproduction of the contents of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please notify the sender by return email and destroy all copies of the original message including any attachments thereto. <BR>
Thank you.<BR>