I'd like to parse MOD13Q1 VI quality layers in R. My original code must have been incorrect, because it gave lots of "deep ocean" flags in the middle of Brazil. After the changes suggested by Mikkel, that's no longer the case. However I do see some VI usefulness values that don't appear in the documentation. I'm not sure whether that's a problem or whether the documentation is incomplete -- will explain further below. Here's my code, after the change suggested by Mikkel:
library(raster)library(rgdal)## See http://modis-land.gsfc.nasa.gov/MODLAND_grid.html: h11v09 should be entirely non-oceanfilename qual[10^6]2062 > intToBits(qual[10^6]) [1] 00 01 01 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00[26] 00 00 00 00 00 00 00> as.integer(intToBits(qual[10^6])) [1] 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0> first_k_bits(qual[10^6], k=16, reverse=F)[1] "0111000000010000"> sum(2^(0:15) * as.integer(intToBits(qual[10^6]))[1:16])[1] 2062
أكثر...
library(raster)library(rgdal)## See http://modis-land.gsfc.nasa.gov/MODLAND_grid.html: h11v09 should be entirely non-oceanfilename qual[10^6]2062 > intToBits(qual[10^6]) [1] 00 01 01 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00[26] 00 00 00 00 00 00 00> as.integer(intToBits(qual[10^6])) [1] 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0> first_k_bits(qual[10^6], k=16, reverse=F)[1] "0111000000010000"> sum(2^(0:15) * as.integer(intToBits(qual[10^6]))[1:16])[1] 2062
أكثر...