<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">&quot;sur_refl_qc_250&quot; 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>&nbsp;</P><P>when i try and create a mask using this raster i use the </P><P><FONT FACE="Monospace,Courier">r.mapcalc MASK=&quot;if(sur_refl_qc_250 &amp; 0x00F0 == 0x00B0 , 1, null())&quot;</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>&nbsp;</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>&nbsp;</P><P><FONT FACE="Monospace,Courier">best regards</FONT></P><P><FONT FACE="Monospace,Courier">Andrew</FONT></P><P>&nbsp;</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>&nbsp;</P><P>&nbsp;</P><P><BR><BR><FONT SIZE=2 STYLE=font-size:9pt><B>Glynn Clements &lt;glynn@gclements.plus.com&gt;</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> &nbsp; <FONT SIZE=2 STYLE=font-size:9pt>andrew.haywood@poyry.com</FONT><BR> <FONT SIZE=2 STYLE=font-size:9pt>cc</FONT> &nbsp; <FONT SIZE=2 STYLE=font-size:9pt>grassuser@grass.itc.it</FONT><BR> <FONT SIZE=2 STYLE=font-size:9pt>bcc</FONT> &nbsp; <BR> <FONT SIZE=2 STYLE=font-size:9pt>Subject</FONT> &nbsp; <FONT SIZE=2 STYLE=font-size:9pt>Re: [GRASS-user] help to use r.mapcalc with decimal/binary (modis data)</FONT><BR> &nbsp;<BR><BR></P><P><FONT FACE="Monospace,Courier">andrew.haywood@poyry.com wrote:<BR></FONT><BR><FONT FACE="Monospace,Courier">&gt; i am having some issues with analysing &nbsp;MOD09 modis data in grass. &nbsp;I<BR>&gt; would like to mask out the cloud pixels using the below quality control<BR>&gt; band.<BR>&gt; when i import this band the unsigned 16bit integer is converted in decimal<BR>&gt; and I am unsure how to &nbsp;use r.mapcalc to create a mask based on the<BR>&gt; different bits.<BR>&gt;<BR>&gt; I am unsure how I should go about this (see *** section below). I would<BR>&gt; like to try different selections to see which would make the best mask but<BR>&gt; i am unsure how to do this against a binary field<BR>&gt;<BR>&gt; eg. r.mapcalc MASK=&quot;if(sur_refl_qc_250 == **** clear state **** , 1,<BR>&gt; null())&quot;<BR>&gt;<BR>&gt; how do I select out the different bits to create the mask?<BR>&gt;<BR>&gt; At this stage i am thinking of trying to convert the decimal back to<BR>&gt; binary (not sure how to do this ) and then subselect columns (bits) eg 0-1<BR>&gt; or 2-3 and the placing an if statement (eg. if column01 == &quot;00&quot; or if<BR>&gt; column23 = &quot;00&quot;).<BR></FONT><BR><FONT FACE="Monospace,Courier">Use<BR></FONT><BR><FONT FACE="Monospace,Courier">r.mapcalc MASK=&quot;if(sur_refl_qc_250 &amp; 3 == 0 , 1, null())&quot;<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 &quot;band 1 quality = missing input&quot;:<BR></FONT><BR><FONT FACE="Monospace,Courier">r.mapcalc MASK=&quot;if(sur_refl_qc_250 &amp; 0x00F0 == 0x00B0 , 1, null())&quot;<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 &lt;glynn@gclements.plus.com&gt;</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>