Working with AppEEARS NetCDF-4 Output Data in R

Details:

Published: Dec. 6, 2017

Working with AppEEARS NetCDF-4 Output Data in R

This tutorial demonstrates how to work with data output from the Application for Extracting and Exploring Analysis Ready Samples (AppEEARS) Area Sampler in R.

AppEEARS allows users to select NetCDF-4 as an output file format for Area Requests. This tutorial provides step-by-step instructions for creating NetCDF-4 files filtered based on specific quality and land cover type determinations.


Case Study:

Throughout the tutorial, the following study is used as an example of how and why quality filtering is necessary in order to arrive at scientifically sound conclusions when working with remote sensing data. The tutorial follows similar data and methods of this study to demonstrate how to work with AppEEARS NetCDF-4 output files in R.

Samanta, A., Ganguly, S., Hashimoto, H., Devadiga, S., Vermote, E., Knyazikhin, Y., Nemani, R.R., and Myneni, R.B., 2010, Amazon forests did not green-up during the 2005 drought: Geophysical Research Letters, v. 37, no. 5.

What: The study tries to reproduce reports from previous studies showing greening of Amazon forests during the 2005 drought.

Why: To demonstrate the importance of considering remote sensing data quality, and reconcile contradicting reports of increased tree mortality and biomass burning with reports of anomalous Amazon forest greening.

How: The authors replicated a previous study claiming that Amazon forests were greening during the 2005 drought, with very specific quality and land cover type screening in their methods. They then used the quality-filtered data to calculate standard anomalies of EVI in order to arrive at their conclusions.

Where: Amazon Rainforest, from latitude: 20° S to 10° N, and longitude: 80° W to 45° W

When: July-September 2000-2008

AppEEARS Request Parameters: Request time series data for MODIS Enhance Vegetation Indices (EVI) and Land Cover.

  • Date: July 01, 2005 to September 30, 2005
  • Data layers:
    • Terra MODIS Vegetation Indices: MOD13A2.006, 1000m, 16 day: '_1_km_16_days_EVI'
    • Combined MODIS Land Cover Type: MCD12Q1.051, 500m, Yearly: 'Land_Cover_Type_1'
  • Location: 20° S to 10° N, and longitude: 80° W to 45° W
  • File Format: NetCDF-4
  • Projection: Geographic (EPSG: 4326)

AppEEARS Information

To access AppEEARS, visit: https://appeears.earthdatacloud.nasa.gov/
For information on how to make an AppEEARS request, visit: https://appeears.earthdatacloud.nasa.gov/help


Topics Covered in this Tutorial

  1. Setting up the Working Environment
  2. Downloading AppEEARS Output in R from Text File
  3. Opening a NetCDF-4 (.nc) File
  4. Reading NetCDF-4 File Metadata
  5. Reading Quality Lookup Tables (LUTs) from CSV Files
  6. Setting Custom QA/QC Filtering (Masking)
  7. Visualizing NetCDF-4 Data
  8. Masking by Land Cover Type
  9. Visualizing NetCDF-4 Data with GIS Layers
  10. Generating Statistics on Quality Filtered Data
  11. Automating QA/QC Filtering
  12. Visualizing Time Series
  13. Exporting NetCDF-4 Files

Prerequisites

  • R: Version 3.*

**R Libraries: **

  • raster
  • ncdf4
  • RColorBrewer
  • rmarkdown
  • rworldmap
  • colorspace
  • fields
  • sp

NOTE: You will need to have cURL installed on your OS in order to perform topic two (downloading data). If you are unable to download cURL, you can skip step two and download the files needed to run the rest of the tutorial in the section below.

The AppEEARS files used in this tutorial can be downloaded from:

The source code used to generate this tutorial can be downloaded from:

1. Set up Working Environment


First, load the R packages necessary to run the tutorial. If you are missing any of the packages, you can download them using the install.packages('missing package') command in the console.

# Load necessary packages into R                                               
 library(raster); library(rmarkdown); library(ncdf4); library(sp)

Next, set your input/working directory, and create an output directory for the results.

# Set input directory, and change working directory
in_dir <- 'C:/Users/ckrehbiel/Documents/appeears-tutorials/' # IMPORTANT: Need to update this to reflect your working directory
setwd(in_dir)    

# Create and set output directory
out_dir <- paste(in_dir, 'R_output/', sep= '')
suppressWarnings(dir.create(out_dir))

2. Download AppEEARS Output from .txt


Now take an AppEEARS output download text file and download all of your NetCDF-4 output files.

For more information on how to retrieve the output download text file from your request, visit the AppEEARS help pages, under Area Samples -> Downloading Your Request.

If you plan to use the files for the use case in this tutorial, you will need to download the text file of AppEEARS output file links and make sure that the text file is located in your input directory.

# Search for, open, and read text file containing links to AppEEARS output files
download_file <- file(list.files(pattern = '.*txt$'),'r')
download_link <- readLines(download_file)
## Warning in readLines(download_file): incomplete final line found on
## 'amazon-appeears-tutorial-example-download-list.txt'
# Loop through text file and download all AppEEARS outputs
for (i in 1:length(download_link)){
  file_name <- tail(strsplit(download_link[i], '/')[[1]],1)

  # NOTE: you will need cURL installed on your OS in order to successfully download the files
  download.file(download_link[i], destfile = file_name, method = 'curl')
  print(paste('Downloaded file: ', file_name, ' (', i, " of ", length(download_link), ')', sep = ""))
}
## [1] "Downloaded file: MCD12Q1.051_500m_aid0001.nc (1 of 2)"
## [1] "Downloaded file: MOD13A2.006_1km_aid0001.nc (2 of 2)"
close(download_file)

# Once you have finished downloading the files, remove these variables
rm(download_link, download_file)

Notice that two files were downloaded. For an AppEEARS Area Sample request, if NetCDF-4 is selected as the output format, outputs will be grouped into .nc files by product and by feature.

3. Open a NetCDF-4 (.nc) File


Search for the NetCDF-4 files that you just downloaded in your working directory, create a list of the files, and print the list.

# Now search for downloaded files
file_list <- list.files(pattern = '.*nc$')
file_list
## [1] "MCD12Q1.051_500m_aid0001.nc" "MOD13A2.006_1km_aid0001.nc"

Notice that the request includes the version 5.1 MODIS Combined Yearly Land Cover Type (MCD12Q1.051) and version 6 MODIS Terra 16-day Vegetation Indices (MOD13A2.006) products. Start with the MOD13A2 version 6 NetCDF file.

Notice below that the file_list index is set to 2, to select the MOD13A2.006.nc file above [1,2]. Read the file in by calling the nc_open() function from the ncdf4 library.

# Read file in, lets start with MOD13A2 version 6
file_in <- nc_open(file_list[2])

4. Read NetCDF-4 File Metadata


Below, look at the variables and metadata in the NetCDF-4 file.

# Print a list of variables in file
attributes(file_in$var)$names
## [1] "crs"                      "_1_km_16_days_EVI"       
## [3] "_1_km_16_days_VI_Quality"
# Print a list of dimensions in file
attributes(file_in$dim)$names
## [1] "time" "lat"  "lon"

_1_km_16_days_EVI and _1_km_16_days_VI_Quality are the data layers focused on for this tutorial, which are Enhanced Vegetation Index (EVI) and the corresponding quality data that were used in the case study.

Below, read in the metadata for the EVI dataset.

v6_info <- ncatt_get(file_in, "_1_km_16_days_EVI")
v6_info
## $`_FillValue`
## [1] -3000
## 
## $coordinates
## [1] "time lat lon"
## 
## $grid_mapping
## [1] "crs"
## 
## $valid_min
## [1] -2000
## 
## $valid_max
## [1] 10000
## 
## $long_name
## [1] "1 km 16 days EVI"
## 
## $units
## [1] "EVI"
## 
## $scale_factor_err
## [1] 0
## 
## $add_offset_err
## [1] 0
## 
## $calibrated_nt
## [1] 5
## 
## $scale_factor
## [1] 1e-04
## 
## $add_offset
## [1] 0

Above, notice the useful metadata, including things like units, scale factor, and fill value.

Below, set the dataset arrays to variables by using the ncdf4 library's ncvar_get() command.

# Grab the EVI and VI Quality datasets and set to a variable
v6_EVI <- ncvar_get(file_in, "_1_km_16_days_EVI")
v6_QA <- ncvar_get(file_in, "_1_km_16_days_VI_Quality")

# Variable dimensions
dim(v6_EVI)
## [1] 4200 3600    7

Above, notice the NetCDF-4 file dimensions. 'time' indicates that the file includes 6 timesteps or layers (observations).

Grab the latitude and longitude arrays that are included in the NetCDF-4 files.

# Set lat and lon arrays for EVI data
lat_EVI <- ncvar_get(file_in, "lat")
lon_EVI <- ncvar_get(file_in, "lon")

# Grab the fill value and set to NA
fillvalue <- ncatt_get(file_in, "_1_km_16_days_EVI", "_FillValue")
v6_EVI[v6_EVI == fillvalue$value] <- NA

# Define the coordinate referense system proj.4 string
crs <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs+ towgs84=0,0,0")

# Grab first observation of EVI and Quality datasets
v6_EVI <- raster(t(v6_EVI[,,1]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
v6_EVI_original <- v6_EVI
v6_QA <- raster(t(v6_QA[,,1]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)

5. Read Quality Lookup Tables from CSV


In this section, take the quality lookup table (LUT) CSV file from an AppEEARS request, read it into R using read.csv(), and use it to help set the quality masking parameters.

The quality LUT for your request (files ending in lookup.csv) can be found under Supporting Files on the Download Area Sample page.

For more information on how to retrieve the quality LUTs from your request, visit the AppEEARS help pages, under Area Samples -> Downloading Your Request.

Next, search the working directory for the quality LUT CSV file.

# Search for look up table
lut <- list.files(pattern = '.*lookup.csv$')
lut
## [1] "MOD13A2-006-1-km-16-days-VI-Quality-lookup.csv"

Below, use the read.csv() function to read in the CSV file as a dataframe.

# Read in the lut
v6_QA_lut <- read.csv(lut[1])
v6_QA_lut
##     Value                                             MODLAND
## 1    2050            Pixel produced, but most probably cloudy
## 2    2057                     VI produced, but check other QA
## 3    2058            Pixel produced, but most probably cloudy
## 4    2061                     VI produced, but check other QA
## 5    2062            Pixel produced, but most probably cloudy
## 6    2112                           VI produced, good quality
## 7    2114            Pixel produced, but most probably cloudy
## 8    2116                           VI produced, good quality
## 9    2118            Pixel produced, but most probably cloudy
## 10   2177                     VI produced, but check other QA
## 11   2181                     VI produced, but check other QA
## 12   2182            Pixel produced, but most probably cloudy
## 13   2185                     VI produced, but check other QA
## 14   2186            Pixel produced, but most probably cloudy
## 15   2241                     VI produced, but check other QA
## 16   2242            Pixel produced, but most probably cloudy
## 17   2253                     VI produced, but check other QA
## 18   2254            Pixel produced, but most probably cloudy
## 19   2257                     VI produced, but check other QA
## 20   2258            Pixel produced, but most probably cloudy
## 21   2317                     VI produced, but check other QA
## 22   2318            Pixel produced, but most probably cloudy
## 23   2321                     VI produced, but check other QA
## 24   2322            Pixel produced, but most probably cloudy
## 25   2372                           VI produced, good quality
## 26   2374            Pixel produced, but most probably cloudy
## 27   2376                           VI produced, good quality
## 28   2378            Pixel produced, but most probably cloudy
## 29   2433                     VI produced, but check other QA
## 30   2441                     VI produced, but check other QA
## 31   2442            Pixel produced, but most probably cloudy
## 32   2445                     VI produced, but check other QA
## 33   2446            Pixel produced, but most probably cloudy
## 34   2497                     VI produced, but check other QA
## 35   2498            Pixel produced, but most probably cloudy
## 36   2513                     VI produced, but check other QA
## 37   2514            Pixel produced, but most probably cloudy
## 38   2517                     VI produced, but check other QA
## 39   2518            Pixel produced, but most probably cloudy
## 40   3074            Pixel produced, but most probably cloudy
## 41   3094            Pixel produced, but most probably cloudy
## 42   3098            Pixel produced, but most probably cloudy
## 43   3150            Pixel produced, but most probably cloudy
## 44   3154            Pixel produced, but most probably cloudy
## 45   3218            Pixel produced, but most probably cloudy
## 46   3222            Pixel produced, but most probably cloudy
## 47   3266            Pixel produced, but most probably cloudy
## 48   3290            Pixel produced, but most probably cloudy
## 49   3294            Pixel produced, but most probably cloudy
## 50   3354            Pixel produced, but most probably cloudy
## 51   3358            Pixel produced, but most probably cloudy
## 52   3410            Pixel produced, but most probably cloudy
## 53   3414            Pixel produced, but most probably cloudy
## 54   3478            Pixel produced, but most probably cloudy
## 55   3482            Pixel produced, but most probably cloudy
## 56   3522            Pixel produced, but most probably cloudy
## 57   3550            Pixel produced, but most probably cloudy
## 58   3554            Pixel produced, but most probably cloudy
## 59   4097                     VI produced, but check other QA
## 60   4098            Pixel produced, but most probably cloudy
## 61   4105                     VI produced, but check other QA
## 62   4106            Pixel produced, but most probably cloudy
## 63   4109                     VI produced, but check other QA
## 64   4110            Pixel produced, but most probably cloudy
## 65   4160                           VI produced, good quality
## 66   4162            Pixel produced, but most probably cloudy
## 67   4164                           VI produced, good quality
## 68   4166            Pixel produced, but most probably cloudy
## 69   4225                     VI produced, but check other QA
## 70   4229                     VI produced, but check other QA
## 71   4230            Pixel produced, but most probably cloudy
## 72   4233                     VI produced, but check other QA
## 73   4234            Pixel produced, but most probably cloudy
## 74   4289                     VI produced, but check other QA
## 75   4301                     VI produced, but check other QA
## 76   4302            Pixel produced, but most probably cloudy
## 77   4305                     VI produced, but check other QA
## 78   4306            Pixel produced, but most probably cloudy
## 79   4353                     VI produced, but check other QA
## 80   4365                     VI produced, but check other QA
## 81   4366            Pixel produced, but most probably cloudy
## 82   4369                     VI produced, but check other QA
## 83   4370            Pixel produced, but most probably cloudy
## 84   5122            Pixel produced, but most probably cloudy
## 85   5142            Pixel produced, but most probably cloudy
## 86   5146            Pixel produced, but most probably cloudy
## 87   5186            Pixel produced, but most probably cloudy
## 88   5198            Pixel produced, but most probably cloudy
## 89   5202            Pixel produced, but most probably cloudy
## 90   5250            Pixel produced, but most probably cloudy
## 91   5266            Pixel produced, but most probably cloudy
## 92   5270            Pixel produced, but most probably cloudy
## 93   5314            Pixel produced, but most probably cloudy
## 94   5338            Pixel produced, but most probably cloudy
## 95   5342            Pixel produced, but most probably cloudy
## 96   5378            Pixel produced, but most probably cloudy
## 97   5402            Pixel produced, but most probably cloudy
## 98   5406            Pixel produced, but most probably cloudy
## 99   6145                     VI produced, but check other QA
## 100  6146            Pixel produced, but most probably cloudy
## 101  6153                     VI produced, but check other QA
## 102  6154            Pixel produced, but most probably cloudy
## 103  6157                     VI produced, but check other QA
## 104  6158            Pixel produced, but most probably cloudy
## 105  6208                           VI produced, good quality
## 106  6210            Pixel produced, but most probably cloudy
## 107  6212                           VI produced, good quality
## 108  6214            Pixel produced, but most probably cloudy
## 109  6273                     VI produced, but check other QA
## 110  6274            Pixel produced, but most probably cloudy
## 111  6277                     VI produced, but check other QA
## 112  6278            Pixel produced, but most probably cloudy
## 113  6281                     VI produced, but check other QA
## 114  6282            Pixel produced, but most probably cloudy
## 115  6337                     VI produced, but check other QA
## 116  6338            Pixel produced, but most probably cloudy
## 117  6349                     VI produced, but check other QA
## 118  6350            Pixel produced, but most probably cloudy
## 119  6353                     VI produced, but check other QA
## 120  6354            Pixel produced, but most probably cloudy
## 121  6401                     VI produced, but check other QA
## 122  6413                     VI produced, but check other QA
## 123  6414            Pixel produced, but most probably cloudy
## 124  6417                     VI produced, but check other QA
## 125  6418            Pixel produced, but most probably cloudy
## 126  6464                           VI produced, good quality
## 127  6468                           VI produced, good quality
## 128  6472                           VI produced, good quality
## 129  6529                     VI produced, but check other QA
## 130  6537                     VI produced, but check other QA
## 131  6541                     VI produced, but check other QA
## 132  6593                     VI produced, but check other QA
## 133  6609                     VI produced, but check other QA
## 134  6613                     VI produced, but check other QA
## 135  6614            Pixel produced, but most probably cloudy
## 136  7170            Pixel produced, but most probably cloudy
## 137  7190            Pixel produced, but most probably cloudy
## 138  7194            Pixel produced, but most probably cloudy
## 139  7234            Pixel produced, but most probably cloudy
## 140  7246            Pixel produced, but most probably cloudy
## 141  7250            Pixel produced, but most probably cloudy
## 142  7298            Pixel produced, but most probably cloudy
## 143  7314            Pixel produced, but most probably cloudy
## 144  7318            Pixel produced, but most probably cloudy
## 145  7362            Pixel produced, but most probably cloudy
## 146  7386            Pixel produced, but most probably cloudy
## 147  7390            Pixel produced, but most probably cloudy
## 148  7426            Pixel produced, but most probably cloudy
## 149  7450            Pixel produced, but most probably cloudy
## 150  7454            Pixel produced, but most probably cloudy
## 151  7618            Pixel produced, but most probably cloudy
## 152  7646            Pixel produced, but most probably cloudy
## 153  7650            Pixel produced, but most probably cloudy
## 154 34833                     VI produced, but check other QA
## 155 34834            Pixel produced, but most probably cloudy
## 156 34837                     VI produced, but check other QA
## 157 34838            Pixel produced, but most probably cloudy
## 158 34888                           VI produced, good quality
## 159 34890            Pixel produced, but most probably cloudy
## 160 34892                           VI produced, good quality
## 161 34894            Pixel produced, but most probably cloudy
## 162 34957                     VI produced, but check other QA
## 163 34958            Pixel produced, but most probably cloudy
## 164 34961                     VI produced, but check other QA
## 165 34962            Pixel produced, but most probably cloudy
## 166 35029                     VI produced, but check other QA
## 167 35030            Pixel produced, but most probably cloudy
## 168 35033                     VI produced, but check other QA
## 169 35034            Pixel produced, but most probably cloudy
## 170 35089                     VI produced, but check other QA
## 171 35090            Pixel produced, but most probably cloudy
## 172 35093                     VI produced, but check other QA
## 173 35094            Pixel produced, but most probably cloudy
## 174 35097                     VI produced, but check other QA
## 175 35098            Pixel produced, but most probably cloudy
## 176 35144                           VI produced, good quality
## 177 35146            Pixel produced, but most probably cloudy
## 178 35148                           VI produced, good quality
## 179 35150            Pixel produced, but most probably cloudy
## 180 35152                           VI produced, good quality
## 181 35154            Pixel produced, but most probably cloudy
## 182 35201                     VI produced, but check other QA
## 183 35213                     VI produced, but check other QA
## 184 35214            Pixel produced, but most probably cloudy
## 185 35217                     VI produced, but check other QA
## 186 35218            Pixel produced, but most probably cloudy
## 187 35221                     VI produced, but check other QA
## 188 35222            Pixel produced, but most probably cloudy
## 189 35266            Pixel produced, but most probably cloudy
## 190 35285                     VI produced, but check other QA
## 191 35286            Pixel produced, but most probably cloudy
## 192 35289                     VI produced, but check other QA
## 193 35290            Pixel produced, but most probably cloudy
## 194 35293                     VI produced, but check other QA
## 195 35294            Pixel produced, but most probably cloudy
## 196 35870            Pixel produced, but most probably cloudy
## 197 35874            Pixel produced, but most probably cloudy
## 198 35926            Pixel produced, but most probably cloudy
## 199 35930            Pixel produced, but most probably cloudy
## 200 35994            Pixel produced, but most probably cloudy
## 201 35998            Pixel produced, but most probably cloudy
## 202 36034            Pixel produced, but most probably cloudy
## 203 36066            Pixel produced, but most probably cloudy
## 204 36070            Pixel produced, but most probably cloudy
## 205 36126            Pixel produced, but most probably cloudy
## 206 36130            Pixel produced, but most probably cloudy
## 207 36134            Pixel produced, but most probably cloudy
## 208 36178            Pixel produced, but most probably cloudy
## 209 36182            Pixel produced, but most probably cloudy
## 210 36186            Pixel produced, but most probably cloudy
## 211 36190            Pixel produced, but most probably cloudy
## 212 36246            Pixel produced, but most probably cloudy
## 213 36250            Pixel produced, but most probably cloudy
## 214 36254            Pixel produced, but most probably cloudy
## 215 36258            Pixel produced, but most probably cloudy
## 216 36318            Pixel produced, but most probably cloudy
## 217 36322            Pixel produced, but most probably cloudy
## 218 36326            Pixel produced, but most probably cloudy
## 219 36330            Pixel produced, but most probably cloudy
## 220 36881                     VI produced, but check other QA
## 221 36885                     VI produced, but check other QA
## 222 36928                           VI produced, good quality
## 223 36936                           VI produced, good quality
## 224 36938            Pixel produced, but most probably cloudy
## 225 36940                           VI produced, good quality
## 226 36942            Pixel produced, but most probably cloudy
## 227 36993                     VI produced, but check other QA
## 228 37005                     VI produced, but check other QA
## 229 37006            Pixel produced, but most probably cloudy
## 230 37009                     VI produced, but check other QA
## 231 37010            Pixel produced, but most probably cloudy
## 232 37077                     VI produced, but check other QA
## 233 37078            Pixel produced, but most probably cloudy
## 234 37081                     VI produced, but check other QA
## 235 37082            Pixel produced, but most probably cloudy
## 236 37121                     VI produced, but check other QA
## 237 37137                     VI produced, but check other QA
## 238 37141                     VI produced, but check other QA
## 239 37142            Pixel produced, but most probably cloudy
## 240 37145                     VI produced, but check other QA
## 241 37146            Pixel produced, but most probably cloudy
## 242 37192                           VI produced, good quality
## 243 37196                           VI produced, good quality
## 244 37261                     VI produced, but check other QA
## 245 37265                     VI produced, but check other QA
## 246 37333                     VI produced, but check other QA
## 247 37337                     VI produced, but check other QA
## 248 37918            Pixel produced, but most probably cloudy
## 249 37974            Pixel produced, but most probably cloudy
## 250 37978            Pixel produced, but most probably cloudy
## 251 38042            Pixel produced, but most probably cloudy
## 252 38046            Pixel produced, but most probably cloudy
## 253 38082            Pixel produced, but most probably cloudy
## 254 38114            Pixel produced, but most probably cloudy
## 255 38118            Pixel produced, but most probably cloudy
## 256 38146            Pixel produced, but most probably cloudy
## 257 38174            Pixel produced, but most probably cloudy
## 258 38178            Pixel produced, but most probably cloudy
## 259 38182            Pixel produced, but most probably cloudy
## 260 38913                     VI produced, but check other QA
## 261 38929                     VI produced, but check other QA
## 262 38930            Pixel produced, but most probably cloudy
## 263 38933                     VI produced, but check other QA
## 264 38976                           VI produced, good quality
## 265 38984                           VI produced, good quality
## 266 38988                           VI produced, good quality
## 267 39041                     VI produced, but check other QA
## 268 39053                     VI produced, but check other QA
## 269 39054            Pixel produced, but most probably cloudy
## 270 39057                     VI produced, but check other QA
## 271 39105                     VI produced, but check other QA
## 272 39125                     VI produced, but check other QA
## 273 39126            Pixel produced, but most probably cloudy
## 274 39129                     VI produced, but check other QA
## 275 39130            Pixel produced, but most probably cloudy
## 276 39169                     VI produced, but check other QA
## 277 39170            Pixel produced, but most probably cloudy
## 278 39185                     VI produced, but check other QA
## 279 39186            Pixel produced, but most probably cloudy
## 280 39189                     VI produced, but check other QA
## 281 39190            Pixel produced, but most probably cloudy
## 282 39193                     VI produced, but check other QA
## 283 39194            Pixel produced, but most probably cloudy
## 284 39232                           VI produced, good quality
## 285 39240                           VI produced, good quality
## 286 39244                           VI produced, good quality
## 287 39297                     VI produced, but check other QA
## 288 39309                     VI produced, but check other QA
## 289 39313                     VI produced, but check other QA
## 290 39317                     VI produced, but check other QA
## 291 39361                     VI produced, but check other QA
## 292 39362            Pixel produced, but most probably cloudy
## 293 39381                     VI produced, but check other QA
## 294 39385                     VI produced, but check other QA
## 295 39386            Pixel produced, but most probably cloudy
## 296 39389                     VI produced, but check other QA
## 297 39390            Pixel produced, but most probably cloudy
## 298 39938            Pixel produced, but most probably cloudy
## 299 39966            Pixel produced, but most probably cloudy
## 300 39970            Pixel produced, but most probably cloudy
## 301 40022            Pixel produced, but most probably cloudy
## 302 40026            Pixel produced, but most probably cloudy
## 303 40066            Pixel produced, but most probably cloudy
## 304 40090            Pixel produced, but most probably cloudy
## 305 40094            Pixel produced, but most probably cloudy
## 306 40130            Pixel produced, but most probably cloudy
## 307 40162            Pixel produced, but most probably cloudy
## 308 40166            Pixel produced, but most probably cloudy
## 309 40194            Pixel produced, but most probably cloudy
## 310 40222            Pixel produced, but most probably cloudy
## 311 40226            Pixel produced, but most probably cloudy
## 312 40230            Pixel produced, but most probably cloudy
## 313 40386            Pixel produced, but most probably cloudy
## 314 40422            Pixel produced, but most probably cloudy
## 315 40426            Pixel produced, but most probably cloudy
## 316 51199 Pixel not produced due to other reasons than clouds
## 317 63487 Pixel not produced due to other reasons than clouds
##                                     VI.Usefulness Aerosol.Quantity
## 1                                  Higest quality      Climatology
## 2                       Decreasing quality (0010)      Climatology
## 3                       Decreasing quality (0010)      Climatology
## 4                       Decreasing quality (0011)      Climatology
## 5                       Decreasing quality (0011)      Climatology
## 6                                  Higest quality              Low
## 7                                  Higest quality              Low
## 8                                   Lower quality              Low
## 9                                   Lower quality              Low
## 10                                 Higest quality          Average
## 11                                  Lower quality          Average
## 12                                  Lower quality          Average
## 13                      Decreasing quality (0010)          Average
## 14                      Decreasing quality (0010)          Average
## 15                                 Higest quality             High
## 16                                 Higest quality             High
## 17                      Decreasing quality (0011)             High
## 18                      Decreasing quality (0011)             High
## 19                      Decreasing quality (0100)             High
## 20                      Decreasing quality (0100)             High
## 21                      Decreasing quality (0011)      Climatology
## 22                      Decreasing quality (0011)      Climatology
## 23                      Decreasing quality (0100)      Climatology
## 24                      Decreasing quality (0100)      Climatology
## 25                                  Lower quality              Low
## 26                                  Lower quality              Low
## 27                      Decreasing quality (0010)              Low
## 28                      Decreasing quality (0010)              Low
## 29                                 Higest quality          Average
## 30                      Decreasing quality (0010)          Average
## 31                      Decreasing quality (0010)          Average
## 32                      Decreasing quality (0011)          Average
## 33                      Decreasing quality (0011)          Average
## 34                                 Higest quality             High
## 35                                 Higest quality             High
## 36                      Decreasing quality (0100)             High
## 37                      Decreasing quality (0100)             High
## 38                      Decreasing quality (0101)             High
## 39                      Decreasing quality (0101)             High
## 40                                 Higest quality      Climatology
## 41                      Decreasing quality (0101)      Climatology
## 42                      Decreasing quality (0110)      Climatology
## 43                      Decreasing quality (0011)              Low
## 44                      Decreasing quality (0100)              Low
## 45                      Decreasing quality (0100)          Average
## 46                      Decreasing quality (0101)          Average
## 47                                 Higest quality             High
## 48                      Decreasing quality (0110)             High
## 49                      Decreasing quality (0111)             High
## 50                      Decreasing quality (0110)      Climatology
## 51                      Decreasing quality (0111)      Climatology
## 52                      Decreasing quality (0100)              Low
## 53                      Decreasing quality (0101)              Low
## 54                      Decreasing quality (0101)          Average
## 55                      Decreasing quality (0110)          Average
## 56                                 Higest quality             High
## 57                      Decreasing quality (0111)             High
## 58                      Decreasing quality (1000)             High
## 59                                 Higest quality      Climatology
## 60                                 Higest quality      Climatology
## 61                      Decreasing quality (0010)      Climatology
## 62                      Decreasing quality (0010)      Climatology
## 63                      Decreasing quality (0011)      Climatology
## 64                      Decreasing quality (0011)      Climatology
## 65                                 Higest quality              Low
## 66                                 Higest quality              Low
## 67                                  Lower quality              Low
## 68                                  Lower quality              Low
## 69                                 Higest quality          Average
## 70                                  Lower quality          Average
## 71                                  Lower quality          Average
## 72                      Decreasing quality (0010)          Average
## 73                      Decreasing quality (0010)          Average
## 74                                 Higest quality             High
## 75                      Decreasing quality (0011)             High
## 76                      Decreasing quality (0011)             High
## 77                      Decreasing quality (0100)             High
## 78                      Decreasing quality (0100)             High
## 79                                 Higest quality      Climatology
## 80                      Decreasing quality (0011)      Climatology
## 81                      Decreasing quality (0011)      Climatology
## 82                      Decreasing quality (0100)      Climatology
## 83                      Decreasing quality (0100)      Climatology
## 84                                 Higest quality      Climatology
## 85                      Decreasing quality (0101)      Climatology
## 86                      Decreasing quality (0110)      Climatology
## 87                                 Higest quality              Low
## 88                      Decreasing quality (0011)              Low
## 89                      Decreasing quality (0100)              Low
## 90                                 Higest quality          Average
## 91                      Decreasing quality (0100)          Average
## 92                      Decreasing quality (0101)          Average
## 93                                 Higest quality             High
## 94                      Decreasing quality (0110)             High
## 95                      Decreasing quality (0111)             High
## 96                                 Higest quality      Climatology
## 97                      Decreasing quality (0110)      Climatology
## 98                      Decreasing quality (0111)      Climatology
## 99                                 Higest quality      Climatology
## 100                                Higest quality      Climatology
## 101                     Decreasing quality (0010)      Climatology
## 102                     Decreasing quality (0010)      Climatology
## 103                     Decreasing quality (0011)      Climatology
## 104                     Decreasing quality (0011)      Climatology
## 105                                Higest quality              Low
## 106                                Higest quality              Low
## 107                                 Lower quality              Low
## 108                                 Lower quality              Low
## 109                                Higest quality          Average
## 110                                Higest quality          Average
## 111                                 Lower quality          Average
## 112                                 Lower quality          Average
## 113                     Decreasing quality (0010)          Average
## 114                     Decreasing quality (0010)          Average
## 115                                Higest quality             High
## 116                                Higest quality             High
## 117                     Decreasing quality (0011)             High
## 118                     Decreasing quality (0011)             High
## 119                     Decreasing quality (0100)             High
## 120                     Decreasing quality (0100)             High
## 121                                Higest quality      Climatology
## 122                     Decreasing quality (0011)      Climatology
## 123                     Decreasing quality (0011)      Climatology
## 124                     Decreasing quality (0100)      Climatology
## 125                     Decreasing quality (0100)      Climatology
## 126                                Higest quality              Low
## 127                                 Lower quality              Low
## 128                     Decreasing quality (0010)              Low
## 129                                Higest quality          Average
## 130                     Decreasing quality (0010)          Average
## 131                     Decreasing quality (0011)          Average
## 132                                Higest quality             High
## 133                     Decreasing quality (0100)             High
## 134                     Decreasing quality (0101)             High
## 135                     Decreasing quality (0101)             High
## 136                                Higest quality      Climatology
## 137                     Decreasing quality (0101)      Climatology
## 138                     Decreasing quality (0110)      Climatology
## 139                                Higest quality              Low
## 140                     Decreasing quality (0011)              Low
## 141                     Decreasing quality (0100)              Low
## 142                                Higest quality          Average
## 143                     Decreasing quality (0100)          Average
## 144                     Decreasing quality (0101)          Average
## 145                                Higest quality             High
## 146                     Decreasing quality (0110)             High
## 147                     Decreasing quality (0111)             High
## 148                                Higest quality      Climatology
## 149                     Decreasing quality (0110)      Climatology
## 150                     Decreasing quality (0111)      Climatology
## 151                                Higest quality             High
## 152                     Decreasing quality (0111)             High
## 153                     Decreasing quality (1000)             High
## 154                     Decreasing quality (0100)      Climatology
## 155                     Decreasing quality (0100)      Climatology
## 156                     Decreasing quality (0101)      Climatology
## 157                     Decreasing quality (0101)      Climatology
## 158                     Decreasing quality (0010)              Low
## 159                     Decreasing quality (0010)              Low
## 160                     Decreasing quality (0011)              Low
## 161                     Decreasing quality (0011)              Low
## 162                     Decreasing quality (0011)          Average
## 163                     Decreasing quality (0011)          Average
## 164                     Decreasing quality (0100)          Average
## 165                     Decreasing quality (0100)          Average
## 166                     Decreasing quality (0101)             High
## 167                     Decreasing quality (0101)             High
## 168                     Decreasing quality (0110)             High
## 169                     Decreasing quality (0110)             High
## 170                     Decreasing quality (0100)      Climatology
## 171                     Decreasing quality (0100)      Climatology
## 172                     Decreasing quality (0101)      Climatology
## 173                     Decreasing quality (0101)      Climatology
## 174                     Decreasing quality (0110)      Climatology
## 175                     Decreasing quality (0110)      Climatology
## 176                     Decreasing quality (0010)              Low
## 177                     Decreasing quality (0010)              Low
## 178                     Decreasing quality (0011)              Low
## 179                     Decreasing quality (0011)              Low
## 180                     Decreasing quality (0100)              Low
## 181                     Decreasing quality (0100)              Low
## 182                                Higest quality          Average
## 183                     Decreasing quality (0011)          Average
## 184                     Decreasing quality (0011)          Average
## 185                     Decreasing quality (0100)          Average
## 186                     Decreasing quality (0100)          Average
## 187                     Decreasing quality (0101)          Average
## 188                     Decreasing quality (0101)          Average
## 189                                Higest quality             High
## 190                     Decreasing quality (0101)             High
## 191                     Decreasing quality (0101)             High
## 192                     Decreasing quality (0110)             High
## 193                     Decreasing quality (0110)             High
## 194                     Decreasing quality (0111)             High
## 195                     Decreasing quality (0111)             High
## 196                     Decreasing quality (0111)      Climatology
## 197                     Decreasing quality (1000)      Climatology
## 198                     Decreasing quality (0101)              Low
## 199                     Decreasing quality (0110)              Low
## 200                     Decreasing quality (0110)          Average
## 201                     Decreasing quality (0111)          Average
## 202                                Higest quality             High
## 203                     Decreasing quality (1000)             High
## 204                     Decreasing quality (1001)             High
## 205                     Decreasing quality (0111)      Climatology
## 206                     Decreasing quality (1000)      Climatology
## 207                     Decreasing quality (1001)      Climatology
## 208                     Decreasing quality (0100)              Low
## 209                     Decreasing quality (0101)              Low
## 210                     Decreasing quality (0110)              Low
## 211                     Decreasing quality (0111)              Low
## 212                     Decreasing quality (0101)          Average
## 213                     Decreasing quality (0110)          Average
## 214                     Decreasing quality (0111)          Average
## 215                     Decreasing quality (1000)          Average
## 216                     Decreasing quality (0111)             High
## 217                     Decreasing quality (1000)             High
## 218                     Decreasing quality (1001)             High
## 219                     Decreasing quality (1010)             High
## 220                     Decreasing quality (0100)      Climatology
## 221                     Decreasing quality (0101)      Climatology
## 222                                Higest quality              Low
## 223                     Decreasing quality (0010)              Low
## 224                     Decreasing quality (0010)              Low
## 225                     Decreasing quality (0011)              Low
## 226                     Decreasing quality (0011)              Low
## 227                                Higest quality          Average
## 228                     Decreasing quality (0011)          Average
## 229                     Decreasing quality (0011)          Average
## 230                     Decreasing quality (0100)          Average
## 231                     Decreasing quality (0100)          Average
## 232                     Decreasing quality (0101)             High
## 233                     Decreasing quality (0101)             High
## 234                     Decreasing quality (0110)             High
## 235                     Decreasing quality (0110)             High
## 236                                Higest quality      Climatology
## 237                     Decreasing quality (0100)      Climatology
## 238                     Decreasing quality (0101)      Climatology
## 239                     Decreasing quality (0101)      Climatology
## 240                     Decreasing quality (0110)      Climatology
## 241                     Decreasing quality (0110)      Climatology
## 242                     Decreasing quality (0010)              Low
## 243                     Decreasing quality (0011)              Low
## 244                     Decreasing quality (0011)          Average
## 245                     Decreasing quality (0100)          Average
## 246                     Decreasing quality (0101)             High
## 247                     Decreasing quality (0110)             High
## 248                     Decreasing quality (0111)      Climatology
## 249                     Decreasing quality (0101)              Low
## 250                     Decreasing quality (0110)              Low
## 251                     Decreasing quality (0110)          Average
## 252                     Decreasing quality (0111)          Average
## 253                                Higest quality             High
## 254                     Decreasing quality (1000)             High
## 255                     Decreasing quality (1001)             High
## 256                                Higest quality      Climatology
## 257                     Decreasing quality (0111)      Climatology
## 258                     Decreasing quality (1000)      Climatology
## 259                     Decreasing quality (1001)      Climatology
## 260                                Higest quality      Climatology
## 261                     Decreasing quality (0100)      Climatology
## 262                     Decreasing quality (0100)      Climatology
## 263                     Decreasing quality (0101)      Climatology
## 264                                Higest quality              Low
## 265                     Decreasing quality (0010)              Low
## 266                     Decreasing quality (0011)              Low
## 267                                Higest quality          Average
## 268                     Decreasing quality (0011)          Average
## 269                     Decreasing quality (0011)          Average
## 270                     Decreasing quality (0100)          Average
## 271                                Higest quality             High
## 272                     Decreasing quality (0101)             High
## 273                     Decreasing quality (0101)             High
## 274                     Decreasing quality (0110)             High
## 275                     Decreasing quality (0110)             High
## 276                                Higest quality      Climatology
## 277                                Higest quality      Climatology
## 278                     Decreasing quality (0100)      Climatology
## 279                     Decreasing quality (0100)      Climatology
## 280                     Decreasing quality (0101)      Climatology
## 281                     Decreasing quality (0101)      Climatology
## 282                     Decreasing quality (0110)      Climatology
## 283                     Decreasing quality (0110)      Climatology
## 284                                Higest quality              Low
## 285                     Decreasing quality (0010)              Low
## 286                     Decreasing quality (0011)              Low
## 287                                Higest quality          Average
## 288                     Decreasing quality (0011)          Average
## 289                     Decreasing quality (0100)          Average
## 290                     Decreasing quality (0101)          Average
## 291                                Higest quality             High
## 292                                Higest quality             High
## 293                     Decreasing quality (0101)             High
## 294                     Decreasing quality (0110)             High
## 295                     Decreasing quality (0110)             High
## 296                     Decreasing quality (0111)             High
## 297                     Decreasing quality (0111)             High
## 298                                Higest quality      Climatology
## 299                     Decreasing quality (0111)      Climatology
## 300                     Decreasing quality (1000)      Climatology
## 301                     Decreasing quality (0101)              Low
## 302                     Decreasing quality (0110)              Low
## 303                                Higest quality          Average
## 304                     Decreasing quality (0110)          Average
## 305                     Decreasing quality (0111)          Average
## 306                                Higest quality             High
## 307                     Decreasing quality (1000)             High
## 308                     Decreasing quality (1001)             High
## 309                                Higest quality      Climatology
## 310                     Decreasing quality (0111)      Climatology
## 311                     Decreasing quality (1000)      Climatology
## 312                     Decreasing quality (1001)      Climatology
## 313                                Higest quality             High
## 314                     Decreasing quality (1001)             High
## 315                     Decreasing quality (1010)             High
## 316 Not useful for any other reason/not processed             High
## 317 Not useful for any other reason/not processed             High
##     Adjacent.cloud.detected Atmosphere.BRDF.Correction Mixed.Clouds
## 1                        No                         No           No
## 2                        No                         No           No
## 3                        No                         No           No
## 4                        No                         No           No
## 5                        No                         No           No
## 6                        No                         No           No
## 7                        No                         No           No
## 8                        No                         No           No
## 9                        No                         No           No
## 10                       No                         No           No
## 11                       No                         No           No
## 12                       No                         No           No
## 13                       No                         No           No
## 14                       No                         No           No
## 15                       No                         No           No
## 16                       No                         No           No
## 17                       No                         No           No
## 18                       No                         No           No
## 19                       No                         No           No
## 20                       No                         No           No
## 21                      Yes                         No           No
## 22                      Yes                         No           No
## 23                      Yes                         No           No
## 24                      Yes                         No           No
## 25                      Yes                         No           No
## 26                      Yes                         No           No
## 27                      Yes                         No           No
## 28                      Yes                         No           No
## 29                      Yes                         No           No
## 30                      Yes                         No           No
## 31                      Yes                         No           No
## 32                      Yes                         No           No
## 33                      Yes                         No           No
## 34                      Yes                         No           No
## 35                      Yes                         No           No
## 36                      Yes                         No           No
## 37                      Yes                         No           No
## 38                      Yes                         No           No
## 39                      Yes                         No           No
## 40                       No                         No          Yes
## 41                       No                         No          Yes
## 42                       No                         No          Yes
## 43                       No                         No          Yes
## 44                       No                         No          Yes
## 45                       No                         No          Yes
## 46                       No                         No          Yes
## 47                       No                         No          Yes
## 48                       No                         No          Yes
## 49                       No                         No          Yes
## 50                      Yes                         No          Yes
## 51                      Yes                         No          Yes
## 52                      Yes                         No          Yes
## 53                      Yes                         No          Yes
## 54                      Yes                         No          Yes
## 55                      Yes                         No          Yes
## 56                      Yes                         No          Yes
## 57                      Yes                         No          Yes
## 58                      Yes                         No          Yes
## 59                       No                         No           No
## 60                       No                         No           No
## 61                       No                         No           No
## 62                       No                         No           No
## 63                       No                         No           No
## 64                       No                         No           No
## 65                       No                         No           No
## 66                       No                         No           No
## 67                       No                         No           No
## 68                       No                         No           No
## 69                       No                         No           No
## 70                       No                         No           No
## 71                       No                         No           No
## 72                       No                         No           No
## 73                       No                         No           No
## 74                       No                         No           No
## 75                       No                         No           No
## 76                       No                         No           No
## 77                       No                         No           No
## 78                       No                         No           No
## 79                      Yes                         No           No
## 80                      Yes                         No           No
## 81                      Yes                         No           No
## 82                      Yes                         No           No
## 83                      Yes                         No           No
## 84                       No                         No          Yes
## 85                       No                         No          Yes
## 86                       No                         No          Yes
## 87                       No                         No          Yes
## 88                       No                         No          Yes
## 89                       No                         No          Yes
## 90                       No                         No          Yes
## 91                       No                         No          Yes
## 92                       No                         No          Yes
## 93                       No                         No          Yes
## 94                       No                         No          Yes
## 95                       No                         No          Yes
## 96                      Yes                         No          Yes
## 97                      Yes                         No          Yes
## 98                      Yes                         No          Yes
## 99                       No                         No           No
## 100                      No                         No           No
## 101                      No                         No           No
## 102                      No                         No           No
## 103                      No                         No           No
## 104                      No                         No           No
## 105                      No                         No           No
## 106                      No                         No           No
## 107                      No                         No           No
## 108                      No                         No           No
## 109                      No                         No           No
## 110                      No                         No           No
## 111                      No                         No           No
## 112                      No                         No           No
## 113                      No                         No           No
## 114                      No                         No           No
## 115                      No                         No           No
## 116                      No                         No           No
## 117                      No                         No           No
## 118                      No                         No           No
## 119                      No                         No           No
## 120                      No                         No           No
## 121                     Yes                         No           No
## 122                     Yes                         No           No
## 123                     Yes                         No           No
## 124                     Yes                         No           No
## 125                     Yes                         No           No
## 126                     Yes                         No           No
## 127                     Yes                         No           No
## 128                     Yes                         No           No
## 129                     Yes                         No           No
## 130                     Yes                         No           No
## 131                     Yes                         No           No
## 132                     Yes                         No           No
## 133                     Yes                         No           No
## 134                     Yes                         No           No
## 135                     Yes                         No           No
## 136                      No                         No          Yes
## 137                      No                         No          Yes
## 138                      No                         No          Yes
## 139                      No                         No          Yes
## 140                      No                         No          Yes
## 141                      No                         No          Yes
## 142                      No                         No          Yes
## 143                      No                         No          Yes
## 144                      No                         No          Yes
## 145                      No                         No          Yes
## 146                      No                         No          Yes
## 147                      No                         No          Yes
## 148                     Yes                         No          Yes
## 149                     Yes                         No          Yes
## 150                     Yes                         No          Yes
## 151                     Yes                         No          Yes
## 152                     Yes                         No          Yes
## 153                     Yes                         No          Yes
## 154                      No                         No           No
## 155                      No                         No           No
## 156                      No                         No           No
## 157                      No                         No           No
## 158                      No                         No           No
## 159                      No                         No           No
## 160                      No                         No           No
## 161                      No                         No           No
## 162                      No                         No           No
## 163                      No                         No           No
## 164                      No                         No           No
## 165                      No                         No           No
## 166                      No                         No           No
## 167                      No                         No           No
## 168                      No                         No           No
## 169                      No                         No           No
## 170                     Yes                         No           No
## 171                     Yes                         No           No
## 172                     Yes                         No           No
## 173                     Yes                         No           No
## 174                     Yes                         No           No
## 175                     Yes                         No           No
## 176                     Yes                         No           No
## 177                     Yes                         No           No
## 178                     Yes                         No           No
## 179                     Yes                         No           No
## 180                     Yes                         No           No
## 181                     Yes                         No           No
## 182                     Yes                         No           No
## 183                     Yes                         No           No
## 184                     Yes                         No           No
## 185                     Yes                         No           No
## 186                     Yes                         No           No
## 187                     Yes                         No           No
## 188                     Yes                         No           No
## 189                     Yes                         No           No
## 190                     Yes                         No           No
## 191                     Yes                         No           No
## 192                     Yes                         No           No
## 193                     Yes                         No           No
## 194                     Yes                         No           No
## 195                     Yes                         No           No
## 196                      No                         No          Yes
## 197                      No                         No          Yes
## 198                      No                         No          Yes
## 199                      No                         No          Yes
## 200                      No                         No          Yes
## 201                      No                         No          Yes
## 202                      No                         No          Yes
## 203                      No                         No          Yes
## 204                      No                         No          Yes
## 205                     Yes                         No          Yes
## 206                     Yes                         No          Yes
## 207                     Yes                         No          Yes
## 208                     Yes                         No          Yes
## 209                     Yes                         No          Yes
## 210                     Yes                         No          Yes
## 211                     Yes                         No          Yes
## 212                     Yes                         No          Yes
## 213                     Yes                         No          Yes
## 214                     Yes                         No          Yes
## 215                     Yes                         No          Yes
## 216                     Yes                         No          Yes
## 217                     Yes                         No          Yes
## 218                     Yes                         No          Yes
## 219                     Yes                         No          Yes
## 220                      No                         No           No
## 221                      No                         No           No
## 222                      No                         No           No
## 223                      No                         No           No
## 224                      No                         No           No
## 225                      No                         No           No
## 226                      No                         No           No
## 227                      No                         No           No
## 228                      No                         No           No
## 229                      No                         No           No
## 230                      No                         No           No
## 231                      No                         No           No
## 232                      No                         No           No
## 233                      No                         No           No
## 234                      No                         No           No
## 235                      No                         No           No
## 236                     Yes                         No           No
## 237                     Yes                         No           No
## 238                     Yes                         No           No
## 239                     Yes                         No           No
## 240                     Yes                         No           No
## 241                     Yes                         No           No
## 242                     Yes                         No           No
## 243                     Yes                         No           No
## 244                     Yes                         No           No
## 245                     Yes                         No           No
## 246                     Yes                         No           No
## 247                     Yes                         No           No
## 248                      No                         No          Yes
## 249                      No                         No          Yes
## 250                      No                         No          Yes
## 251                      No                         No          Yes
## 252                      No                         No          Yes
## 253                      No                         No          Yes
## 254                      No                         No          Yes
## 255                      No                         No          Yes
## 256                     Yes                         No          Yes
## 257                     Yes                         No          Yes
## 258                     Yes                         No          Yes
## 259                     Yes                         No          Yes
## 260                      No                         No           No
## 261                      No                         No           No
## 262                      No                         No           No
## 263                      No                         No           No
## 264                      No                         No           No
## 265                      No                         No           No
## 266                      No                         No           No
## 267                      No                         No           No
## 268                      No                         No           No
## 269                      No                         No           No
## 270                      No                         No           No
## 271                      No                         No           No
## 272                      No                         No           No
## 273                      No                         No           No
## 274                      No                         No           No
## 275                      No                         No           No
## 276                     Yes                         No           No
## 277                     Yes                         No           No
## 278                     Yes                         No           No
## 279                     Yes                         No           No
## 280                     Yes                         No           No
## 281                     Yes                         No           No
## 282                     Yes                         No           No
## 283                     Yes                         No           No
## 284                     Yes                         No           No
## 285                     Yes                         No           No
## 286                     Yes                         No           No
## 287                     Yes                         No           No
## 288                     Yes                         No           No
## 289                     Yes                         No           No
## 290                     Yes                         No           No
## 291                     Yes                         No           No
## 292                     Yes                         No           No
## 293                     Yes                         No           No
## 294                     Yes                         No           No
## 295                     Yes                         No           No
## 296                     Yes                         No           No
## 297                     Yes                         No           No
## 298                      No                         No          Yes
## 299                      No                         No          Yes
## 300                      No                         No          Yes
## 301                      No                         No          Yes
## 302                      No                         No          Yes
## 303                      No                         No          Yes
## 304                      No                         No          Yes
## 305                      No                         No          Yes
## 306                      No                         No          Yes
## 307                      No                         No          Yes
## 308                      No                         No          Yes
## 309                     Yes                         No          Yes
## 310                     Yes                         No          Yes
## 311                     Yes                         No          Yes
## 312                     Yes                         No          Yes
## 313                     Yes                         No          Yes
## 314                     Yes                         No          Yes
## 315                     Yes                         No          Yes
## 316                     Yes                        Yes          Yes
## 317                     Yes                        Yes          Yes
##                          Land.Water.Mask Possible.snow.ice Possible.shadow
## 1           Land (Nothing else but land)                No              No
## 2           Land (Nothing else but land)                No              No
## 3           Land (Nothing else but land)                No              No
## 4           Land (Nothing else but land)                No              No
## 5           Land (Nothing else but land)                No              No
## 6           Land (Nothing else but land)                No              No
## 7           Land (Nothing else but land)                No              No
## 8           Land (Nothing else but land)                No              No
## 9           Land (Nothing else but land)                No              No
## 10          Land (Nothing else but land)                No              No
## 11          Land (Nothing else but land)                No              No
## 12          Land (Nothing else but land)                No              No
## 13          Land (Nothing else but land)                No              No
## 14          Land (Nothing else but land)                No              No
## 15          Land (Nothing else but land)                No              No
## 16          Land (Nothing else but land)                No              No
## 17          Land (Nothing else but land)                No              No
## 18          Land (Nothing else but land)                No              No
## 19          Land (Nothing else but land)                No              No
## 20          Land (Nothing else but land)                No              No
## 21          Land (Nothing else but land)                No              No
## 22          Land (Nothing else but land)                No              No
## 23          Land (Nothing else but land)                No              No
## 24          Land (Nothing else but land)                No              No
## 25          Land (Nothing else but land)                No              No
## 26          Land (Nothing else but land)                No              No
## 27          Land (Nothing else but land)                No              No
## 28          Land (Nothing else but land)                No              No
## 29          Land (Nothing else but land)                No              No
## 30          Land (Nothing else but land)                No              No
## 31          Land (Nothing else but land)                No              No
## 32          Land (Nothing else but land)                No              No
## 33          Land (Nothing else but land)                No              No
## 34          Land (Nothing else but land)                No              No
## 35          Land (Nothing else but land)                No              No
## 36          Land (Nothing else but land)                No              No
## 37          Land (Nothing else but land)                No              No
## 38          Land (Nothing else but land)                No              No
## 39          Land (Nothing else but land)                No              No
## 40          Land (Nothing else but land)                No              No
## 41          Land (Nothing else but land)                No              No
## 42          Land (Nothing else but land)                No              No
## 43          Land (Nothing else but land)                No              No
## 44          Land (Nothing else but land)                No              No
## 45          Land (Nothing else but land)                No              No
## 46          Land (Nothing else but land)                No              No
## 47          Land (Nothing else but land)                No              No
## 48          Land (Nothing else but land)                No              No
## 49          Land (Nothing else but land)                No              No
## 50          Land (Nothing else but land)                No              No
## 51          Land (Nothing else but land)                No              No
## 52          Land (Nothing else but land)                No              No
## 53          Land (Nothing else but land)                No              No
## 54          Land (Nothing else but land)                No              No
## 55          Land (Nothing else but land)                No              No
## 56          Land (Nothing else but land)                No              No
## 57          Land (Nothing else but land)                No              No
## 58          Land (Nothing else but land)                No              No
## 59  Ocean coastlines and lake shorelines                No              No
## 60  Ocean coastlines and lake shorelines                No              No
## 61  Ocean coastlines and lake shorelines                No              No
## 62  Ocean coastlines and lake shorelines                No              No
## 63  Ocean coastlines and lake shorelines                No              No
## 64  Ocean coastlines and lake shorelines                No              No
## 65  Ocean coastlines and lake shorelines                No              No
## 66  Ocean coastlines and lake shorelines                No              No
## 67  Ocean coastlines and lake shorelines                No              No
## 68  Ocean coastlines and lake shorelines                No              No
## 69  Ocean coastlines and lake shorelines                No              No
## 70  Ocean coastlines and lake shorelines                No              No
## 71  Ocean coastlines and lake shorelines                No              No
## 72  Ocean coastlines and lake shorelines                No              No
## 73  Ocean coastlines and lake shorelines                No              No
## 74  Ocean coastlines and lake shorelines                No              No
## 75  Ocean coastlines and lake shorelines                No              No
## 76  Ocean coastlines and lake shorelines                No              No
## 77  Ocean coastlines and lake shorelines                No              No
## 78  Ocean coastlines and lake shorelines                No              No
## 79  Ocean coastlines and lake shorelines                No              No
## 80  Ocean coastlines and lake shorelines                No              No
## 81  Ocean coastlines and lake shorelines                No              No
## 82  Ocean coastlines and lake shorelines                No              No
## 83  Ocean coastlines and lake shorelines                No              No
## 84  Ocean coastlines and lake shorelines                No              No
## 85  Ocean coastlines and lake shorelines                No              No
## 86  Ocean coastlines and lake shorelines                No              No
## 87  Ocean coastlines and lake shorelines                No              No
## 88  Ocean coastlines and lake shorelines                No              No
## 89  Ocean coastlines and lake shorelines                No              No
## 90  Ocean coastlines and lake shorelines                No              No
## 91  Ocean coastlines and lake shorelines                No              No
## 92  Ocean coastlines and lake shorelines                No              No
## 93  Ocean coastlines and lake shorelines                No              No
## 94  Ocean coastlines and lake shorelines                No              No
## 95  Ocean coastlines and lake shorelines                No              No
## 96  Ocean coastlines and lake shorelines                No              No
## 97  Ocean coastlines and lake shorelines                No              No
## 98  Ocean coastlines and lake shorelines                No              No
## 99                  Shallow inland water                No              No
## 100                 Shallow inland water                No              No
## 101                 Shallow inland water                No              No
## 102                 Shallow inland water                No              No
## 103                 Shallow inland water                No              No
## 104                 Shallow inland water                No              No
## 105                 Shallow inland water                No              No
## 106                 Shallow inland water                No              No
## 107                 Shallow inland water                No              No
## 108                 Shallow inland water                No              No
## 109                 Shallow inland water                No              No
## 110                 Shallow inland water                No              No
## 111                 Shallow inland water                No              No
## 112                 Shallow inland water                No              No
## 113                 Shallow inland water                No              No
## 114                 Shallow inland water                No              No
## 115                 Shallow inland water                No              No
## 116                 Shallow inland water                No              No
## 117                 Shallow inland water                No              No
## 118                 Shallow inland water                No              No
## 119                 Shallow inland water                No              No
## 120                 Shallow inland water                No              No
## 121                 Shallow inland water                No              No
## 122                 Shallow inland water                No              No
## 123                 Shallow inland water                No              No
## 124                 Shallow inland water                No              No
## 125                 Shallow inland water                No              No
## 126                 Shallow inland water                No              No
## 127                 Shallow inland water                No              No
## 128                 Shallow inland water                No              No
## 129                 Shallow inland water                No              No
## 130                 Shallow inland water                No              No
## 131                 Shallow inland water                No              No
## 132                 Shallow inland water                No              No
## 133                 Shallow inland water                No              No
## 134                 Shallow inland water                No              No
## 135                 Shallow inland water                No              No
## 136                 Shallow inland water                No              No
## 137                 Shallow inland water                No              No
## 138                 Shallow inland water                No              No
## 139                 Shallow inland water                No              No
## 140                 Shallow inland water                No              No
## 141                 Shallow inland water                No              No
## 142                 Shallow inland water                No              No
## 143                 Shallow inland water                No              No
## 144                 Shallow inland water                No              No
## 145                 Shallow inland water                No              No
## 146                 Shallow inland water                No              No
## 147                 Shallow inland water                No              No
## 148                 Shallow inland water                No              No
## 149                 Shallow inland water                No              No
## 150                 Shallow inland water                No              No
## 151                 Shallow inland water                No              No
## 152                 Shallow inland water                No              No
## 153                 Shallow inland water                No              No
## 154         Land (Nothing else but land)                No             Yes
## 155         Land (Nothing else but land)                No             Yes
## 156         Land (Nothing else but land)                No             Yes
## 157         Land (Nothing else but land)                No             Yes
## 158         Land (Nothing else but land)                No             Yes
## 159         Land (Nothing else but land)                No             Yes
## 160         Land (Nothing else but land)                No             Yes
## 161         Land (Nothing else but land)                No             Yes
## 162         Land (Nothing else but land)                No             Yes
## 163         Land (Nothing else but land)                No             Yes
## 164         Land (Nothing else but land)                No             Yes
## 165         Land (Nothing else but land)                No             Yes
## 166         Land (Nothing else but land)                No             Yes
## 167         Land (Nothing else but land)                No             Yes
## 168         Land (Nothing else but land)                No             Yes
## 169         Land (Nothing else but land)                No             Yes
## 170         Land (Nothing else but land)                No             Yes
## 171         Land (Nothing else but land)                No             Yes
## 172         Land (Nothing else but land)                No             Yes
## 173         Land (Nothing else but land)                No             Yes
## 174         Land (Nothing else but land)                No             Yes
## 175         Land (Nothing else but land)                No             Yes
## 176         Land (Nothing else but land)                No             Yes
## 177         Land (Nothing else but land)                No             Yes
## 178         Land (Nothing else but land)                No             Yes
## 179         Land (Nothing else but land)                No             Yes
## 180         Land (Nothing else but land)                No             Yes
## 181         Land (Nothing else but land)                No             Yes
## 182         Land (Nothing else but land)                No             Yes
## 183         Land (Nothing else but land)                No             Yes
## 184         Land (Nothing else but land)                No             Yes
## 185         Land (Nothing else but land)                No             Yes
## 186         Land (Nothing else but land)                No             Yes
## 187         Land (Nothing else but land)                No             Yes
## 188         Land (Nothing else but land)                No             Yes
## 189         Land (Nothing else but land)                No             Yes
## 190         Land (Nothing else but land)                No             Yes
## 191         Land (Nothing else but land)                No             Yes
## 192         Land (Nothing else but land)                No             Yes
## 193         Land (Nothing else but land)                No             Yes
## 194         Land (Nothing else but land)                No             Yes
## 195         Land (Nothing else but land)                No             Yes
## 196         Land (Nothing else but land)                No             Yes
## 197         Land (Nothing else but land)                No             Yes
## 198         Land (Nothing else but land)                No             Yes
## 199         Land (Nothing else but land)                No             Yes
## 200         Land (Nothing else but land)                No             Yes
## 201         Land (Nothing else but land)                No             Yes
## 202         Land (Nothing else but land)                No             Yes
## 203         Land (Nothing else but land)                No             Yes
## 204         Land (Nothing else but land)                No             Yes
## 205         Land (Nothing else but land)                No             Yes
## 206         Land (Nothing else but land)                No             Yes
## 207         Land (Nothing else but land)                No             Yes
## 208         Land (Nothing else but land)                No             Yes
## 209         Land (Nothing else but land)                No             Yes
## 210         Land (Nothing else but land)                No             Yes
## 211         Land (Nothing else but land)                No             Yes
## 212         Land (Nothing else but land)                No             Yes
## 213         Land (Nothing else but land)                No             Yes
## 214         Land (Nothing else but land)                No             Yes
## 215         Land (Nothing else but land)                No             Yes
## 216         Land (Nothing else but land)                No             Yes
## 217         Land (Nothing else but land)                No             Yes
## 218         Land (Nothing else but land)                No             Yes
## 219         Land (Nothing else but land)                No             Yes
## 220 Ocean coastlines and lake shorelines                No             Yes
## 221 Ocean coastlines and lake shorelines                No             Yes
## 222 Ocean coastlines and lake shorelines                No             Yes
## 223 Ocean coastlines and lake shorelines                No             Yes
## 224 Ocean coastlines and lake shorelines                No             Yes
## 225 Ocean coastlines and lake shorelines                No             Yes
## 226 Ocean coastlines and lake shorelines                No             Yes
## 227 Ocean coastlines and lake shorelines                No             Yes
## 228 Ocean coastlines and lake shorelines                No             Yes
## 229 Ocean coastlines and lake shorelines                No             Yes
## 230 Ocean coastlines and lake shorelines                No             Yes
## 231 Ocean coastlines and lake shorelines                No             Yes
## 232 Ocean coastlines and lake shorelines                No             Yes
## 233 Ocean coastlines and lake shorelines                No             Yes
## 234 Ocean coastlines and lake shorelines                No             Yes
## 235 Ocean coastlines and lake shorelines                No             Yes
## 236 Ocean coastlines and lake shorelines                No             Yes
## 237 Ocean coastlines and lake shorelines                No             Yes
## 238 Ocean coastlines and lake shorelines                No             Yes
## 239 Ocean coastlines and lake shorelines                No             Yes
## 240 Ocean coastlines and lake shorelines                No             Yes
## 241 Ocean coastlines and lake shorelines                No             Yes
## 242 Ocean coastlines and lake shorelines                No             Yes
## 243 Ocean coastlines and lake shorelines                No             Yes
## 244 Ocean coastlines and lake shorelines                No             Yes
## 245 Ocean coastlines and lake shorelines                No             Yes
## 246 Ocean coastlines and lake shorelines                No             Yes
## 247 Ocean coastlines and lake shorelines                No             Yes
## 248 Ocean coastlines and lake shorelines                No             Yes
## 249 Ocean coastlines and lake shorelines                No             Yes
## 250 Ocean coastlines and lake shorelines                No             Yes
## 251 Ocean coastlines and lake shorelines                No             Yes
## 252 Ocean coastlines and lake shorelines                No             Yes
## 253 Ocean coastlines and lake shorelines                No             Yes
## 254 Ocean coastlines and lake shorelines                No             Yes
## 255 Ocean coastlines and lake shorelines                No             Yes
## 256 Ocean coastlines and lake shorelines                No             Yes
## 257 Ocean coastlines and lake shorelines                No             Yes
## 258 Ocean coastlines and lake shorelines                No             Yes
## 259 Ocean coastlines and lake shorelines                No             Yes
## 260                 Shallow inland water                No             Yes
## 261                 Shallow inland water                No             Yes
## 262                 Shallow inland water                No             Yes
## 263                 Shallow inland water                No             Yes
## 264                 Shallow inland water                No             Yes
## 265                 Shallow inland water                No             Yes
## 266                 Shallow inland water                No             Yes
## 267                 Shallow inland water                No             Yes
## 268                 Shallow inland water                No             Yes
## 269                 Shallow inland water                No             Yes
## 270                 Shallow inland water                No             Yes
## 271                 Shallow inland water                No             Yes
## 272                 Shallow inland water                No             Yes
## 273                 Shallow inland water                No             Yes
## 274                 Shallow inland water                No             Yes
## 275                 Shallow inland water                No             Yes
## 276                 Shallow inland water                No             Yes
## 277                 Shallow inland water                No             Yes
## 278                 Shallow inland water                No             Yes
## 279                 Shallow inland water                No             Yes
## 280                 Shallow inland water                No             Yes
## 281                 Shallow inland water                No             Yes
## 282                 Shallow inland water                No             Yes
## 283                 Shallow inland water                No             Yes
## 284                 Shallow inland water                No             Yes
## 285                 Shallow inland water                No             Yes
## 286                 Shallow inland water                No             Yes
## 287                 Shallow inland water                No             Yes
## 288                 Shallow inland water                No             Yes
## 289                 Shallow inland water                No             Yes
## 290                 Shallow inland water                No             Yes
## 291                 Shallow inland water                No             Yes
## 292                 Shallow inland water                No             Yes
## 293                 Shallow inland water                No             Yes
## 294                 Shallow inland water                No             Yes
## 295                 Shallow inland water                No             Yes
## 296                 Shallow inland water                No             Yes
## 297                 Shallow inland water                No             Yes
## 298                 Shallow inland water                No             Yes
## 299                 Shallow inland water                No             Yes
## 300                 Shallow inland water                No             Yes
## 301                 Shallow inland water                No             Yes
## 302                 Shallow inland water                No             Yes
## 303                 Shallow inland water                No             Yes
## 304                 Shallow inland water                No             Yes
## 305                 Shallow inland water                No             Yes
## 306                 Shallow inland water                No             Yes
## 307                 Shallow inland water                No             Yes
## 308                 Shallow inland water                No             Yes
## 309                 Shallow inland water                No             Yes
## 310                 Shallow inland water                No             Yes
## 311                 Shallow inland water                No             Yes
## 312                 Shallow inland water                No             Yes
## 313                 Shallow inland water                No             Yes
## 314                 Shallow inland water                No             Yes
## 315                 Shallow inland water                No             Yes
## 316                        Shallow ocean               Yes             Yes
## 317        Moderate or continental ocean               Yes             Yes

Page through the table above to see the quality information contained in the LUT. Value refers to the pixel values, followed by the specific bit beginning with MODLAND. AppEEARS decodes each binary quality bit-field into more meaningful information for the user.

The case study used the following quality parameters to define their screening process:

  1. MODLAND_QA flag = 0 or 1

    • 0 = good quality
    • 1 = check other QA
  2. VI usefulness <= 11

    • 0000 Highest quality = 0
    • 0001 Lower quality = 1
    • 0010 Decreasing quality = 2
    • ...
    • 1011 Decreasing quality = 11
  3. Adjacent cloud detected, Mixed Clouds, and Possible shadow = 0

    • 0 = No
  4. Aerosol Quantity = 1 or 2

    • 1 = low aerosol
    • 2 = average aerosol

Below, use the pixel quality flag parameters outlined above in order to filter the data. Here, search the dataframe by column and value, and only keep the specific values that relate to the parameters outlined above.

Notice in the line: v6_QA_lut <- v6_QA_lut[v6_QA_lut$MODLAND %in% modland,], it is including all rows where the MODLAND column is either 'VI_produced, good quality' or 'VI produced, but check other QA'.

However, in the line: v6_QA_lut <- v6_QA_lut[!v6_QA_lut$VI.Usefulness %in% VIU,], by adding the ! in front of the command, the dataframe will exclude the values in the VIU variable.

# Exclude poor quality based on MODLAND
modland <- c('VI produced, good quality', 'VI produced, but check other QA')
v6_QA_lut <- v6_QA_lut[v6_QA_lut$MODLAND %in% modland,]

# Include better quality VI usefulness
VIU <- c("Lowest quality","Quality so low that it is not useful","L1B data faulty","Not useful for any other reason/not processed")
v6_QA_lut <- v6_QA_lut[!v6_QA_lut$VI.Usefulness %in% VIU,]

# Exclude climatology or high aerosol
AQ <- c('Low','Average')
v6_QA_lut <- v6_QA_lut[v6_QA_lut$Aerosol.Quantity %in% AQ,]

# Include where adjacent cloud, mixed clouds, or possible shadow were not detected
v6_QA_lut <- v6_QA_lut[v6_QA_lut$Adjacent.cloud.detected == 'No',]
v6_QA_lut <- v6_QA_lut[v6_QA_lut$Mixed.Clouds == 'No', ]
v6_QA_lut <- v6_QA_lut[v6_QA_lut$Possible.shadow == 'No',]
v6_QA_lut
##     Value                         MODLAND             VI.Usefulness
## 6    2112       VI produced, good quality            Higest quality
## 8    2116       VI produced, good quality             Lower quality
## 10   2177 VI produced, but check other QA            Higest quality
## 11   2181 VI produced, but check other QA             Lower quality
## 13   2185 VI produced, but check other QA Decreasing quality (0010)
## 65   4160       VI produced, good quality            Higest quality
## 67   4164       VI produced, good quality             Lower quality
## 69   4225 VI produced, but check other QA            Higest quality
## 70   4229 VI produced, but check other QA             Lower quality
## 72   4233 VI produced, but check other QA Decreasing quality (0010)
## 105  6208       VI produced, good quality            Higest quality
## 107  6212       VI produced, good quality             Lower quality
## 109  6273 VI produced, but check other QA            Higest quality
## 111  6277 VI produced, but check other QA             Lower quality
## 113  6281 VI produced, but check other QA Decreasing quality (0010)
##     Aerosol.Quantity Adjacent.cloud.detected Atmosphere.BRDF.Correction
## 6                Low                      No                         No
## 8                Low                      No                         No
## 10           Average                      No                         No
## 11           Average                      No                         No
## 13           Average                      No                         No
## 65               Low                      No                         No
## 67               Low                      No                         No
## 69           Average                      No                         No
## 70           Average                      No                         No
## 72           Average                      No                         No
## 105              Low                      No                         No
## 107              Low                      No                         No
## 109          Average                      No                         No
## 111          Average                      No                         No
## 113          Average                      No                         No
##     Mixed.Clouds                      Land.Water.Mask Possible.snow.ice
## 6             No         Land (Nothing else but land)                No
## 8             No         Land (Nothing else but land)                No
## 10            No         Land (Nothing else but land)                No
## 11            No         Land (Nothing else but land)                No
## 13            No         Land (Nothing else but land)                No
## 65            No Ocean coastlines and lake shorelines                No
## 67            No Ocean coastlines and lake shorelines                No
## 69            No Ocean coastlines and lake shorelines                No
## 70            No Ocean coastlines and lake shorelines                No
## 72            No Ocean coastlines and lake shorelines                No
## 105           No                 Shallow inland water                No
## 107           No                 Shallow inland water                No
## 109           No                 Shallow inland water                No
## 111           No                 Shallow inland water                No
## 113           No                 Shallow inland water                No
##     Possible.shadow
## 6                No
## 8                No
## 10               No
## 11               No
## 13               No
## 65               No
## 67               No
## 69               No
## 70               No
## 72               No
## 105              No
## 107              No
## 109              No
## 111              No
## 113              No

6. Set Custom QA/QC Filtering (Mask)


In this section, demonstrate how to take the list of possible values (based on quality requirements) above, and mask the EVI and quality arrays to only include pixels where the quality value is in the list of 'good quality' values based on the parameters from the case study.

# Print list of possible QA values based on parameters above
v6_QA_mask <- v6_QA_lut$Value
v6_QA_mask
##  [1] 2112 2116 2177 2181 2185 4160 4164 4225 4229 4233 6208 6212 6273 6277
## [15] 6281

So above, only pixels with those specific _1_km_16_days_VI_Quality values will be included after masking below.

Below, mask the first observation for the datasets. Notice the ! in front of the array, meaning that you don't want to exclude the list of values above, but rather exclude every other value.

# Apply QA mask to the EVI data
v6_EVI[!v6_QA %in% v6_QA_mask,]<- NA
v6_EVI_qamasked <- v6_EVI

7. Visualize NetCDF-4 Data


In this section, begin by highlighting the functionality of plotting in R using the Raster package. Start by making a basic plot of the EVI data, then add some additional parameters to the plot, and ultimately export the finished plot to an image file.

# Visualize a basic plot:
plot(v6_EVI_original)

Figure 1. MODIS Terra Version 6 EVI (MOD13A2.006) over the Amazon Basin.

Above is a basic Raster plot of the EVI array over the Amazon basin.

Next, add some additional parameters to the visualization.

Here, use cellStats() from the Raster package to calculate statistics on an entire raster array.

# Min, Max, and Mean
print(paste0('Min NDVI:', cellStats(v6_EVI_original, stat='min', na.rm=TRUE)))
## [1] "Min NDVI:-0.2"
print(paste0('Max NDVI:', cellStats(v6_EVI_original, stat='max', na.rm=TRUE)))
## [1] "Max NDVI:0.9059"
print(paste0('Mean NDVI:',cellStats(v6_EVI_original, stat='mean', na.rm=TRUE)))
## [1] "Mean NDVI:0.415054825025268"
# Import additional colormaps
library(RColorBrewer)

# Create custom colormap
YlGn <- brewer.pal(9, "YlGn")

# Plot the unfiltered data for time step 1, using a colormap and setting a custom linear stretch
plot(v6_EVI_original, zlim=c(-0.2,1.0), maxpixels = 20000000, col = YlGn, xaxt='n', yaxt='n')

Figure 2. MODIS Terra Version 6 EVI (MOD13A2.006) over the Amazon Basin with custom colormap.

Above is a better visualization of the data, but it is still missing important items such as a title and a colormap legend.

Below, plot the quality filtered data, add a figure title, subtitle, colormap legend, and export the result to a .png file in the output directory.

# Plot the masked data
plot(v6_EVI, zlim=c(-0.2,1.0), maxpixels = 20000000, col = YlGn, xaxt='n', yaxt='n', legend.args=list(text='EVI', side=4, font=2, line=2.5, cex=0.8))
  title("MODIS Version 6 Enhanced Vegetation Index Quality Filtered Data\nAmazon Rainforest: 07-12-2005", line = 0.21)

Figure 3. MODIS Terra Version 6 EVI (MOD13A2.006) quality filtered data over the Amazon Basin with custom colormap from July 12, 2005.

# Export difference map to a png image file. 
file_name <- strsplit(file_list[2], '.nc')[[1]]
invisible(dev.copy(png, paste0(out_dir,file_name,'_EVI.png'),width = 700, height = 600))
invisible(dev.off())

8. Mask by Land Cover Type


The case study also limited the analysis to only "forest" land cover types (LCT). Below, you can also limit your analysis based on LCT.

# Use MCD12Q1.051 to define land cover types
file_list
## [1] "MCD12Q1.051_500m_aid0001.nc" "MOD13A2.006_1km_aid0001.nc"
# Set to 'MCD12Q1.051_aid0001.nc' and open
lct_file <- nc_open(file_list[1])

# Print a list of variables in file
attributes(lct_file$var)$names
## [1] "crs"                "Land_Cover_Type_1"  "Land_Cover_Type_QC"
# Print a list of dimensions in file
attributes(lct_file$dim)$names
## [1] "time" "lat"  "lon"
# Show the variable metadata
lct_info <- ncatt_get(lct_file, "Land_Cover_Type_1")
lct_info
## $`_FillValue`
## [1] 255
## 
## $coordinates
## [1] "time lat lon"
## 
## $grid_mapping
## [1] "crs"
## 
## $valid_min
## [1] 0
## 
## $valid_max
## [1] 254
## 
## $long_name
## [1] "Land_Cover_Type_1"
## 
## $units
## [1] "class number"
## 
## $water
## [1] 0
## 
## $evergreen_needleleaf_forest
## [1] 1
## 
## $evergreen_broadleaf_forest
## [1] 2
## 
## $deciduous_needleleaf_forest
## [1] 3
## 
## $deciduous_broadleaf_forest
## [1] 4
## 
## $mixed_forests
## [1] 5
## 
## $closed_shrubland
## [1] 6
## 
## $open_shrublands
## [1] 7
## 
## $woody_savannas
## [1] 8
## 
## $savannas
## [1] 9
## 
## $grasslands
## [1] 10
## 
## $permanent_wetlands
## [1] 11
## 
## $croplands
## [1] 12
## 
## $urban_and_built_up
## [1] 13
## 
## $cropland_natural_vegetation_mosaic
## [1] 14
## 
## $snow_and_ice
## [1] 15
## 
## $barren_or_sparsely_vegetated
## [1] 16
## 
## $unclassified
## [1] -2

Above, notice the class number assignments. Below, mask the data to only include forest LCTs.

In the study, the researchers used the MOD12Q1 Collection 5 Land Cover product to identify forest pixels in their study area. This tutorial uses the newer MCD12Q1 Version 5.1 Land Cover Type product to only include pixels in our study region that are classified as one of five forest types:

  • evergreen_needleleaf_forest: 1
  • evergreen_broadleaf_forest: 2
  • deciduous_needleleaf_forest: 3
  • deciduous_broadleaf_forest: 4
  • mixed_forests: 5
# Set lat and lon arrays for LCT data
lat_LCT <- ncvar_get(lct_file, "lat")
lon_LCT <- ncvar_get(lct_file, "lon")

# Open the Land_Cover_Type_1 dataset
lct <- raster(t(ncvar_get(lct_file, "Land_Cover_Type_1")), xmn=min(lon_LCT), xmx=max(lon_LCT), ymn=min(lat_LCT), ymx=max(lat_LCT), crs=crs)

# Make a list of the forest land cover types outlined above
lct_forest <- c(1,2,3,4,5)

# Mask the LCT dataset to only include forest LCT
lct[!lct %in% lct_forest,]<- NA 

# Close NetCDF-4 file
nc_close(lct_file)
rm(lat_LCT, lon_LCT)

Before using the newly created forest LCT mask to filter out non-forest pixels from the EVI data, the 500 m LCT data will need to be resampled to the same resolution as the EVI data (1000 m). Below, the resample() command is used to resample the data from 500 m to 1000 m using nearest neighbor resampling.

# Resample by a factor of 2 with nearest neighbor interpolation:
resampled_lct <- resample(lct, v6_EVI, method='ngb')
rm(lct)

# Next, apply LCT mask to the EVI data
v6_EVI[!resampled_lct %in% lct_forest,]<- NA

Now, visualize the: (1) original data, (2) quality screened data, and (3) quality screened forest-only data by creating 3 subplots, and plotting them side by side.

par(mfrow=c(1,3),oma = c(0, 0, 5, 0), pty = 's')
image(v6_EVI_original,zlim=c(-0.2,1.0),  col = YlGn,  xlab = 'Longitude', ylab = 'Latitude', main = 'Original Data')
image(v6_EVI_qamasked,zlim=c(-0.2,1.0),  col = YlGn,xlab = '', ylab = '', xaxt='n', yaxt='n', main ='Quality Filtered Data')
image(v6_EVI,zlim=c(-0.2,1.0),  col = YlGn,xlab = '', ylab = '',xaxt='n', yaxt='n', main ='Quality Filtered Forest Data')
mtext("MODIS Version 6 Enhanced Vegetation Index (EVI) Quality Filtered Data\nAmazon Rainforest: 07-12-2005", outer = TRUE, cex = 1.5)

9. Visualize Data with GIS Layers


Next, import a package called rworldmap, which allows you to add other useful layers such as country boundaries and coastlines.

In the first example, define a colormap for the LCT data and plot with coastlines and country borders.

cmap1 <- c(rgb(0.149,0.451,0), rgb(0.220,0.659,0),rgb(0.298,0.902,0), rgb(0.639,1,0.451), rgb(0.266,0.537,0.439))

Below, import rworldmap, set up the lat/lon grid, generate the basemap, draw the desired borders, and ultimately plot the lct (forest only) data, assigning it to the colormap generated above.

# Add `dev.off()` if running directly in console to clear parameters from previous plot

invisible(library(rworldmap))
## ### Welcome to rworldmap ###

## For a short introduction type :   vignette('rworldmap')
# Import country borders
data(countriesLow)

# Plot the data
image(resampled_lct,  xlab = 'Longitude', ylab = 'Latitude',xlim = c(-83,-34), ylim = c(-20,13), useRaster = TRUE, col = cmap1, main = "Forest Land Cover Types of the Amazon Basin (2005)")

# Set the background color to light blue
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")

# Plot the country borders filled in as white
plot(countriesLow ,col = 'white', add = TRUE)

# Plot the data again on top of the other layers
image(resampled_lct, add = T, useRaster = TRUE, col = cmap1)

# Plot the borders on top of the LCT data
plot(countriesLow, add = T)

10. Generate Statistics on Data


Below, look at the mean EVI values for the Amazon region from July 12, 2005. Notice that differences arise based on (1) quality filtering (or lack thereof) and (2) land cover type used in calculating the mean EVI.

# Call cellStats, set stat to mean, remove, NA values, and print results
print(paste0('Version 6 all quality mean EVI: ', cellStats(v6_EVI_original, stat='mean', na.rm=TRUE)))
## [1] "Version 6 all quality mean EVI: 0.415054825025268"
print(paste0('Version 6 quality filtered mean EVI: ', cellStats(v6_EVI_qamasked, stat='mean', na.rm=TRUE)))
## [1] "Version 6 quality filtered mean EVI: 0.41557945279398"
print(paste0('Version 6 quality filtered mean (forests) EVI: ', cellStats(v6_EVI, stat='mean', na.rm=TRUE)))
## [1] "Version 6 quality filtered mean (forests) EVI: 0.497680360773332"
rm(v6_EVI, v6_EVI_original,v6_EVI_qamasked)

11. Automate QA/QC Filtering


Here loop through and mask arrays by quality for multiple time steps in a NetCDF-4 file.

# Grab the EVI and VI Quality datasets and set to a variable
v6_EVI <- ncvar_get(file_in, "_1_km_16_days_EVI")
v6_QA <- ncvar_get(file_in, "_1_km_16_days_VI_Quality")

# See how many time steps the file contains
dim(v6_EVI)
## [1] 4200 3600    7

So, the NetCDF-4 file contains 6 timesteps, or layers. Below, use a 'for' loop and indexing (i) in order to loop through each layer and filter based on quality and land cover type.

# Define a function to apply scale factor
apply_sf <- function(x){as.integer(x*10000)}

# Loop through all timesteps (observations) in the file, mask out poor quality and exclude non-forest pixels
for (i in 1:file_in$dim$time$len){
  v6_EVI_1 <- raster(t(v6_EVI[,,i]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
  v6_QA_1 <- raster(t(v6_QA[,,i]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)

  # Apply QA mask to the EVI data
  v6_EVI_1[!v6_QA_1 %in% v6_QA_mask,]<- NA
  rm(v6_QA_1)

  # Next, apply LCT mask to the EVI data
  v6_EVI_1[!resampled_lct %in% lct_forest,]<- NA
  v6_EVI_1<- calc(v6_EVI_1, apply_sf)
  v6_EVI[,,i] <- t(v6_EVI_1[,,1])
  rm(v6_EVI_1)
}
rm(resampled_lct, v6_QA)

12. Visualize Time Series Data


Below, set up subplots to visualize all 6 timesteps (observations) on the same plot.

par(mfrow=c(2,3),oma = c(0, 0, 3, 0))
#title(, line = 0.21)
image(raster(t(v6_EVI[,,1]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn,  xlab = 'Longitude', ylab = 'Latitude', main = '07-12-2005')
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")
plot(countriesLow,col = 'white', add = TRUE)
image(raster(t(v6_EVI[,,1]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn, add = T)
plot(countriesLow, add = T)
image(raster(t(v6_EVI[,,2]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn,xlab = '', ylab = '', xaxt='n', yaxt='n', main ='07-28-2005')
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")
plot(countriesLow,col = 'white', add = TRUE)
image(raster(t(v6_EVI[,,2]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn, add = T)
plot(countriesLow, add = T)
image(raster(t(v6_EVI[,,3]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn,xlab = '', ylab = '',xaxt='n', yaxt='n', main ='08-13-2005')
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")
plot(countriesLow,col = 'white', add = TRUE)
image(raster(t(v6_EVI[,,3]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn, add = T)
plot(countriesLow, add = T)
image(raster(t(v6_EVI[,,4]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn,  xlab = '', ylab = '', xaxt='n', yaxt='n', main = '08-29-2005')
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")
plot(countriesLow,col = 'white', add = TRUE)
image(raster(t(v6_EVI[,,4]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn, add = T)
plot(countriesLow, add = T)
image(raster(t(v6_EVI[,,5]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn,xlab = '', ylab = '', xaxt='n', yaxt='n', main ='09-14-2005')
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")
plot(countriesLow,col = 'white', add = TRUE)
image(raster(t(v6_EVI[,,5]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn, add = T)
plot(countriesLow, add = T)
image(raster(t(v6_EVI[,,6]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn,xlab = '', ylab = '',xaxt='n', yaxt='n', main ='09-30-2005')
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = "lightblue")
plot(countriesLow,col = 'white', add = TRUE)
image(raster(t(v6_EVI[,,6]), xmn=min(lon_EVI), xmx=max(lon_EVI), ymn=min(lat_EVI), ymx=max(lat_EVI), crs=crs)
      ,zlim=c(-200,10000),  col = YlGn, add = T)
plot(countriesLow, add = T)
mtext('MODIS Version 6 Enhanced Vegetation Index (EVI): 07-12-2005 to 09-30-2005', outer = TRUE, cex = 1.5)

13. Export NetCDF-4 Files


Lastly, demonstrate how to copy the original NetCDF-4 file, insert the quality and LCT-masked data, and save to a new NetCDF-4 file.

# Set up output file name
v6_outfile_name <- paste0(out_dir,strsplit(file_list[2], '.nc')[[1]] ,'_masked.nc')

# Copy the original file, insert quality filtered data, and close file
system(paste('cp',file_list[2],v6_outfile_name)) 
v6_file_out_new <- nc_open(v6_outfile_name, write = TRUE)
ncvar_put(v6_file_out_new, "_1_km_16_days_EVI", v6_EVI)
nc_close(v6_file_out_new)

Contact Information


Material written by Cole Krehbiel1
Contact: LPDAAC@usgs.gov
Voice: +1-605-594-6116
Organization: Land Processes Distributed Active Archive Center (LP DAAC)
Website: https://lpdaac.usgs.gov/
Date last modified: 12-06-2017

1 Innovate! Inc., contractor to the U.S. Geological Survey, Earth Resources Observation and Science (EROS) Center, Sioux Falls, South Dakota, USA. Work performed under USGS contract G15PD00467 for LP DAAC2.

2 LP DAAC Work performed under NASA contract NNG14HH33I.

Relevant Products

Product Long Name
MOD13A2.006 MODIS/Terra Vegetation Indices 16-Day L3 Global 1 km SIN Grid

Tools

Name Filters Description
AppEEARS Decode Quality, Order, Search, Subset

The Application for Extracting and Exploring Analysis Ready Samples (AρρE…