πŸ˜ƒ"Good" HDF

Standard MODIS data usually could be easily read and processed with GIS apps

Data source

MOD10A / MYD10A - daily snow cover, identified using Normalized Difference Snow Index (NDSI). Files could be downloaded directly from NSIDC, or from NASA Earthdata.

For this section h15v14 tile (covering South Georgia) was used.

Files were downloaded from Earthdata with wget. For this reason, the folders structure is the following: MOD10A1/n5eil01u.ecs.nsidc.org/DP4/<sensor code>/<product code>/<YYYY.MM.DD>/<filename>

QGIS

Add data to the map view

This window appears after adding an hdf file to the map: sub-dataset selection is needed. NDSI snow cover data is stored in 'NDSI_Snow_Cover MOD_Grid_Snow_500m (8-bit unsigned integer)' sub-dataset.

QGIS dialog window for sub-dataset selection

Check the georeference

Data is georeferenced correctly, though QGIS doesn't know the MODIS data CRS, as it is not in the EPSG catalog.

MYD10A hdf file added to a map in EPSG:3031

Export

Anyway, it is possible to work with this file, for example to reproject it and export to GeoTIFF format.

Exporting MODIS HDF to GeoTIFF and clipping to vector data extent

GDAL

What if you need to process this way not only 1 file but at least 100? GDAL command line tool could be a better solution for this. GDAL installation instructions are on the first page.

gdalinfo: view metadata

Navigate to your working folder, e.g. cd /mnt/c/my_dir/. Run gdalinfo command on one of the HDF files:

The output contains all the metadata, but for further work, you need only a correct sub-dataset name. You will find it at the end of the output (SUBDATASET_1_NAME):

gdalwarp: clip, reproject and save to GeoTiff

gdalwarp command is used to reproject data with the option to clip the image to a certain extent. The full expression is the following

  • The first parameter is an input file, the sub-dataset specified as it appears in gdalinfo output: HDF4_EOS:EOS_GRID:"MOD10A1/n5eil01u.ecs.nsidc.org/DP4/MOSA/MYD10A1.061/2023.01.07/MYD10A1.A2023007.h15v14.061.2023009201030.hdf":MOD_Grid_Snow_500m:NDSI_Snow_Cover

  • The second parameter is the output file, which will be created in the working directory: modis_clip_gdal.tif

  • -t_srs tag sets output spatial reference (epsg code in this case)

  • -cutline and -crop_to_cutline tags let cropping the image to the vector file extent

  • -tr tag defines target raster resolution (x and y) in CRS specified by -t_srs

To be sure, that this file is processed correctly, add it to the map view:

Processed file in the map view

Batch gdalwarp

To apply the same command to all the downloaded files, we need to amend the previous expression:

This command creates GeoTIFF files with the same names and the same directories as HDF files. To move them to another folder:

Metadata

You probably have already noticed, that the NDSI snow cover layer has 8-bit values from 0 to 250, but it is not clear what these values stand for. The answer could be found with QGIS or GDAL.

Open HDF layer properties in QGIS and in "More information" section find 'Key= 0-100=NDSI snow, 200=missing data, 201=no decision, 211=night, 237=inland water, 239=ocean, 250=cloud, 254=detector saturated, 255=fill'.

The same output you can get if run gdalinfo on a specified sub-dataset:

Last updated