Main Content

geohypercube

Read hyperspectral image with geospatial information

Since R2025a

    Description

    hcube = geohypercube(file) reads hyperspectral image data with geospatial information from the specified file file and stores the geospatial information in the Metadata property of the hypercube object.

    example

    hcube = geohypercube(file,wavelength) specifies the wavelength for each spectral band in the input data, and sets the Wavelength property of the output hypercube object.

    hcube = geohypercube(image,wavelength) creates a hypercube object from the hyperspectral data cube image and the specified center wavelength values wavelength.

    hcube = geohypercube(image,wavelength,metadata) creates a hypercube object from the hyperspectral data cube image, specified center wavelength values wavelength, and metadata metadata. You can use this syntax to modify the Metadata property of a hypercube object.

    hcube = geohypercube(image) creates a hypercube object from the hyperspectral data cube image without wavelengths. The Wavelength property of the returned hypercube object hcube is empty.

    hcube = geohypercube(___,BlockSize=blockSize) specifies the block size to use when loading the hyperspectral data cube, in addition to any combination of input arguments from previous syntaxes.

    Note

    This function requires a Mapping Toolbox™ license.

    Note

    This function requires the Hyperspectral Imaging Library for Image Processing Toolbox™. You can install the Hyperspectral Imaging Library for Image Processing Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    The Hyperspectral Imaging Library for Image Processing Toolbox requires desktop MATLAB®, as MATLAB Online™ and MATLAB Mobile™ do not support the library.

    Examples

    collapse all

    Read hyperspectral data with geospatial data into the workspace.

    hcube = geohypercube("LC08_L1TP_097070_20201101_20201101_01_cropped.dat");

    Extract the geospatial information in the metadata of the hypercube object. For more information about geospatial information, see the Reference Objects section of Georeferenced Raster Data (Mapping Toolbox).

    R = hcube.Metadata.RasterReference
    R = 
      MapCellsReference with properties:
    
                XWorldLimits: [796770 827880]
                YWorldLimits: [-1603770 -1573470]
                  RasterSize: [1010 1037]
        RasterInterpretation: 'cells'
            ColumnsStartFrom: 'north'
               RowsStartFrom: 'west'
          CellExtentInWorldX: 30
          CellExtentInWorldY: 30
        RasterExtentInWorldX: 31110
        RasterExtentInWorldY: 30300
            XIntrinsicLimits: [0.5 1037.5]
            YIntrinsicLimits: [0.5 1010.5]
          TransformationType: 'rectilinear'
        CoordinateSystemType: 'planar'
                ProjectedCRS: [1×1 projcrs]
    
    
    

    Estimate and visualize the RGB image of the hyperspectral data.

    rgbImg = colorize(hcube,Method="rgb");
    figure
    imshow(rgbImg)

    Figure contains an axes object. The hidden axes object contains an object of type image.

    Create a polygonal region of interest in geographic coordinates.

    xlimits = R.XWorldLimits;
    ylimits = R.YWorldLimits;
    dataRegion = mappolyshape(xlimits([1 1 2 2 1]),ylimits([1 2 2 1 1]));
    dataRegion.ProjectedCRS = R.ProjectedCRS;

    Plot the polygonal region of interest using satellite imagery.

    figure
    geoplot(dataRegion, ...
      LineWidth=2, ...
      EdgeColor="yellow", ...
      FaceColor="red", ...
      FaceAlpha=0.2)
    hold on
    geobasemap satellite

    Figure contains an axes object with type geoaxes. The geoaxes object contains an object of type polygon.

    Input Arguments

    collapse all

    Input filename, specified as a character vector or string scalar. The input filename can refer to an image file or header file, and must be one of these file formats.

    File FormatExtensionsAdditional Requirements

    ENVI image files

    ENVI header files

    Image files:

    • .dat

    • .img

    • .raw

    • .bsq

    • .bil

    • .bip

    Header files:

    • .hdr

    The corresponding image and header files must be in the same folder and have the same filename.
    NITF files

    .ntf

    .nsf

    None.

    Hyperion level 1R image files

    Hyperion header files

    Image files:

    • .L1R

    Header files:

    • .hdr

    The corresponding image and header files must be in the same folder and have the same filename.
    GeoTIFF metadata files from EO satellites.txtFilename must end with the suffix "MTL". For example, geotiffEO1_MTL.txt.

    Multipage TIFF files

    .tif

    File must be a multipage TIFF file containing a volume or time series image stack.

    Data Types: char | string

    Hyperspectral image data cube, specified as an M-by-N-by-C numeric array. M and N are the number of rows and columns in the hyperspectral data, respectively. C is the number of spectral bands in the hyperspectral data.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Hyperspectral image data cube, specified as a 3-D numeric array of size M-by-N-by-C. M and N are the number of rows and columns in the hyperspectral data, respectively. C is the number of spectral bands in the hyperspectral data.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Metadata of the hyperspectral data, specified as a structure array. This argument sets the Metadata property of the hypercube object. To include geospatial information in the hypercube object, the metadata structure must contain the geospatial information in the field RasterReference.

    Data Types: struct

    Size of the data blocks, specified as a 2-element vector of positive integers. The first and second elements of the vector correspond to the number of rows and columns in each block, respectively. This argument sets the BlockSize property of the hypercube object.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Output Arguments

    collapse all

    Hyperspectral data with geospatial information, returned as a hypercube object.

    Version History

    Introduced in R2025a