Class TLcdGDALModelDecoder

All Implemented Interfaces:
ILcdMetadataDecoder, ILcdModelDecoder, ILcdStatusSource

@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdGDALModelDecoder extends Object implements ILcdModelDecoder, ILcdMetadataDecoder, ILcdStatusSource
This decoder can decode raster data using GDAL. It supports verified raster formats for which Luciad doesn't have a proper decoder:
  • ACE2 (*.ace2)
  • Arc/Info Binary Grid (*.adf)
  • Azavea Raster Grid (*.arg, *.json)
  • Magellan BLX Topo (*.blx, *.xlb)
  • BSB Nautical Chart (*.kap)
  • VTP Binary Terrain Format (*.bt)
  • First Generation USGS DOQ (*.doq)
  • ERDAS Imagine (*.img)
  • ENVI .hdr Labelled Raster (*.dat)
  • EOSAT FAST Format (*.fst)
  • Golden Software ASCII Grid (*.grd)
  • Golden Software Binary Grid (*.grd)
  • Golden Software Surfer 7 Binary Grid (*.grd)
  • New Labelled USGS DOQ (*.doq, *.nws)
  • GXF - Grid eXchange File (*.gxf)
  • NOAA .gtx vertical datum shift (*.gtx)
  • HF2/HFZ heightfield raster (*.hf2)
  • SGI Image Format (*.bw, *.rgb, *.rgba, *.sgi)
  • Snow Data Assimilation System (*.hdr)
  • SRTM HGT Format (*.hgt)
  • GDAL Virtual (*.vrt)
  • GeospatialPDF (*.pdf)
Optionally, this decoder can also decode unverified raster formats that are listed as raster formats supported by the GDAL library, using setAllowUnverifiedFormats(boolean). Since this behaviour is unverified the decoder might not succeed in decoding the source.

A raster data file is typically a satellite image which can represent either a measurement (e.g. elevation) or true color (e.g. RGB). It can also be a multi or hyper spectral image as well.

Input Files

FileRequiredEntry pointDescription
*.imgXXThe ERDAS Imagine file
The model reference is obtained from an ILcdModelReferenceDecoder. The default reference decoder set on this model decoder is based on all model reference decoders annotated with the LcdService annotation, and can handle If this fails, the decoder's default model reference is returned. Unless set by the user, the default model reference is null.

Supported file transfer protocols

  • This model decoder decodes data from a file system.

Model structure

  • This model decoder creates a model with a single domain object for an input file.
  • The resulting model is an ILcd2DBoundsIndexedModel.

Model descriptor

  • The returned model has a model descriptor with "GDAL/<type>" as type name. The type is obtained from the GDAL library driver, and depends on the format. For example for ERDAS Imagine data the type is "HFA".
  • The model descriptor of the model is a ILcdImageModelDescriptor.
  • The decoded source name is the display name of the model descriptor.

Model reference

Model elements

Thread safety

  • The decoding of models is thread-safe, as long as no properties are changed during the decoding.
  • The decoded models are thread-safe for read access.

Sample code

   // decode the model
   TLcdGDALModelDecoder decoder = new TLcdGDALModelDecoder();
   ILcdModel model = decoder.decode(aSource);

   // retrieve the measurements
   Object domainObject = model.elements().nextElement();
   ALcdImage image = ALcdImage.fromDomainObject(domainObject);
For more information on how to integrate GDAL decoded raster data into your application, refer to the GDAL developer's guide.
See Also:
  • Field Details


      public static final String TYPE_NAME
      The first part of the type name of the model descriptor; its value is "GDAL". The actual type name is GDAL/<type>, where the type is obtained from the GDAL library driver and depends on the format.
      See Also:
  • Constructor Details

    • TLcdGDALModelDecoder

      public TLcdGDALModelDecoder()
  • Method Details

    • setAllowUnverifiedFormats

      public void setAllowUnverifiedFormats(boolean aAllow)
      Allow decoding of formats that have not been verified by Luciad, including formats for which a proper model decoder exists. The default is off, unless the default itself has been overridden using the system property "com.luciad.format.gdal.allowUnverifiedFormats".
      aAllow - whether or not to allow decoding of unverified formats
    • getDisplayName

      public String getDisplayName()
      Returns "GDAL".
      Specified by:
      getDisplayName in interface ILcdModelDecoder
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return true for a source name while decode throws an exception for that same source name.

      For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      aSourceName - the data source to be verified; typically a file name or a URL.
      true if this decoder can likely decode the data specified by the source name, false otherwise.
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      aSourceName - the data source to be decoded; typically a file name or a URL.
      A model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
         public ILcdModel decode( String aSourceName ) throws IOException {
            try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
               // Perform decoding ...
            } catch (RuntimeException e) {
               throw new IOException(e);
      See Also:
    • canDecodeMetadata

      public boolean canDecodeMetadata(String aSourceName)
      Description copied from interface: ILcdMetadataDecoder
      Tells whether this metadata decoder can likely decode metadata for a given source name.
      Specified by:
      canDecodeMetadata in interface ILcdMetadataDecoder
      aSourceName - the source name to decode metadata for
      true if this metadata decoder can decode metadata for the given source name, false otherwise
    • decodeMetadata

      public TLcdISO19115Metadata decodeMetadata(String aSourceName) throws IOException
      Decodes the metadata from a gdal source and returns a TLcdISO19115Metadata instance.
      Specified by:
      decodeMetadata in interface ILcdMetadataDecoder
      aSourceName - a gdal source
      a TLcdISO19115Metadata instance which contains paths of all files which are needed to decode the gdal source, null if the metadata can not be decoded.
      IOException - if the source can not be found
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource

      Registers the given listener so it will receive status events from this source.

      In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a ALcdWeakStatusListener instance as status listener.

      Specified by:
      addStatusListener in interface ILcdStatusSource
      aListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      aListener - The listener to remove.