Prog_Name = 'ReadSwath.m'; FILE_NAME = 'AMSR_E_L2A_BrightnessTemperatures_V09_200206190029_D.hdf'; SWATH_NAME = 'Low_Res_Swath'; DATAFIELD_NAME = '23.8H_Approx._Res.3_TB_(not-resampled)'; %Opening the HDF-EOS2 Swath File file_id = hdfsw('open', FILE_NAME, 'rdonly') if (file_id == -1) disp([Prog_Name ': ERROR - ' FILE_NAME ' could not be opened.']) return; end %Open a swath named 'Low_Res_Swath' swath_id = hdfsw('attach', file_id, SWATH_NAME) if (swath_id == -1) disp([Prog_Name ': ERROR - Unable to open swath' SWATH_NAME]) status = hdfsw('close', file_id); return; end %Reading Data from a Data Field [data, status] = hdfsw('readfield', swath_id, DATAFIELD_NAME,[],[],[]); [lat, status] = hdfsw('readfield', swath_id, 'Latitude', [], [], []); [lon, status] = hdfsw('readfield', swath_id, 'Longitude', [], [], []); if (status == -1) disp([Prog_Name ': ERROR - Unable to read data from' DATAFIELD_NAME]) status = hdfsw('detach', swath_id); status = hdfsw('close', file_id); return; end %Visualizing the data field on a world map contourf(lon, lat, data) geoshow('landareas.shp', 'FaceColor', 'white', 'FaceAlpha', 0) colorbar %Dumping a subset of the values in the data field startvector = [0 0] stride = [] endvector = [5 5] [data_subset, subset_fail] = hdfsw('readfield', swath_id, DATAFIELD_NAME, startvector, stride, endvector) if (subset_fail == -1) disp([Prog_Name ': ERROR - Unable to read and dump a subset of data from' DATAFIELD_NAME]) status = hdfgd('detach', grid_id); status = hdfgd('close', file_id); return; end %Alternative method to dump the subset of the values in the data field for i = 1:5 for j = 1:7 data(i, j); end end %Detaching from the Swath Object hdfsw('detach', swath_id); %Closing the File hdfsw('close', file_id);