Iris
Iris

Reputation: 1

Convert MODIS LST in HDF to Geotiff using Matlab

I have downloaded land surface temperature grids from MODIS, which are in .hdf format. I would like to convert the folder containing these .hdfs into geotiffs for easier processing.

I have attempted using the hdfread('/User/....hdf') command, but if I only give my hdf file as an input, it has not enough input parameters. The help function specifies that here I should input my datasetname.

hdfinfo = 
  Filename: '/Users/Desktop//MODIS_MAT_2000_2014/2005/MOD11C3.A2005001.004.2005035221349.hdf'
  Attributes: [1x4 struct]
  Vgroup: [1x1 struct]

hdfinfo.Vgroup.Name
ans = MODIS_MONTHLY_0.05DEG_CMG_LST

But if I input this as my datasetname, I get an error. Does anybody have any experience with loading hdf files this way?

Code:

fileinfo = hdfread('/Users/Desktop/Windows_data/MODIS_MAT_2000_2014/2005/MOD11C3.A2005001.004.2005035221349.hdf');

Error message: 'Not enough input arguments' since I miss this datasetname, but I don't know how to find what the different datasets are named. There is also no SDS that I can access, only Attributes and Vgroup.

Upvotes: 0

Views: 951

Answers (2)

Iris
Iris

Reputation: 1

In the end I found the solution myself, by adjusting my code as follows:

hdfread(fullfile('/Users/Desktop/Windows_data/MODIS_MAT_2000_2014/2006','LST_Day_CMG');

I just could not find the right header (which was 'LST_Day_CMG' in this case), which I in the end found on the MODIS website.

Upvotes: 0

Cecilia
Cecilia

Reputation: 4741

The documentation for hdfread gives a few examples for how to use the function.

One way is to use the dataset name as you tried to do, but another is to use the hdfinfo directly.

You can try

fileinfo = hdfinfo(''/User/....hdf') %Get the info
sds_info = fileinfo.SDS(2) %Choose a dataset
data = hdfread(sds_info); %Read the dataset

Upvotes: 0

Related Questions