matlab.io.hdfeos.sw.defDataField
Namespace: matlab.io.hdfeos.sw
Define new data field within swath
Syntax
defDataField(swathID,fieldname,dimlist,dtype)
defDataField(swathID,fieldname,dimlist,dtype,mergeCode)
Description
defDataField(swathID,fieldname,dimlist,dtype) defines a data field to be
stored in the swath identified by swathID.
The dimlist input can be a cell array character vectors or a string array
containing dimension names, or a single character vector or string scalar if there is only one
dimension. dimlist should be ordered such that the fastest varying dimension
is listed first. This is opposite from the order in which the dimensions are listed in the C API.
dtype is the data type of the field and can be one of the following values.
'double''single''int32''uint32''int16''uint16''int8''uint8''char'
defDataField(swathID,fieldname,dimlist,dtype,mergeCode) defines a data
field that can be merged with other data fields according to the value of
mergeCode. The mergeCode input can be
'automerge' or 'nomerge'. If mergeCode
is 'automerge', then the HDF-EOS library will attempt to merge swath fields
into a single object. This should not be done if you want to access the swath fields individually
with the another interface. By default, mergeCode is
'nomerge'.
Note
To assure that the fields defined by sw.defDataField are
properly established in the file, the swath should be detached and
then reattached before writing to any fields.
This function corresponds to the SWdefdatafield function
in the HDF-EOS library C API, but because MATLAB® uses FORTRAN-style
ordering, the dimlist parameter is reversed with
respect to the C library API.
Examples
import matlab.io.hdfeos.* swfid = sw.open('myfile.hdf','create'); swathID = sw.create(swfid,'MySwath'); sw.defDim(swathID,'GeoTrack',2000); sw.defDim(swathID,'GeoXtrack',1000); sw.defDim(swathID,'DataTrack',4000); sw.defDim(swathID,'DataXtrack',2000); sw.defDim(swathID,'Bands',3); sw.defDimMap(swathID,'GeoTrack','DataTrack',0,2); sw.defDimMap(swathID,'GeoXtrack','DataXtrack',1,2); dims = {'GeoXtrack','GeoTrack'}; sw.defGeoField(swathID,'Longitude',dims,'float'); sw.defGeoField(swathID,'Latitude',dims,'float'); dims = {'DataXtrack','DataTrack','Bands'}; sw.defDataField(swathID,'Spectra',dims,'float'); sw.detach(swathID); sw.close(swfid);