Pages

Friday, August 10, 2018

Research Note #14 - Opening MODIS Land Cover Data MCD12C1 with GrADS

MODIS is probably one of the best instruments ever created in the history of remote sensing. MODIS data products have been widely used in various multi-discipline studies, including atmospheric and environmental sciences. One of the data which is frequently utilized in such studies is MODIS land cover products. This time I would like to share how to open MODIS land cover product using GrADS. Nevertheless, of course we can open it with other software such as HDFView, ArcGIS or even Matlab. Anyway, since I have been studying atmospheric science for almost two decades and getting used to work with GrADS, I prefer to use the tool for such purpose.

Firstly, keep in mind that the data I used is MODIS Terra/Aqua combined land cover product yearly global or in short, MCD12C1, with 0.05 spatial resolution. You can read the detail description of the data product on this page. The point is, this data use HDF-EOS format and geographic lon-lat coordinate system which are fully supported by GrADS. MCD12C1 is quite special, because it uses geographic coordinate system instead of sinusoidal coordinate as many others MODIS products. By the way, I will make another post about opening products with such coordinate system in the near future.

Step 1: Checking the metadata
As any other self-describing data files (SDF), the first most important thing to do is checking the metadata or header, in order to get the information about its dimensions such as grid numbers, resolution and variables/parameters stored inside the data. We can easily do this by checking the product page, dumping the HDF file or using tools such as HDFView. For MCD12C1, these are the most important information we need:
  • Grid numbers (x,y,z): 7200x3600x1 --> z=1 because it's a surface data 
  • Starting longitude or left-most coordinate point: -180
  • Starting latitude or bottom-most coordinate point: -90 
  • Spatial resolution: 0.05 degree
  • Variables: Majority_Land_Cover_Type_1 etc (read the product page/dump for more details).
  • Undefined values: none or fill value (255)
MODIS data dimensions and variables/fields checked with HDFView

Step 2: Making GrADS descriptor/control (ctl) file
I previously made a post about how to open NetCDF file using GrADS ctl file and it actually could also be applied for HDF file. If this is the first time for you to open an SDF file using GrADS ctl , I suggest you to read that post first, and then return to this post. If you are good, now, create a text file using your favorite text editor and write the following entries in it:

DSET ^MCD12C1.A2016001.006.2018031200421.hdf
title MODIS Land Cover
DTYPE hdfsds
OPTIONS yrev
UNDEF 255
XDEF 7200 linear -180 0.05
YDEF 3600 linear  -90 0.05
ZDEF 1 linear 1 1
TDEF 1 linear 04jul2001 1dy
VARS 2
Majority_Land_Cover_Type_1=>Landcov1 0 y,x Landcover Type 1
Majority_Land_Cover_Type_2=>Landcov2 0 y,x Landcover Type 2
ENDVARS

For example above, I would like to open 2 variables only. You can list as many variables as you like in the ctl file. Please note that for the TDEF, you can state any dates you want because it's a single yearly data. Of course, it will be a different story if you want to open multiple data. Also, don't forget to put 'yrev' option because MODIS uses reversed geographic coordinates, otherwise the grid points will be reversed (south to north, and vice versa).

For the undefined value, use 255, because it's just a single fill value other than the main data. Of course you can also omit this if you want to show it on GrADS.

Name the ctl file, for example: mcd12c1.ctl

Step 3: Open the data with GrADS
Next, you can just open the data with GrADS as you normally do with an ordinary binary file.

> open mcd12c1.ctl
> set display color white
> set gxout shaded
> d Landcov1
> cbarn


Easy isn't it? Hope that helps you to work with MODIS land cover data :-)

No comments:

Post a Comment