RasterUtilities Namespace Reference

This namespace contains a number of convenience functions for dealing with raster datasets. More...


Typedefs

typedef EnumWrapper
< InterpolationTypeEnum
InterpolationType

Enumerations

enum  InterpolationTypeEnum { NEAREST_NEIGHBOR, BILINEAR, BICUBIC }

Functions

std::vector< DimensionDescriptorgenerateDimensionVector (unsigned int count, bool setOriginalNumbers=true, bool setActiveNumbers=false, bool setOnDiskNumbers=false)
bool determineSkipFactor (const std::vector< DimensionDescriptor > &values, unsigned int &skipFactor)
bool determineExportSkipFactor (const std::vector< DimensionDescriptor > &values, unsigned int &skipFactor)
std::vector< DimensionDescriptorsubsetDimensionVector (const std::vector< DimensionDescriptor > &origValues, const DimensionDescriptor &start, const DimensionDescriptor &stop, unsigned int skipFactor=0)
FileDescriptorgenerateFileDescriptor (DataDescriptor *pDd, const std::string &filename, const std::string &datasetLocation, EndianType endian)
FileDescriptorgenerateAndSetFileDescriptor (DataDescriptor *pDd, const std::string &filename, const std::string &datasetLocation, EndianType endian)
FileDescriptorgenerateFileDescriptorForExport (const DataDescriptor *pDd, const std::string &filename)
FileDescriptorgenerateFileDescriptorForExport (const DataDescriptor *pDd, const std::string &filename, const DimensionDescriptor &startRow, const DimensionDescriptor &stopRow, unsigned int rowSkipFactor, const DimensionDescriptor &startCol, const DimensionDescriptor &stopCol, unsigned int colSkipFactor, const std::vector< DimensionDescriptor > &subsetBands=std::vector< DimensionDescriptor >())
FileDescriptorgenerateFileDescriptorForExport (const DataDescriptor *pDd, const std::string &filename, const DimensionDescriptor &startRow, const DimensionDescriptor &stopRow, unsigned int rowSkipFactor, const DimensionDescriptor &startCol, const DimensionDescriptor &stopCol, unsigned int colSkipFactor, const DimensionDescriptor &startBand, const DimensionDescriptor &stopBand, unsigned int bandSkipFactor)
RasterDataDescriptorgenerateRasterDataDescriptor (const std::string &name, DataElement *pParent, unsigned int rows, unsigned int columns, unsigned int bands, InterleaveFormatType interleave, EncodingType encoding, ProcessingLocation location)
RasterDataDescriptorgenerateRasterDataDescriptor (const std::string &name, DataElement *pParent, unsigned int rows, unsigned int columns, EncodingType encoding, ProcessingLocation location)
RasterDataDescriptorgenerateUnchippedRasterDataDescriptor (const RasterElement *pOrigElement)
void subsetDataDescriptor (DataDescriptor *pDd, const DimensionDescriptor &startRow, const DimensionDescriptor &stopRow, unsigned int rowSkipFactor, const DimensionDescriptor &startCol, const DimensionDescriptor &stopCol, unsigned int colSkipFactor, const std::vector< DimensionDescriptor > &subsetBands=std::vector< DimensionDescriptor >())
void subsetDataDescriptor (DataDescriptor *pDd, const DimensionDescriptor &startRow, const DimensionDescriptor &stopRow, unsigned int rowSkipFactor, const DimensionDescriptor &startCol, const DimensionDescriptor &stopCol, unsigned int colSkipFactor, const DimensionDescriptor &startBand, const DimensionDescriptor &stopBand, unsigned int bandSkipFactor)
RasterElementcreateRasterElement (const std::string &name, unsigned int rows, unsigned int columns, EncodingType encoding, bool inMemory=true, DataElement *pParent=0)
RasterElementcreateRasterElement (const std::string &name, unsigned int rows, unsigned int columns, unsigned int bands, EncodingType encoding, InterleaveFormatType interleave=BIP, bool inMemory=true, DataElement *pParent=0)
size_t bytesInEncoding (EncodingType encoding)
std::vector< std::string > getBandNames (const RasterDataDescriptor *pDescriptor)
std::string getBandName (const RasterDataDescriptor *pDescriptor, DimensionDescriptor band)
bool isSubcube (const RasterDataDescriptor *pDescriptor, bool checkBands)
bool findColorCompositeDimensionDescriptors (const RasterDataDescriptor *pDescriptor, const std::string &name, DimensionDescriptor &redBand, DimensionDescriptor &greenBand, DimensionDescriptor &blueBand)
int findBandWavelengthMatch (double lowTarget, double highTarget, const std::vector< double > &lowWavelengths, const std::vector< double > &highWavelengths=std::vector< double >(), bool allowPartialMatch=true)
std::vector< unsigned int > findBandWavelengthMatches (double lowTarget, double highTarget, const std::vector< double > &lowWavelengths, const std::vector< double > &highWavelengths=std::vector< double >(), bool allowPartialMatch=true)
DimensionDescriptor findBandWavelengthMatch (double lowTarget, double highTarget, const RasterDataDescriptor *pDescriptor, bool allowPartialMatch=true)
int findBestMatch (const std::vector< double > &values, double value, double tolerance, int startAt=0)
std::vector< RasterChannelTypegetVisibleRasterChannels ()
bool chipMetadata (DynamicObject *pMetadata, const std::vector< DimensionDescriptor > &selectedRows, const std::vector< DimensionDescriptor > &selectedColumns, const std::vector< DimensionDescriptor > &selectedBands)
template<typename T>
bool isBad (T value)
template<>
bool isBad< double > (double value)
template<>
bool isBad< float > (float value)
template<typename T>
uint64_t sanitizeData (T *pData, uint64_t count, double value=0.0)
uint64_t sanitizeData (void *pData, uint64_t count, EncodingType type, double value=0.0)
int64_t calculateFileSize (const RasterFileDescriptor *pDescriptor)
bool rotate (RasterElement *pDst, const RasterElement *pSrc, double angle, int defaultValue, InterpolationType interp=NEAREST_NEIGHBOR, Progress *pProgress=NULL, bool *pAbort=NULL)


Detailed Description

This namespace contains a number of convenience functions for dealing with raster datasets.

This includes creation of DataDescriptors, FileDescriptors, and DataElements.


Typedef Documentation

The EnumWrapper contains a given enum value and provides a isValid() method which returns true if the contained enum value is valid.

Please see How To Use EnumWrapper for more information. The wrapped enum values are RasterUtilities::InterpolationTypeEnum.

Definition at line 990 of file RasterUtilities.h.


Enumeration Type Documentation

Types of interpolation.

Enumerator:
NEAREST_NEIGHBOR  Duplicate the nearest neighbor.
BILINEAR  Bilinear interpolation.
BICUBIC  Bicubic interpolation.

Definition at line 980 of file RasterUtilities.h.


Function Documentation

size_t RasterUtilities::bytesInEncoding ( EncodingType  encoding  ) 

Determine the number of bytes in a single element of a given EncodingType.

Parameters:
encoding EncodingType to find the size of.
Returns:
The size in bytes of encoding.

int64_t RasterUtilities::calculateFileSize ( const RasterFileDescriptor pDescriptor  ) 

Calculate size of data file.

This function will calculate the size of the file described in the given RasterFileDescriptor. For a BSQ multiple file data set, it will calculate the required size for an individual file, not the total of all the files.

Parameters:
pDescriptor The RasterFileDescriptor to use in calculation of file size.
Returns:
The calculated file size. For BSQ multiple files, it will return calculated size that each of the files should require. Will return -1 if errors occurred during calculation, e.g. if pDescriptor is NULL.

bool RasterUtilities::chipMetadata ( DynamicObject pMetadata,
const std::vector< DimensionDescriptor > &  selectedRows,
const std::vector< DimensionDescriptor > &  selectedColumns,
const std::vector< DimensionDescriptor > &  selectedBands 
)

Chip the metadata in-place.

The vector metadata with the SPECIAL_METADATA_NAME / BAND_METADATA_NAME, ROW_METADATA_NAME, and COLUMN_METADATA_NAME DynamicObjects will be chipped such that they can still be indexed with active numbers.

This method will automatically be called when using one of the standard ways to chip (RasterElement::createChip, chipping on import using the default behavior in RasterElementImporterShell). Plug-ins should only call it when implementing their own chipping behavior.

Metadata chipping is supported for vectors of the signed and unsigned variants of char, int, long, int64_t, as well as float, double, bool, and std::string.

Parameters:
pMetadata The DynamicObject that contains SPECIAL_METADATA_NAME / BAND_METADATA_NAME, ROW_METADATA_NAME, and COLUMN_METADATA_NAME that will be chipped by this method. This DynamicObject will be modified in-place. This DynamicObject will most likely come from DataDescriptor::getMetadata().
selectedRows The DimensionDescriptors (unmodified from the RasterElement) for the rows which should be included in this chip.
selectedColumns The DimensionDescriptors (unmodified from the RasterElement) for the columns which should be included in this chip.
selectedBands The DimensionDescriptors (unmodified from the RasterElement) for the bands which should be included in this chip.
Returns:
True if the operation succeeded, false otherwise.

RasterElement* RasterUtilities::createRasterElement ( const std::string &  name,
unsigned int  rows,
unsigned int  columns,
unsigned int  bands,
EncodingType  encoding,
InterleaveFormatType  interleave = BIP,
bool  inMemory = true,
DataElement pParent = 0 
)

Creates a RasterElement with the given parameters that can be immediately used.

This method should only be used by plug-ins that need to programmatically create a RasterElement to store results of an algorithm. It should NOT be used by importers or exporters to create a RasterElement. It should also NOT be used to create a RasterElement that corresponds to a data file on the filesystem. The created element will inherit the parent's classification unless the parent is NULL, in which case the classification will be set to the system's highest level of classification. Use the DataElement convenience method copyClassification or setClassification if the parent is NULL or if you require different classification settings.

Parameters:
name The name for the new RasterDataDescriptor.
rows The number of rows for the new RasterDataDescriptor.
columns The number of columns for the new RasterDataDescriptor.
bands The number of bands for the new RasterDataDescriptor.
encoding The encoding for the new RasterDataDescriptor.
interleave The interleave for the new RasterDataDescriptor.
inMemory If true, the data for the RasterElement will be fully contained in RAM. If false, the data for the RasterElement will be fully contained on the filesystem and will be paged into memory as required.
pParent The parent element for the new RasterDataDescriptor.
Returns:
A RasterElement created with the given parameters that requires no additional initialization.
See also:
DataElement::copyClassification, DataElement::setClassification

RasterElement* RasterUtilities::createRasterElement ( const std::string &  name,
unsigned int  rows,
unsigned int  columns,
EncodingType  encoding,
bool  inMemory = true,
DataElement pParent = 0 
)

Creates a RasterElement with the given parameters and that assumes a single band that can be immediately used.

This method should only be used by plug-ins that need to programmatically create a RasterElement to store results of an algorithm. It should NOT be used by importers or exporters to create a RasterElement. It should also NOT be used to create a RasterElement that corresponds to a data file on the filesystem. The created element will inherit the parent's classification unless the parent is NULL, in which case the classification will be set to the system's highest level of classification. Use the DataElement convenience method copyClassification or setClassification if the parent is NULL or if you require different classification settings.

Parameters:
name The name for the new RasterDataDescriptor.
rows The number of rows for the new RasterDataDescriptor.
columns The number of columns for the new RasterDataDescriptor.
encoding The encoding for the new RasterDataDescriptor.
inMemory If true, the data for the RasterElement will be fully contained in RAM. If false, the data for the RasterElement will be fully contained on the filesystem and will be paged into memory as required.
pParent The parent element for the new RasterDataDescriptor.
Returns:
A RasterElement created with the given parameters and that assumes a single band that requires no additional initialization.
See also:
DataElement::copyClassification, DataElement::setClassification
Examples:
Tutorial/Tutorial5.cpp.

bool RasterUtilities::determineExportSkipFactor ( const std::vector< DimensionDescriptor > &  values,
unsigned int &  skipFactor 
)

Determine the export skip factor if any between each DimensionDescriptor.

This function will determine the uniform skip factor between each DimensionDescriptor::getActiveNumber() which represents any skip factor used when exporting the data.

Parameters:
values The DimensionDescriptors to determine the skip factor of.
skipFactor This will be set to the calculated skip factor. A skipFactor of 0, indicates the active numbers are the following: 0, 1, 2, 3, 4, 5, 6. A skip factor of 1, indicates the active numbers are the following: 0, 2, 4, 6.
Returns:
true, if a uniform skip factor could be determined, false otherwise.

bool RasterUtilities::determineSkipFactor ( const std::vector< DimensionDescriptor > &  values,
unsigned int &  skipFactor 
)

Determine the load skip factor if any between each DimensionDescriptor.

This function will determine the uniform skip factor between each DimensionDescriptor::getOnDiskNumber() which represents any skip factor used to load the data.

Parameters:
values The DimensionDescriptors to determine the skip factor of.
skipFactor This will be set to the calculated skip factor. A skipFactor of 0, indicates the on-disk numbers are the following: 0, 1, 2, 3, 4, 5, 6. A skip factor of 1, indicates the on-disk numbers are the following: 0, 2, 4, 6.
Returns:
true, if a uniform skip factor could be determined, false otherwise.

DimensionDescriptor RasterUtilities::findBandWavelengthMatch ( double  lowTarget,
double  highTarget,
const RasterDataDescriptor pDescriptor,
bool  allowPartialMatch = true 
)

Find the band which matches a wavelength region.

This searches the wavelengths stored in the metadata for all bands which fall within the (lowTarget, highTarget) region. The preferred order of the wavelengths to use is:

  • Start and End (if both are available)
  • Center only
  • Start only
  • End only

The allowPartialMatch variable determines if the entire band must fall in the region or if a partial overlap is allowed. Both lowTarget and highTarget must be in microns.

Parameters:
lowTarget The lower bound of the wavelength region.
highTarget The upper bound of the wavelength region.
pDescriptor The RasterDataDescriptor to search for wavelength regions.
allowPartialMatch Set to false to require entire band range to fall within requested wavelength region. Set to true to allow partial inclusion.
Returns:
The band found or an invalid DimensionDescriptor if no bands were found.

int RasterUtilities::findBandWavelengthMatch ( double  lowTarget,
double  highTarget,
const std::vector< double > &  lowWavelengths,
const std::vector< double > &  highWavelengths = std::vector< double >(),
bool  allowPartialMatch = true 
)

Find the band which matches a wavelength region.

This searches the wavelengths vectors for all bands which fall within the (lowTarget, highTarget) region. The allowPartialMatch variable determines if the entire band must fall in the region or if a partial overlap is allowed. Once all the bands have been found, they are sorted by lower wavelength and the index of the median value is returned. The parameters lowTarget, highTarget, lowWavelengths, and highWavelengths must all have the same units. If highWavelengths is empty, lowWavelengths should contain wave centers which will be matched instead of a continuous region.

Parameters:
lowTarget The lower bound of the wavelength region.
highTarget The upper bound of the wavelength region.
lowWavelengths The lower bound of the wavelengths for each band.
highWavelengths The upper bound of the wavelengths for each band. Must be either empty of the same length as lowWavelengths.
allowPartialMatch Set to false to require entire band range to fall within requested wavelength region. Set to true to allow partial inclusion.
Returns:
The band number found or -1 if no bands were found. This corresponds to an index into the lowWavelengths and highWavelengths vectors.

std::vector<unsigned int> RasterUtilities::findBandWavelengthMatches ( double  lowTarget,
double  highTarget,
const std::vector< double > &  lowWavelengths,
const std::vector< double > &  highWavelengths = std::vector< double >(),
bool  allowPartialMatch = true 
)

Find the bands which match a wavelength region.

This searches the wavelengths vectors for all bands which fall within the (lowTarget, highTarget) region. The allowPartialMatch variable determines if the entire band must fall in the region or if a partial overlap is allowed. Once all the bands have been found, they are sorted by lower wavelength. The parameters lowTarget, highTarget, lowWavelengths, and highWavelengths must all have the same units. If highWavelengths is empty, lowWavelengths should contain wave centers which will be matched instead of a continuous region.

Parameters:
lowTarget The lower bound of the wavelength region.
highTarget The upper bound of the wavelength region.
lowWavelengths The lower bound of the wavelengths for each band.
highWavelengths The upper bound of the wavelengths for each band. Must be either empty of the same length as lowWavelengths.
allowPartialMatch Set to false to require entire band range to fall within requested wavelength region. Set to true to allow partial inclusion.
Returns:
The band numbers found or an empty vector if no bands were found. These correspond to indices into the lowWavelengths and highWavelengths vectors.

int RasterUtilities::findBestMatch ( const std::vector< double > &  values,
double  value,
double  tolerance,
int  startAt = 0 
)

Finds the closest match in vector of values to a value within the tolerance specified.

This method will return the index in vector of the closest match. If there is no match within the tolerance, the method will return -1.

Parameters:
values the list of values to search for the closest match.
value the value for which to find the closest match.
tolerance the maximum difference allowed to consider as a valid match.
startAt the index at which to start search. Defaults to first element.
Returns:
the index of best match or -1 if no match found.

bool RasterUtilities::findColorCompositeDimensionDescriptors ( const RasterDataDescriptor pDescriptor,
const std::string &  name,
DimensionDescriptor redBand,
DimensionDescriptor greenBand,
DimensionDescriptor blueBand 
)

Find the appropriate red, green, and blue bands for a color composite.

Parameters:
pDescriptor RasterDataDescriptor containing the band and wavelength information.
name The name of the user-defined color composite to set. This is typically chosen from a menu.
redBand The band to be displayed in the red channel.
greenBand The band to be displayed in the green channel.
blueBand The band to be displayed in the blue channel.
Returns:
True if red, green, and blue bands are successfully set and are valid, false otherwise.
See also:
RasterLayer::getSettingColorComposites(), DimensionDescriptor::isValid()

FileDescriptor* RasterUtilities::generateAndSetFileDescriptor ( DataDescriptor pDd,
const std::string &  filename,
const std::string &  datasetLocation,
EndianType  endian 
)

Returns a FileDescriptor to go with a passed in DataDescriptor and sets the FileDescriptor onto the provided DataDescriptor.

Parameters:
pDd The DataDescriptor to generate a FileDescriptor for. If a RasterDataDescriptor, the DimensionDescriptors will be modified to set on-disk numbers.
filename The filename for the FileDescriptor
datasetLocation The location within the file which contains the dataset.
endian The endianness of the file.
Returns:
A newly created FileDescriptor, of an appropriate subclass to match pDd. It has the appropriate fields copied from the source DataDescriptor. Any special fields (like GCPs, preline bytes, etc) must be set manually. The returned FileDescriptor is set into the DataDescriptor.
Examples:
SampleRasterElementImporter.cpp.

std::vector<DimensionDescriptor> RasterUtilities::generateDimensionVector ( unsigned int  count,
bool  setOriginalNumbers = true,
bool  setActiveNumbers = false,
bool  setOnDiskNumbers = false 
)

Returns a vector of DimensionDescriptors, suitable for use in a RasterDataDescriptor or RasterFileDescriptor.

Parameters:
count The number of DimensionDescriptors to generate.
setOriginalNumbers if true, the original numbers will be set from 0 to count-1 matching their index location within the vector.
setActiveNumbers if true, the active numbers will be set from 0 to count-1 matching their index location within the vector.
setOnDiskNumbers if true, the on-disk numbers will be set from 0 to count-1 matching their index location within the vector.
Returns:
A vector of size count, containing the requested DimensionDescriptors.

FileDescriptor* RasterUtilities::generateFileDescriptor ( DataDescriptor pDd,
const std::string &  filename,
const std::string &  datasetLocation,
EndianType  endian 
)

Returns a FileDescriptor to go with a passed in DataDescriptor.

Parameters:
pDd The DataDescriptor to generate a FileDescriptor for. If a RasterDataDescriptor, the DimensionDescriptors will be modified to set on-disk numbers.
filename The filename for the FileDescriptor
datasetLocation The location within the file which contains the dataset.
endian The endianness of the file.
Returns:
A newly created FileDescriptor, of an appropriate subclass to match pDd. It has the appropriate fields copied from the source DataDescriptor. Any special fields (like GCPs, preline bytes, etc) must be set manually. The returned FileDescriptor is not set into the DataDescriptor.

FileDescriptor* RasterUtilities::generateFileDescriptorForExport ( const DataDescriptor pDd,
const std::string &  filename,
const DimensionDescriptor startRow,
const DimensionDescriptor stopRow,
unsigned int  rowSkipFactor,
const DimensionDescriptor startCol,
const DimensionDescriptor stopCol,
unsigned int  colSkipFactor,
const DimensionDescriptor startBand,
const DimensionDescriptor stopBand,
unsigned int  bandSkipFactor 
)

Returns a FileDescriptor that can be provided to an exporter to export the data that is some subset of the given DataDescriptor.

Parameters:
pDd The DataDescriptor to generate a suitable FileDescriptor necessary for export of.
filename The name of the file that the data should be exported to.
startRow The DimensionDescriptor that specifies the starting row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first row will be used.
stopRow The DimensionDescriptor that specifies the ending row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last row will be used.
rowSkipFactor Specifies the number of rows that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following row positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following row positions: 0, 2, 4, 6.
startCol The DimensionDescriptor that specifies the starting column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first column will be used.
stopCol The DimensionDescriptor that specifies the ending column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last column will be used.
colSkipFactor Specifies the number of columns that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following column positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following column positions: 0, 2, 4, 6.
startBand The DimensionDescriptor that specifies the starting band of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the band subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first band will be used.
stopBand The DimensionDescriptor that specifies the ending band of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the band subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last band will be used.
bandSkipFactor Specifies the number of band that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following band positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following band positions: 0, 2, 4, 6.
Returns:
A newly created FileDescriptor, of an appropriate subclass to match pDd. The returned FileDescriptor only includes the specified subset and is not set into the DataDescriptor and is only suitable for an exporter to use.

FileDescriptor* RasterUtilities::generateFileDescriptorForExport ( const DataDescriptor pDd,
const std::string &  filename,
const DimensionDescriptor startRow,
const DimensionDescriptor stopRow,
unsigned int  rowSkipFactor,
const DimensionDescriptor startCol,
const DimensionDescriptor stopCol,
unsigned int  colSkipFactor,
const std::vector< DimensionDescriptor > &  subsetBands = std::vector< DimensionDescriptor >() 
)

Returns a FileDescriptor that can be provided to an exporter to export the data that is some subset of the given DataDescriptor.

Parameters:
pDd The DataDescriptor to generate a suitable FileDescriptor necessary for export of.
filename The name of the file that the data should be exported to.
startRow The DimensionDescriptor that specifies the starting row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first row will be used.
stopRow The DimensionDescriptor that specifies the ending row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last row will be used.
rowSkipFactor Specifies the number of rows that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following row positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following row positions: 0, 2, 4, 6.
startCol The DimensionDescriptor that specifies the starting column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first column will be used.
stopCol The DimensionDescriptor that specifies the ending column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last column will be used.
colSkipFactor Specifies the number of columns that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following column positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following column positions: 0, 2, 4, 6.
subsetBands Specifies the list of bands that should be included in the subset. The vector must be a subset of the DataDescriptor::getBands() value. An empty vector can be provided, in which case no bands will be removed during the subset.
Returns:
A newly created FileDescriptor, of an appropriate subclass to match pDd. The returned FileDescriptor only includes the specified subset and is not set into the DataDescriptor and is only suitable for an exporter to use.

FileDescriptor* RasterUtilities::generateFileDescriptorForExport ( const DataDescriptor pDd,
const std::string &  filename 
)

Returns a FileDescriptor that can be provided to an exporter to export the data represented by the given DataDescriptor.

Parameters:
pDd The DataDescriptor to generate a suitable FileDescriptor necessary for export of.
filename The name of the file that the data should be exported to.
Returns:
A newly created FileDescriptor, of an appropriate subclass to match pDd. The returned FileDescriptor is not set into the DataDescriptor and is only suitable for an exporter to use.

RasterDataDescriptor* RasterUtilities::generateRasterDataDescriptor ( const std::string &  name,
DataElement pParent,
unsigned int  rows,
unsigned int  columns,
EncodingType  encoding,
ProcessingLocation  location 
)

Generate a populated RasterDataDescriptor to match the given parameters assuming the data only has one band.

The new RasterDataDescriptor will inherit the classification settings of the parent DataElement unless the parent element is NULL, in which case the classification will be set to the system's highest level.

Parameters:
name The name for the new RasterDataDescriptor.
pParent The parent element for the new RasterDataDescriptor.
rows The number of rows for the new RasterDataDescriptor.
columns The number of columns for the new RasterDataDescriptor.
encoding The encoding for the new RasterDataDescriptor.
location The processing location for the new RasterDataDescriptor.
Returns:
A fully populated RasterDataDescriptor, without a FileDescriptor. Note that original numbers for rows, and columns will go from 0 to n.

RasterDataDescriptor* RasterUtilities::generateRasterDataDescriptor ( const std::string &  name,
DataElement pParent,
unsigned int  rows,
unsigned int  columns,
unsigned int  bands,
InterleaveFormatType  interleave,
EncodingType  encoding,
ProcessingLocation  location 
)

Generate a populated RasterDataDescriptor to match the given parameters.

The new RasterDataDescriptor will inherit the classification settings of the parent DataElement unless the parent element is NULL, in which case the classification will be set to the system's highest level.

Parameters:
name The name for the new RasterDataDescriptor.
pParent The parent element for the new RasterDataDescriptor.
rows The number of rows for the new RasterDataDescriptor.
columns The number of columns for the new RasterDataDescriptor.
bands The number of bands for the new RasterDataDescriptor.
interleave The interleave for the new RasterDataDescriptor.
encoding The encoding for the new RasterDataDescriptor.
location The processing location for the new RasterDataDescriptor.
Returns:
A fully populated RasterDataDescriptor, without a FileDescriptor. Note that original numbers for rows, columns, and bands will go from 0 to n.
Examples:
SampleRasterElementImporter.cpp.

RasterDataDescriptor* RasterUtilities::generateUnchippedRasterDataDescriptor ( const RasterElement pOrigElement  ) 

Generate a populated RasterDataDescriptor with RasterFileDescriptor to match the given RasterElement without any chipping.

This method will retain any interesting original DimensionDescriptor numbers, inherit the classification from the original element but not copy any metadata.

Parameters:
pOrigElement The RasterElement to copy. There must be a valid RasterFileDescriptor attached to this element.
Returns:
A fully populated RasterDataDescriptor with RasterFileDescriptor. The original numbers for rows and columns will match those for pOrigElement, but without any chipping. The parent of this descriptor is pOrigElement.

std::string RasterUtilities::getBandName ( const RasterDataDescriptor pDescriptor,
DimensionDescriptor  band 
)

Returns the band name for the given descriptor and band.

This method will query the SPECIAL_METADATA_NAME / BAND_METADATA_NAME / NAMES_METADATA_NAME and SPECIAL_METADATA_NAME / BAND_NAME_PREFIX_METADATA_NAME keys of the metadata to determine the correct band name. This method should not be called for every band in a RasterDataDescriptor, for that please call getBandNames().

Parameters:
pDescriptor the descriptor to return the band name for.
band the individual band to return the band name for.
Returns:
the band name for the given descriptor and band or empty string if not found.

std::vector<std::string> RasterUtilities::getBandNames ( const RasterDataDescriptor pDescriptor  ) 

Returns the band names for the given descriptor.

This method will query the SPECIAL_METADATA_NAME / BAND_METADATA_NAME / NAMES_METADATA_NAME and SPECIAL_METADATA_NAME / BAND_NAME_PREFIX_METADATA_NAME keys of the metadata to determine the correct band names.

Parameters:
pDescriptor the descriptor to return the band names for.
Returns:
the band names for the given descriptor or empty vector if not found.

std::vector<RasterChannelType> RasterUtilities::getVisibleRasterChannels (  ) 

Returns a vector of RasterChannelType enum values.

Returns:
a vector of RasterChannelType enum values.

template<typename T>
bool RasterUtilities::isBad ( value  ) 

Checks whether a floating-point value is a NaN.

Parameters:
value The value to test.
Returns:
True if value is NaN, false otherwise.

Definition at line 852 of file RasterUtilities.h.

template<>
bool RasterUtilities::isBad< double > ( double  value  ) 

Checks whether a floating-point value is a NaN.

Parameters:
value The value to test.
Returns:
True if value is NaN, false otherwise.

template<>
bool RasterUtilities::isBad< float > ( float  value  ) 

Checks whether a floating-point value is a NaN.

Parameters:
value The value to test.
Returns:
True if value is NaN, false otherwise.

bool RasterUtilities::isSubcube ( const RasterDataDescriptor pDescriptor,
bool  checkBands 
)

Returns whether or not raster image is a subcube.

Parameters:
pDescriptor the descriptor of the raster image to be checked.
checkBands If true, include the bands in the comparison. If false, don't include the bands
Returns:
True if the raster image DimensionDescriptors for Rows, Columns and Bands are equal to the DimensionDescriptors for the Rows, Columns and Bands of the RasterFileDescriptor and the checkBands parameter is true or if the raster image DimensionDescriptors for Rows and Columns are equal to the DimensionDescriptors for the Rows and Columns of the RasterFileDescriptor and the checkBands parameter is false.

bool RasterUtilities::rotate ( RasterElement pDst,
const RasterElement pSrc,
double  angle,
int  defaultValue,
InterpolationType  interp = NEAREST_NEIGHBOR,
Progress pProgress = NULL,
bool *  pAbort = NULL 
)

Rotate a data set.

The original dimensions of the data set are maintained. This means that data clipping and padding may occur.

Parameters:
pDst Destination RasterElement. Must be initialized to the same params as pSrc.
pSrc RasterElement to rotate.
angle Rotate by this angle. In radians.
defaultValue Pixels which do not map to anything in the original data set will be set to this value. This value will be added to the bad values list if it is not already there.
interp Interpolation type. Only NEAREST_NEIGHBOR is currently supported.
pProgress Report progress.
pAbort If not NULL, check this value during the rotation. If the value becomes true, abort.
Returns:
True if successful, false on error.

uint64_t RasterUtilities::sanitizeData ( void *  pData,
uint64_t  count,
EncodingType  type,
double  value = 0.0 
)

Sanitize the given data.

This method will iterate over the given data and replace all instances of floating point NaNs with the specified value.

Parameters:
pData Pointer to the data to be sanitized.
count The number of data values to be sanitized.
type The EncodingType of pData.
value The value to use for all instances of floating point NaNs. This value will be cast (via static_cast) to the given EncodingType.
Returns:
The number of data values which were sanitized.

Definition at line 944 of file RasterUtilities.h.

template<typename T>
uint64_t RasterUtilities::sanitizeData ( T *  pData,
uint64_t  count,
double  value = 0.0 
)

Sanitize the given data.

This method will iterate over the given data and replace all instances of floating point NaNs with the specified value.

Parameters:
pData Pointer to the data to be sanitized.
count The number of data values to be sanitized.
value The value to use for all instances of floating point NaNs. This value will be cast (via static_cast) to T.
Returns:
The number of data values which were sanitized.

Definition at line 904 of file RasterUtilities.h.

void RasterUtilities::subsetDataDescriptor ( DataDescriptor pDd,
const DimensionDescriptor startRow,
const DimensionDescriptor stopRow,
unsigned int  rowSkipFactor,
const DimensionDescriptor startCol,
const DimensionDescriptor stopCol,
unsigned int  colSkipFactor,
const DimensionDescriptor startBand,
const DimensionDescriptor stopBand,
unsigned int  bandSkipFactor 
)

Modifies the provided DataDescriptor to include only the subset specified.

Parameters:
pDd The DataDescriptor that should be modified to only include the specified subset.
startRow The DimensionDescriptor that specifies the starting row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first row will be used.
stopRow The DimensionDescriptor that specifies the ending row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last row will be used.
rowSkipFactor Specifies the number of rows that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following row positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following row positions: 0, 2, 4, 6.
startCol The DimensionDescriptor that specifies the starting column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first column will be used.
stopCol The DimensionDescriptor that specifies the ending column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last column will be used.
colSkipFactor Specifies the number of columns that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following column positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following column positions: 0, 2, 4, 6.
startBand The DimensionDescriptor that specifies the starting band of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the band subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first band will be used.
stopBand The DimensionDescriptor that specifies the ending band of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the band subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last band will be used.
bandSkipFactor Specifies the number of band that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following band positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following band positions: 0, 2, 4, 6.

void RasterUtilities::subsetDataDescriptor ( DataDescriptor pDd,
const DimensionDescriptor startRow,
const DimensionDescriptor stopRow,
unsigned int  rowSkipFactor,
const DimensionDescriptor startCol,
const DimensionDescriptor stopCol,
unsigned int  colSkipFactor,
const std::vector< DimensionDescriptor > &  subsetBands = std::vector< DimensionDescriptor >() 
)

Modifies the provided DataDescriptor to include only the subset specified.

Parameters:
pDd The DataDescriptor that should be modified to only include the specified subset.
startRow The DimensionDescriptor that specifies the starting row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first row will be used.
stopRow The DimensionDescriptor that specifies the ending row of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the row subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last row will be used.
rowSkipFactor Specifies the number of rows that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following row positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following row positions: 0, 2, 4, 6.
startCol The DimensionDescriptor that specifies the starting column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the first column will be used.
stopCol The DimensionDescriptor that specifies the ending column of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the column subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the last column will be used.
colSkipFactor Specifies the number of columns that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following column positions: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following column positions: 0, 2, 4, 6.
subsetBands Specifies the list of bands that should be included in the subset. The vector must be a subset of the DataDescriptor::getBands() value. An empty vector can be provided, in which case no bands will be removed during the subset.

std::vector<DimensionDescriptor> RasterUtilities::subsetDimensionVector ( const std::vector< DimensionDescriptor > &  origValues,
const DimensionDescriptor start,
const DimensionDescriptor stop,
unsigned int  skipFactor = 0 
)

Returns a subset DimensionDescriptor vector.

Parameters:
origValues The DimensionDescriptor vector that should be subset.
start The DimensionDescriptor that specifies the start of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the start of the subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the beginning of the origVector will be used.
stop The DimensionDescriptor that specifies the end of the subset. The DimensionDescriptor::getOriginalNumber() will be used to determine the end of the subset in the vector. A default constructed DimensionDescriptor can be provided, in which case the end of the origVector will be used.
skipFactor Specifies the number of DimensionDescriptors that should be skipped while creating the subset. For example, a skipFactor of 0 would include the following entries of the vector: 0, 1, 2, 3, 4, 5, 6. For example, a skipFactor of 1 would include the following entries of the vector: 0, 2, 4, 6.
Returns:
A new DimensionDescriptor vector that has been subset as specified.


Software Development Kit - Opticks 4.8.0 Build 15482