Mineral Classification API

class pycoal.mineral.MineralClassification(libraryFilename, classNames=None, threshold=0.0, inMemory=False)[source]
__init__(libraryFilename, classNames=None, threshold=0.0, inMemory=False)[source]

Construct a new MineralClassification object with a spectral library in ENVI format such as the USGS Digital Spectral Library 06 or the ASTER Spectral Library Version 2.0 converted with pycoal.mineral.AsterConversion.convert().

If provided, the optional class name parameter will initialize the classifier with a subset of the spectral library, otherwise the full spectral library will be used.

The optional threshold parameter defines a confidence value between zero and one below which classifications will be discarded, otherwise all classifications will be included.

In order to improve performance on systems with sufficient memory, enable the optional parameter to load entire images.

Parameters:
  • libraryFilename (str) – filename of the spectral library
  • classNames (str[], optional) – list of names of classes to include
  • threshold (float, optional) – classification threshold
  • inMemory (boolean, optional) – enable loading entire image
classifyImage(imageFilename, classifiedFilename)[source]

Classify minerals in an AVIRIS image using spectral angle mapper classification and save the results to a file.

Parameters:
  • imageFilename (str) – filename of the image to be classified
  • classifiedFilename (str) – filename of the classified image
Returns:

None

static filterClasses(classifiedFilename)[source]

Modify a classified image to remove unused classes.

Parameters:classifiedFilename (str) – file of the classified image
Returns:None
static subsetSpectralLibrary(spectralLibrary, classNames)[source]

Create a copy of the spectral library containing only the named classes.

Parameters:
  • spectralLibrary (SpectralLibrary) – ENVI spectral library
  • classNames (str[]) – list of names of classes to include
Returns:

subset of ENVI spectral library

Return type:

SpectralLibrary

static toRGB(imageFilename, rgbImageFilename, red=680.0, green=532.5, blue=472.5)[source]

Generate a three-band RGB image from an AVIRIS image and save it to a file.

Parameters:
  • imageFilename (str) – filename of the source image
  • rgbImageFilename (str) – filename of the three-band RGB image
  • red (float, optional) – wavelength in nanometers of the red band
  • green (float, optional) – wavelength in nanometers of the green band
  • blue (float, optional) – wavelength in nanometers of the blue band
Returns:

None

class pycoal.mineral.AsterConversion[source]
__init__()[source]

This class provides a method for converting the ASTER Spectral Library Version 2.0 into ENVI format.

Parameters:None
classmethod convert(data_dir='', db_file='', hdr_file='')[source]

This class method generates an ENVI format spectral library file. data_dir is optional as long as db_file is provided. Note that generating an SQLite database takes upwards of 10 minutes and creating an ENVI format file takes up to 5 minutes. Note: This feature is still experimental.

Parameters:
  • data_dir (str, optional) – path to directory containing ASCII data files
  • db_file (str) – name of the SQLite file that either already exists if data_dir isn’t provided, or will be generated if data_dir is provided
  • hdr_file (str) – name of the ENVI spectral library to generate (without the .hdr or .sli extension)