QgsRasterLayer Class Reference
[Core]

#include <qgsrasterlayer.h>

Inheritance diagram for QgsRasterLayer:

Inheritance graph
[legend]
Collaboration diagram for QgsRasterLayer:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class provides qgis with the ability to render raster datasets onto the mapcanvas.

The qgsrasterlayer class makes use of gdal for data io, and thus supports any gdal supported format. The constructor attempts to infer what type of file (LayerType) is being opened - not in terms of the file format (tif, ascii grid etc.) but rather in terms of whether the image is a GRAYSCALE, PaletteD or Multiband,

Within the three allowable raster layer types, there are 8 permutations of how a layer can actually be rendered. These are defined in the DrawingStyle enum and consist of:

SingleBandGray -> a GRAYSCALE layer drawn as a range of gray colors (0-255) SingleBandPseudoColor -> a GRAYSCALE layer drawn using a pseudocolor algorithm PalettedSingleBandGray -> a PaletteD layer drawn in gray scale (using only one of the color components) PalettedSingleBandPseudoColor -> a PaletteD layer having only one of its color components rendered as psuedo color PalettedMultiBandColor -> a PaletteD image where the bands contains 24bit color info and 8 bits is pulled out per color MultiBandSingleGandGray -> a layer containing 2 or more bands, but using only one band to produce a grayscale image MultiBandSingleBandPseudoColor -> a layer containing 2 or more bands, but using only one band to produce a pseudocolor image MultiBandColor -> a layer containing 2 or more bands, mapped to the three RGBcolors. In the case of a multiband with only two bands, one band will have to be mapped to more than one color

Each of the above mentioned drawing styles is implemented in its own draw* function. Some of the drawing styles listed above require statistics about the layer such as the min / max / mean / stddev etc. statistics for a band can be gathered using the bandStatistics function. Note that statistics gathering is a slow process and every effort should be made to call this function as few times as possible. For this reason, qgsraster has a vector class member to store stats for each band. The constructor initialises this vector on startup, but only populates the band name and number fields.

Note that where bands are of gdal 'undefined' type, their values may exceed the renderable range of 0-255. Because of this a linear scaling histogram enhanceContrast is applied to undefined layers to normalise the data into the 0-255 range.

A qgsrasterlayer band can be referred to either by name or by number (base=1). It should be noted that band names as stored in datafiles may not be unique, and so the rasterlayer class appends the band number in brackets behind each band name.

Sample usage of the QgsRasterLayer class:

     QString myFileNameQString = "/path/to/file";
     QFileInfo myFileInfo(myFileNameQString);
     QString myBaseNameQString = myFileInfo.baseName();
     QgsRasterLayer *myRasterLayer = new QgsRasterLayer(myFileNameQString, myBaseNameQString);

In order to automate redrawing of a raster layer, you should like it to a map canvas like this :

     QObject::connect( myRasterLayer, SIGNAL(repaintRequested()), mapCanvas, SLOT(refresh()) );

A raster layer can also export its legend as a pixmap:

     QPixmap myQPixmap = myRasterLayer->legendPixmap();

Once a layer has been created you can find out what type of layer it is (GrayOrUndefined, Palette or Multiband):

    if (rasterLayer->rasterType()==QgsRasterLayer::Multiband)
    {
      //do something
    }
    else if (rasterLayer->rasterType()==QgsRasterLayer::Palette)
    {
      //do something
    }
    else // QgsRasterLayer::GrayOrUndefined
    {
      //do something.
    }

You can combine layer type detection with the setDrawingStyle method to override the default drawing style assigned when a layer is loaded:

    if (rasterLayer->rasterType()==QgsRasterLayer::Multiband)
    {
       myRasterLayer->setDrawingStyle(QgsRasterLayer::MultiBandSingleBandPseudoColor);
    }
    else if (rasterLayer->rasterType()==QgsRasterLayer::Palette)
    {
      myRasterLayer->setDrawingStyle(QgsRasterLayer::PalettedSingleBandPseudoColor);
    }
    else // QgsRasterLayer::GrayOrUndefined
    {
      myRasterLayer->setDrawingStyle(QgsRasterLayer::SingleBandPseudoColor);
    }

Raster layers can also have an arbitrary level of transparency defined, and have their color palettes inverted using the setTransparency and setInvertHistogram methods.

Pseudocolor images can have their output adjusted to a given number of standard deviations using the setStandardDeviations method.

The final area of functionality you may be interested in is band mapping. Band mapping allows you to choose arbitrary band -> color mappings and is applicable only to Palette and Multiband rasters, There are four mappings that can be made: red, green, blue and gray. Mappings are non-exclusive. That is a given band can be assigned to no, some or all color mappings. The constructor sets sensible defaults for band mappings but these can be overridden at run time using the setRedBandName, setGreenBandName, setBlueBandName and setGrayBandName methods.

Definition at line 179 of file qgsrasterlayer.h.

Public Types

enum  ColorShadingAlgorithm {
  UndefinedShader, PseudoColorShader, FreakOutShader, ColorRampShader,
  UserDefinedShader
}
 This enumerator describes the types of shading that can be used. More...
enum  DrawingStyle {
  UndefinedDrawingStyle, SingleBandGray, SingleBandPseudoColor, PalettedColor,
  PalettedSingleBandGray, PalettedSingleBandPseudoColor, PalettedMultiBandColor, MultiBandSingleGandGray,
  MultiBandSingleBandPseudoColor, MultiBandColor
}
 This enumerator describes the different kinds of drawing we can do. More...
enum  LayerType { GrayOrUndefined, Palette, Multiband }
 This enumerator describes the type of raster layer. More...
typedef QList< QgsContrastEnhancementContrastEnhancementList
 A list containing on ContrastEnhancement object per raster band in this raster layer.
typedef QList< QgsRasterPyramidRasterPyramidList
 A list containing one RasterPyramid struct per raster band in this raster layer.
typedef QList< QgsRasterBandStatsRasterStatsList
 A list containing one RasterBandStats struct per raster band in this raster layer.

Public Slots

QString buildPyramids (const RasterPyramidList &, const QString &theResamplingMethod="NEAREST", bool theTryInternalFlag=false)
 Create GDAL pyramid overviews.
void populateHistogram (int theBandNoInt, int theBinCountInt=256, bool theIgnoreOutOfRangeFlag=true, bool theThoroughBandScanFlag=false)
 Populate the histogram vector for a given band.
void showStatusMessage (const QString &theMessage)
void updateProgress (int, int)
 Propagate progress updates from GDAL up to the parent app.

Signals

void progressUpdate (int theValue)
 Signal for notifying listeners of long running processes.

Public Member Functions

 QgsRasterLayer (const QString &path=QString::null, const QString &baseName=QString::null, bool loadDefaultStyleFlag=true)
 This is the constructor for the RasterLayer class.
 QgsRasterLayer (int dummy, const QString &baseName=QString(), const QString &path=QString(), const QString &providerLib=QString(), const QStringList &layers=QStringList(), const QStringList &styles=QStringList(), const QString &format=QString(), const QString &crs=QString())
 [ data provider interface ] Constructor in provider mode
 ~QgsRasterLayer ()
 The destructor.
QString blueBandName () const
 Accessor for blue band name mapping.
QgsRasterLayer::ColorShadingAlgorithm colorShadingAlgorithm () const
 Accessor for color shader algorithm.
QgsContrastEnhancement::ContrastEnhancementAlgorithm contrastEnhancementAlgorithm ()
 Accessor for contrast enhancement algorithm.
QString contrastEnhancementAlgorithmAsString () const
 Returns contrast enhancement algorithm as a string.
DrawingStyle drawingStyle ()
 Accessor for drawing style.
QString grayBandName () const
 Accessor for gray band name mapping.
QString greenBandName () const
 Accessor for green band name mapping.
bool hasPyramids ()
 Accessor for mHasPyramids (READ ONLY).
bool hasUserDefinedGrayMinimumMaximum () const
 Accessor for mUserDefinedGrayMinimumMaximum.
bool hasUserDefinedRGBMinimumMaximum () const
 Accessor for mUserDefinedRGBMinimumMaximum.
int height ()
 Accessor that returns the height of the (unclipped) raster.
bool invertHistogram () const
 Accessor to find out whether the histogram should be inverted.
bool isNoDataValueValid () const
 Is the NoDataValue Valid.
bool isGrayMinimumMaximumEstimated () const
 Accessor for mGrayMinimumMaximumEstimated.
bool isRGBMinimumMaximumEstimated () const
 Accessor for mRGBMinimumMaximumEstimated.
double noDataValue (bool *isValid=0)
 Accessor that returns the NO_DATA entry for this raster.
QgsRasterTransparencyrasterTransparency ()
 Returns a pointer to the transparency object.
QgsRasterShaderrasterShader ()
 Accessor for raster shader.
LayerType rasterType ()
 Accessor for raster layer type (which is a read only property).
QString redBandName () const
 Accessor for red band name (allows alternate mappings e.g.
void setDataProvider (const QString &provider, const QStringList &layers, const QStringList &styles, const QString &format, const QString &crs)
 [ data provider interface ] Set the data provider
void setDrawingStyle (const DrawingStyle &theDrawingStyle)
 Mutator for drawing style.
void setGrayMinimumMaximumEstimated (bool theBool)
 Mutator for mGrayMinimumMaximumEstimated.
void setInvertHistogram (bool theFlag)
 Mutator to alter the state of the invert histogram flag.
void setRGBMinimumMaximumEstimated (bool theBool)
 Mutator for mRGBMinimumMaximumEstimated.
void setStandardDeviations (double theStandardDeviations)
 Mutator to alter the number of standard deviations that should be plotted.
void setUserDefinedGrayMinimumMaximum (bool theBool)
 Mutator for mUserDefinedGrayMinimumMaximum.
void setUserDefinedRGBMinimumMaximum (bool theBool)
 Mutator for mUserDefinedRGBMinimumMaximum.
double standardDeviations () const
 Accessor to find out how many standard deviations are being plotted.
QString transparentBandName () const
 Accessor for transparent band name mapping.
bool usesProvider ()
 [ data provider interface ] Does this layer use a provider for setting/retrieving data?
int width ()
 Accessor that returns the width of the (unclipped) raster.
unsigned int bandCount ()
 Get the number of bands in this layer.
const QString bandName (int theBandNoInt)
 Get the name of a band given its number.
int bandNumber (const QString &theBandName)
 Get the number of a band given its name.
const QgsRasterBandStats bandStatistics (int)
 Get RasterBandStats for a band given its number (read only).
const QgsRasterBandStats bandStatistics (const QString &)
 Get RasterBandStats for a band given its name (read only).
RasterPyramidList buildPyramidList ()
 Accessor for ths raster layers pyramid list.
QString colorShadingAlgorithmAsString () const
 Accessor for color shader algorithm.
void computeMinimumMaximumEstimates (int theBand, double *theMinMax)
 Wrapper for GDALComputeRasterMinMax with the estimate option.
void computeMinimumMaximumEstimates (QString theBand, double *theMinMax)
 Wrapper for GDALComputeRasterMinMax with the estimate option.
QgsContrastEnhancementcontrastEnhancement (unsigned int theBand)
 Get a pointer to the contrast enhancement for the selected band.
bool copySymbologySettings (const QgsMapLayer &theOther)
 Copies the symbology settings from another layer.
QList< QgsColorRampShader::ColorRampItem > * colorTable (int theBandNoInt)
 Get a pointer to the color table.
QgsRasterDataProviderdataProvider ()
 Returns the data provider.
const QgsRasterDataProviderdataProvider () const
 Returns the data provider in a const-correct manner.
bool draw (QgsRenderContext &rendererContext)
 This is called when the view on the raster layer needs to be redrawn.
void draw (QPainter *theQPainter, QgsRasterViewPort *myRasterViewPort, const QgsMapToPixel *theQgsMapToPixel=0)
 This is an overloaded version of the draw() function that is called by both draw() and thumbnailAsPixmap.
QString drawingStyleAsString () const
 Returns a string representation of drawing style.
bool hasCompatibleSymbology (const QgsMapLayer &theOther) const
 Checks if symbology is the same as another layers.
bool hasStatistics (int theBandNoInt)
 Check whether a given band number has stats associated with it.
bool identify (const QgsPoint &point, QMap< QString, QString > &results)
 Identify raster value(s) found on the point position.
QString identifyAsText (const QgsPoint &point)
 Identify arbitrary details from the WMS server found on the point position.
bool isEditable () const
 Currently returns always false.
QString lastError ()
 [ data provider interface ] If an operation returns 0 (e.g.
QString lastErrorTitle ()
 [ data provider interface ] If an operation returns 0 (e.g.
QPixmap legendAsPixmap ()
 Get a legend image for this layer.
QPixmap legendAsPixmap (bool)
 Overloaded version of above function that can print layer name onto legend.
QPixmap legendAsPixmap (int theLabelCount)
 Use this method when you want an annotated legend suitable for print output etc.
double maximumValue (unsigned int theBand)
 Accessor for maximum value user for contrast enhancement.
double maximumValue (QString theBand)
 Accessor for maximum value user for contrast enhancement.
QString metadata ()
 Obtain GDAL Metadata for this layer.
double minimumValue (unsigned int theBand)
 Accessor for minimum value user for contrast enhancement.
double minimumValue (QString theBand)
 Accessor for minimum value user for contrast enhancement.
QPixmap paletteAsPixmap (int theBand=1)
 Get an 100x100 pixmap of the color palette.
QString providerKey ()
 [ data provider interface ] Which provider is being used for this Raster Layer?
double rasterUnitsPerPixel ()
 Returns the number of raster units per each raster pixel.
bool readColorTable (int theBandNumber, QList< QgsColorRampShader::ColorRampItem > *theList)
 Read color table from GDAL raster band.
void resetNoDataValue ()
 Simple reset function that set the noDataValue back to the value stored in the first raster band.
void setBlueBandName (const QString &theBandName)
 Mutator for blue band name mapping.
void setColorShadingAlgorithm (QgsRasterLayer::ColorShadingAlgorithm theShaderAlgorithm)
 Mutator for color shader algorithm.
void setColorShadingAlgorithm (QString theShaderAlgorithm)
 Mutator for color shader algorithm.
void setContrastEnhancementAlgorithm (QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm, bool theGenerateLookupTableFlag=true)
 Mutator for contrast enhancement algorithm.
void setContrastEnhancementAlgorithm (QString theAlgorithm, bool theGenerateLookupTableFlag=true)
 Mutator for contrast enhancement algorithm.
void setContrastEnhancementFunction (QgsContrastEnhancementFunction *theFunction)
 Mutator for contrast enhancement function.
void setDrawingStyle (const QString &theDrawingStyleQString)
 Overloaded version of the above function for convenience when restoring from xml.
void setGrayBandName (const QString &theBandName)
 Mutator for gray band name mapping.
void setGreenBandName (const QString &theBandName)
 Mutator for green band name mapping.
void setMaximumValue (unsigned int theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the maximum value for contrast enhancement.
void setMaximumValue (QString theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the maximum value for contrast enhancement.
void setMinimumValue (unsigned int theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the minimum value for contrast enhancement.
void setMinimumValue (QString theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the minimum value for contrast enhancement.
void setNoDataValue (double theNoData)
 Mutator that allows the NO_DATA entry for this raster to be overridden.
void setRasterShaderFunction (QgsRasterShaderFunction *theFunction)
 Set the raster shader function to a user defined function.
void setRedBandName (const QString &theBandName)
 Mutator for red band name (allows alternate mappings e.g.
void setTransparentBandName (const QString &theBandName)
 Mutator for transparent band name mapping.
void showProgress (int theValue)
 [ data provider interface ] A wrapper function to emit a progress update signal
QStringList subLayers () const
 Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS.
void thumbnailAsPixmap (QPixmap *theQPixmap)
 Draws a thumbnail of the rasterlayer into the supplied pixmap pointer.
void triggerRepaint ()
 Emit a signal asking for a repaint.
virtual void setLayerOrder (const QStringList &layers)
 Reorders the *previously selected* sublayers of this layer from bottom to top.
virtual void setSubLayerVisibility (const QString &name, bool vis)
 Set the visibility of the given sublayer name.

Static Public Member Functions

static void buildSupportedRasterFileFilter (QString &fileFilters)
 Builds the list of file filter strings to later be used by QgisApp::addRasterLayer().
static bool isValidRasterFileName (const QString &theFileNameQString, QString &retError)
 This helper checks to see whether the file name appears to be a valid raster file name.
static bool isValidRasterFileName (const QString &theFileNameQString)
static QDateTime lastModified (const QString &name)
 Return time stamp for given file name.
static void registerGdalDrivers ()
 ensures that GDAL drivers are registered, but only once

Protected Member Functions

bool readSymbology (const QDomNode &node, QString &errorMessage)
 Read the symbology for the current layer from the Dom node supplied.
bool readXml (QDomNode &layer_node)
 Reads layer specific state from project file Dom node.
bool writeSymbology (QDomNode &, QDomDocument &doc, QString &errorMessage) const
 Write the symbology for the layer into the docment provided.
bool writeXml (QDomNode &layer_node, QDomDocument &doc)
 Write layer specific state to project file Dom node.

Private Member Functions

void drawMultiBandColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel)
 Drawing routine for multiband image.
void drawMultiBandSingleBandGray (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for multiband image, rendered as a single band image in grayscale.
void drawMultiBandSingleBandPseudoColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for multiband image, rendered as a single band image in pseudocolor.
void drawPalettedSingleBandColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for single band with a color map.
void drawPalettedSingleBandGray (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for paletted image, rendered as a single band image in grayscale.
void drawPalettedSingleBandPseudoColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for paletted image, rendered as a single band image in pseudocolor.
void drawPalettedMultiBandColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for paletted multiband image.
void drawSingleBandGray (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for single band grayscale image.
void drawSingleBandPseudoColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for single band grayscale image, rendered in pseudocolor.
void closeDataset ()
 Close data set and release related data.
bool hasBand (const QString &theBandName)
 Find out whether a given band exists.
void paintImageToCanvas (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, QImage *theImage)
 Places the rendered image onto the canvas.
QString projectionWkt ()
 Query GDAL to find out the Wkt projection string for this layer.
void * readData (GDALRasterBandH gdalBand, QgsRasterViewPort *viewPort)
 Allocate memory and load data to that allocated memory.
bool readFile (const QString &fileName)
 Load the given raster file.
double readValue (void *data, GDALDataType type, int index)
 Read a raster value given position from memory block created by readData().
bool update ()
 Update the layer if it is outdated.
QString validateBandName (const QString &theBandName)
 Verify and transform band name for internal consistency.

Private Attributes

const QString QSTRING_NOT_SET
 Constant defining flag for XML and a constant that signals property not used.
const QString TRSTRING_NOT_SET
QString mBlueBandName
 The band to be associated with the color blue - usually 3.
ColorShadingAlgorithm mColorShadingAlgorithm
 The raster shading algorithm being used.
QgsContrastEnhancement::ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm
 The contrast enhancement algorithm being used.
ContrastEnhancementList mContrastEnhancementList
 List containing the contrast enhancements for each band.
double mStandardDeviations
 Number of stddev to plot (0) to ignore.
QgsRasterDataProvidermDataProvider
 [ data provider interface ] Pointer to data provider derived from the abstract base class QgsDataProvider
DrawingStyle mDrawingStyle
bool mEditable
 [ data provider interface ] Flag indicating wheter the layer is in editing mode or not
QString mError
 [ data provider interface ]The error message associated with the last error
QString mErrorCaption
 [ data provider interface ] The error caption associated with the last error
GDALDatasetH mGdalBaseDataset
 Pointer to the gdaldataset.
GDALDatasetH mGdalDataset
 Pointer to the gdaldataset (possibly warped vrt).
double mGeoTransform [6]
 Values for mapping pixel to world coordinates.
QString mGrayBandName
 The band to be associated with the grayscale only output - usually 1.
bool mGrayMinimumMaximumEstimated
 Flag to indicate of the min max values are actual or estimates/user defined.
QString mGreenBandName
 The band to be associated with the color green - usually 2.
bool mHasPyramids
 Whether this raster has overviews / pyramids or not.
int mWidth
 Raster width.
int mHeight
 Raster height.
bool mInvertColor
 Flag indicating whether the color of pixels should be inverted or not.
QDateTime mLastModified
 [ data provider interface ] Timestamp, the last modified time of the data source when the layer was created
QLibrary * mLib
 [ data provider interface ] pointer for loading the provider library
bool mModified
 [ data provider interface ] Flag indicating whether the layer has been modified since the last commit
double mNoDataValue
 Cell value representing no data.
QString mProviderKey
 [ data provider interface ] Data provider key
RasterPyramidList mPyramidList
 This list holds a series of RasterPyramid structs which store information for each potential pyramid level.
QgsRasterShadermRasterShader
 The raster shader for the layer.
RasterStatsList mRasterStatsList
 A collection of stats - one for each band in the layer.
QgsRasterTransparency mRasterTransparency
 The transparency container.
LayerType mRasterType
QString mRedBandName
 The band to be associated with the color red - usually 1.
bool mRGBMinimumMaximumEstimated
 Flag to indicate of the min max values are actual or estimates/user defined.
QString mTransparencyBandName
 The band to be associated with transparency.
bool mUserDefinedGrayMinimumMaximum
 Flag to indicate if the user entered custom min max values.
bool mUserDefinedRGBMinimumMaximum
 Flag to indicate if the user entered custom min max values.
bool mValidNoDataValue
 Flag indicating if the nodatavalue is valid.


Member Typedef Documentation

typedef QList<QgsContrastEnhancement> QgsRasterLayer::ContrastEnhancementList

A list containing on ContrastEnhancement object per raster band in this raster layer.

Definition at line 256 of file qgsrasterlayer.h.

typedef QList<QgsRasterPyramid> QgsRasterLayer::RasterPyramidList

A list containing one RasterPyramid struct per raster band in this raster layer.

POTENTIAL pyramid layer. This works by dividing the height and width of the raster by an incrementing number. As soon as the result of the division is <=256 we stop allowing RasterPyramid structs to be added to the list. Each time a RasterPyramid is created we will check to see if a pyramid matching these dimensions already exists in the raster layer, and if so mark the exists flag as true

Definition at line 265 of file qgsrasterlayer.h.

typedef QList<QgsRasterBandStats> QgsRasterLayer::RasterStatsList

A list containing one RasterBandStats struct per raster band in this raster layer.

Note that while every RasterBandStats element will have the name and number of its associated band populated, any additional stats are calculated on a need to know basis.

Definition at line 270 of file qgsrasterlayer.h.


Member Enumeration Documentation

enum QgsRasterLayer::ColorShadingAlgorithm

This enumerator describes the types of shading that can be used.

Enumerator:
UndefinedShader 
PseudoColorShader 
FreakOutShader 
ColorRampShader 
UserDefinedShader 

Definition at line 222 of file qgsrasterlayer.h.

enum QgsRasterLayer::DrawingStyle

This enumerator describes the different kinds of drawing we can do.

Enumerator:
UndefinedDrawingStyle 
SingleBandGray 
SingleBandPseudoColor 
PalettedColor 
PalettedSingleBandGray 
PalettedSingleBandPseudoColor 
PalettedMultiBandColor 
MultiBandSingleGandGray 
MultiBandSingleBandPseudoColor 
MultiBandColor 

Definition at line 232 of file qgsrasterlayer.h.

enum QgsRasterLayer::LayerType

This enumerator describes the type of raster layer.

Enumerator:
GrayOrUndefined 
Palette 
Multiband 

Reimplemented from QgsMapLayer.

Definition at line 248 of file qgsrasterlayer.h.


Constructor & Destructor Documentation

QgsRasterLayer::QgsRasterLayer ( const QString &  path = QString::null,
const QString &  baseName = QString::null,
bool  loadDefaultStyleFlag = true 
)

This is the constructor for the RasterLayer class.

The main tasks carried out by the constructor are:

-Load the rasters default style (.qml) file if it exists

-Populate the RasterStatsVector with initial values for each band.

-Calculate the layer extents

-Determine whether the layer is gray, paletted or multiband.

-Assign sensible defaults for the red, green, blue and gray bands.

Definition at line 73 of file qgsrasterlayer.cpp.

References QgsMapLayer::loadDefaultStyle(), mGeoTransform, mGrayMinimumMaximumEstimated, mRasterShader, mRGBMinimumMaximumEstimated, mUserDefinedGrayMinimumMaximum, mUserDefinedRGBMinimumMaximum, readFile(), and QgsMapLayer::setLayerName().

QgsRasterLayer::QgsRasterLayer ( int  dummy,
const QString &  baseName = QString(),
const QString &  path = QString(),
const QString &  providerLib = QString(),
const QStringList &  layers = QStringList(),
const QStringList &  styles = QStringList(),
const QString &  format = QString(),
const QString &  crs = QString() 
)

[ data provider interface ] Constructor in provider mode

Parameters:
dummy is just there to distinguish this function signature from the old non-provider one.

Definition at line 132 of file qgsrasterlayer.cpp.

References mDataProvider, mGeoTransform, mRasterShader, QgsDebugMsg, setDataProvider(), showStatusMessage(), and QgsMapLayer::statusChanged().

QgsRasterLayer::~QgsRasterLayer (  ) 

The destructor.

Definition at line 194 of file qgsrasterlayer.cpp.

References mGdalBaseDataset, mGdalDataset, and mProviderKey.


Member Function Documentation

void QgsRasterLayer::buildSupportedRasterFileFilter ( QString &  theFileFiltersString  )  [static]

Builds the list of file filter strings to later be used by QgisApp::addRasterLayer().

We query GDAL for a list of supported raster formats; we then build a list of file filter strings from that list. We return a string that contains this list that is suitable for use in a QFileDialog::getOpenFileNames() call.

Definition at line 226 of file qgsrasterlayer.cpp.

References QgsDebugMsg, registerGdalDrivers(), and QgsLogger::warning().

bool QgsRasterLayer::isValidRasterFileName ( const QString &  theFileNameQString,
QString &  retError 
) [static]

This helper checks to see whether the file name appears to be a valid raster file name.

If the file name looks like it could be valid, but some sort of error occurs in processing the file, the error is returned in retError.

Definition at line 387 of file qgsrasterlayer.cpp.

References registerGdalDrivers().

Referenced by isValidRasterFileName().

bool QgsRasterLayer::isValidRasterFileName ( const QString &  theFileNameQString  )  [static]

Definition at line 418 of file qgsrasterlayer.cpp.

References isValidRasterFileName().

QDateTime QgsRasterLayer::lastModified ( const QString &  name  )  [static]

Return time stamp for given file name.

Definition at line 426 of file qgsrasterlayer.cpp.

References QgsDebugMsg.

Referenced by readFile(), and update().

void QgsRasterLayer::registerGdalDrivers (  )  [static]

ensures that GDAL drivers are registered, but only once

Definition at line 497 of file qgsrasterlayer.cpp.

Referenced by buildSupportedRasterFileFilter(), isValidRasterFileName(), and readFile().

QString QgsRasterLayer::blueBandName (  )  const [inline]

Accessor for blue band name mapping.

Definition at line 304 of file qgsrasterlayer.h.

Referenced by writeSymbology().

QgsRasterLayer::ColorShadingAlgorithm QgsRasterLayer::colorShadingAlgorithm (  )  const [inline]

Accessor for color shader algorithm.

Definition at line 307 of file qgsrasterlayer.h.

Referenced by writeSymbology().

QgsContrastEnhancement::ContrastEnhancementAlgorithm QgsRasterLayer::contrastEnhancementAlgorithm (  )  [inline]

Accessor for contrast enhancement algorithm.

Definition at line 310 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), and drawSingleBandGray().

QString QgsRasterLayer::contrastEnhancementAlgorithmAsString (  )  const

Returns contrast enhancement algorithm as a string.

Definition at line 1243 of file qgsrasterlayer.cpp.

References QgsContrastEnhancement::ClipToMinimumMaximum, mContrastEnhancementAlgorithm, QgsContrastEnhancement::NoEnhancement, QgsContrastEnhancement::StretchAndClipToMinimumMaximum, QgsContrastEnhancement::StretchToMinimumMaximum, and QgsContrastEnhancement::UserDefinedEnhancement.

Referenced by writeSymbology().

DrawingStyle QgsRasterLayer::drawingStyle (  )  [inline]

Accessor for drawing style.

Definition at line 316 of file qgsrasterlayer.h.

QString QgsRasterLayer::grayBandName (  )  const [inline]

Accessor for gray band name mapping.

Definition at line 319 of file qgsrasterlayer.h.

Referenced by writeSymbology().

QString QgsRasterLayer::greenBandName (  )  const [inline]

Accessor for green band name mapping.

Definition at line 322 of file qgsrasterlayer.h.

Referenced by writeSymbology().

bool QgsRasterLayer::hasPyramids (  )  [inline]

Accessor for mHasPyramids (READ ONLY).

Definition at line 325 of file qgsrasterlayer.h.

bool QgsRasterLayer::hasUserDefinedGrayMinimumMaximum (  )  const [inline]

Accessor for mUserDefinedGrayMinimumMaximum.

Definition at line 328 of file qgsrasterlayer.h.

Referenced by writeSymbology().

bool QgsRasterLayer::hasUserDefinedRGBMinimumMaximum (  )  const [inline]

Accessor for mUserDefinedRGBMinimumMaximum.

Definition at line 331 of file qgsrasterlayer.h.

Referenced by writeSymbology().

int QgsRasterLayer::height (  )  [inline]

Accessor that returns the height of the (unclipped) raster.

Definition at line 334 of file qgsrasterlayer.h.

bool QgsRasterLayer::invertHistogram (  )  const [inline]

Accessor to find out whether the histogram should be inverted.

Definition at line 337 of file qgsrasterlayer.h.

Referenced by writeSymbology().

bool QgsRasterLayer::isNoDataValueValid (  )  const [inline]

Is the NoDataValue Valid.

Definition at line 340 of file qgsrasterlayer.h.

bool QgsRasterLayer::isGrayMinimumMaximumEstimated (  )  const [inline]