Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
QgsRasterLayer Class Reference

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

#include <qgsrasterlayer.h>

Inheritance diagram for QgsRasterLayer:
Inheritance graph
[legend]
Collaboration diagram for QgsRasterLayer:
Collaboration graph
[legend]

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,
  MultiBandSingleBandGray = MultiBandSingleGandGray, MultiBandSingleBandPseudoColor, MultiBandColor, SingleBandColorDataStyle
}
 This enumerator describes the different kinds of drawing we can do. More...
 
enum  LayerType { GrayOrUndefined, Palette, Multiband, ColorLayer }
 This enumerator describes the type of raster layer. More...
 
typedef QList
< QgsContrastEnhancement
ContrastEnhancementList
 A list containing on ContrastEnhancement object per raster band in this raster layer. More...
 
typedef QList< QgsRasterPyramidRasterPyramidList
 A list containing one RasterPyramid struct per raster band in this raster layer. More...
 
typedef QList< QgsRasterBandStatsRasterStatsList
 A list containing one RasterBandStats struct per raster band in this raster layer. More...
 
- Public Types inherited from QgsMapLayer
enum  LayerType { VectorLayer, RasterLayer, PluginLayer }
 Layers enum defining the types of layers that can be added to a map. More...
 

Public Slots

QString buildPyramids (const RasterPyramidList &, const QString &theResamplingMethod="NEAREST", bool theTryInternalFlag=false)
 Create GDAL pyramid overviews. More...
 
void populateHistogram (int theBandNoInt, int theBinCountInt=256, bool theIgnoreOutOfRangeFlag=true, bool theThoroughBandScanFlag=false)
 Populate the histogram vector for a given band. More...
 
void showStatusMessage (const QString &theMessage)
 
void updateProgress (int, int)
 Propagate progress updates from GDAL up to the parent app. More...
 
void onProgress (int, double, QString)
 recieve progress signal from provider More...
 
- Public Slots inherited from QgsMapLayer
virtual void invalidTransformInput ()
 Event handler for when a coordinate transform fails due to bad vertex error. More...
 
void setMinimumScale (float theMinScale)
 Accessor and mutator for the minimum scale member. More...
 
float minimumScale ()
 
void setMaximumScale (float theMaxScale)
 Accessor and mutator for the maximum scale member. More...
 
float maximumScale ()
 
void toggleScaleBasedVisibility (bool theVisibilityFlag)
 Accessor and mutator for the scale based visilibility flag. More...
 
bool hasScaleBasedVisibility ()
 
void clearCacheImage ()
 Clear cached image added in 1.5. More...
 

Signals

void progressUpdate (int theValue)
 Signal for notifying listeners of long running processes. More...
 
void dataChanged ()
 This is emitted whenever data or metadata (e.g. More...
 
- Signals inherited from QgsMapLayer
void drawingProgress (int theProgress, int theTotalSteps)
 Emit a signal to notify of a progress event. More...
 
void statusChanged (QString theStatus)
 Emit a signal with status (e.g. More...
 
void layerNameChanged ()
 Emit a signal that the layer name has been changed. More...
 
void layerCrsChanged ()
 Emit a signal that layer's CRS has been reset added in 1.4. More...
 
void repaintRequested ()
 This signal should be connected with the slot QgsMapCanvas::refresh() More...
 
void screenUpdateRequested ()
 The layer emits this signal when a screen update is requested. More...
 
void recalculateExtents ()
 This is used to send a request that any mapcanvas using this layer update its extents. More...
 
void dataChanged ()
 data of layer changed added in 1.5 More...
 

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. More...
 
 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 More...
 
 ~QgsRasterLayer ()
 The destructor. More...
 
void init ()
 Initialize default values. More...
 
void setDataProvider (const QString &provider, const QStringList &layers, const QStringList &styles, const QString &format, const QString &crs)
 
void setDataProvider (const QString &provider, const QStringList &layers, const QStringList &styles, const QString &format, const QString &crs, bool loadDefaultStyleFlag)
 [ data provider interface ] Set the data provider More...
 
QString blueBandName () const
 Accessor for blue band name mapping. More...
 
QgsRasterLayer::ColorShadingAlgorithm colorShadingAlgorithm () const
 Accessor for color shader algorithm. More...
 
QgsContrastEnhancement::ContrastEnhancementAlgorithm contrastEnhancementAlgorithm ()
 Accessor for contrast enhancement algorithm. More...
 
QString contrastEnhancementAlgorithmAsString () const
 Returns contrast enhancement algorithm as a string. More...
 
DrawingStyle drawingStyle ()
 Accessor for drawing style. More...
 
QString grayBandName () const
 Accessor for gray band name mapping. More...
 
QString greenBandName () const
 Accessor for green band name mapping. More...
 
bool hasPyramids ()
 Accessor for mHasPyramids (READ ONLY) More...
 
bool hasUserDefinedGrayMinimumMaximum () const
 Accessor for mUserDefinedGrayMinimumMaximum. More...
 
bool hasUserDefinedRGBMinimumMaximum () const
 Accessor for mUserDefinedRGBMinimumMaximum. More...
 
int height ()
 Accessor that returns the height of the (unclipped) raster. More...
 
bool invertHistogram () const
 Accessor to find out whether the histogram should be inverted. More...
 
bool isNoDataValueValid () const
 Is the NoDataValue Valid. More...
 
bool isGrayMinimumMaximumEstimated () const
 Accessor for mGrayMinimumMaximumEstimated. More...
 
bool isRGBMinimumMaximumEstimated () const
 Accessor for mRGBMinimumMaximumEstimated. More...
 
double noDataValue (bool *isValid=0)
 Accessor that returns the NO_DATA entry for this raster. More...
 
QgsRasterTransparencyrasterTransparency ()
 Returns a pointer to the transparency object. More...
 
QgsRasterShaderrasterShader ()
 Accessor for raster shader. More...
 
LayerType rasterType ()
 Accessor for raster layer type (which is a read only property) More...
 
QString redBandName () const
 Accessor for red band name (allows alternate mappings e.g. More...
 
void setDrawingStyle (const DrawingStyle &theDrawingStyle)
 Mutator for drawing style. More...
 
void setGrayMinimumMaximumEstimated (bool theBool)
 Mutator for mGrayMinimumMaximumEstimated. More...
 
void setInvertHistogram (bool theFlag)
 Mutator to alter the state of the invert histogram flag. More...
 
void setRGBMinimumMaximumEstimated (bool theBool)
 Mutator for mRGBMinimumMaximumEstimated. More...
 
void setStandardDeviations (double theStandardDeviations)
 Mutator to alter the number of standard deviations that should be plotted. More...
 
void setUserDefinedGrayMinimumMaximum (bool theBool)
 Mutator for mUserDefinedGrayMinimumMaximum. More...
 
void setUserDefinedRGBMinimumMaximum (bool theBool)
 Mutator for mUserDefinedRGBMinimumMaximum. More...
 
double standardDeviations () const
 Accessor to find out how many standard deviations are being plotted. More...
 
QString transparentBandName () const
 Accessor for transparent band name mapping. More...
 
bool usesProvider ()
 [ data provider interface ] Does this layer use a provider for setting/retrieving data? More...
 
int width ()
 Accessor that returns the width of the (unclipped) raster. More...
 
unsigned int bandCount ()
 Get the number of bands in this layer. More...
 
const QString bandName (int theBandNoInt)
 Get the name of a band given its number. More...
 
int bandNumber (const QString &theBandName)
 Get the number of a band given its name. More...
 
const QgsRasterBandStats bandStatistics (int)
 Get RasterBandStats for a band given its number (read only) More...
 
const QgsRasterBandStats bandStatistics (const QString &)
 Get RasterBandStats for a band given its name (read only) More...
 
RasterPyramidList buildPyramidList ()
 Accessor for ths raster layers pyramid list. More...
 
QString colorShadingAlgorithmAsString () const
 Accessor for color shader algorithm. More...
 
void computeMinimumMaximumEstimates (int theBand, double *theMinMax)
 Wrapper for GDALComputeRasterMinMax with the estimate option. More...
 
void computeMinimumMaximumEstimates (QString theBand, double *theMinMax)
 Wrapper for GDALComputeRasterMinMax with the estimate option. More...
 
void computeMinimumMaximumEstimates (int theBand, double &theMin, double &theMax)
 Wrapper for GDALComputeRasterMinMax with the estimate option. More...
 
void computeMinimumMaximumFromLastExtent (int theBand, double *theMinMax)
 Compute the actual minimum maximum pixel values based on the current (last) display extent. More...
 
void computeMinimumMaximumFromLastExtent (QString theBand, double *theMinMax)
 Compute the actual minimum maximum pixel values based on the current (last) display extent. More...
 
void computeMinimumMaximumFromLastExtent (int theBand, double &theMin, double &theMax)
 Compute the actual minimum maximum pixel values based on the current (last) display extent. More...
 
QgsContrastEnhancementcontrastEnhancement (unsigned int theBand)
 Get a pointer to the contrast enhancement for the selected band. More...
 
bool copySymbologySettings (const QgsMapLayer &theOther)
 Copies the symbology settings from another layer. More...
 
QList
< QgsColorRampShader::ColorRampItem > * 
colorTable (int theBandNoInt)
 Get a pointer to the color table. More...
 
QgsRasterDataProviderdataProvider ()
 Returns the data provider. More...
 
const QgsRasterDataProviderdataProvider () const
 Returns the data provider in a const-correct manner. More...
 
virtual void reload ()
 Synchronises with changes in the datasource. More...
 
bool draw (QgsRenderContext &rendererContext)
 This is called when the view on the raster layer needs to be redrawn. More...
 
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. More...
 
QString drawingStyleAsString () const
 Returns a string representation of drawing style. More...
 
bool hasCompatibleSymbology (const QgsMapLayer &theOther) const
 Checks if symbology is the same as another layers. More...
 
bool hasStatistics (int theBandNoInt)
 Check whether a given band number has stats associated with it. More...
 
bool identify (const QgsPoint &point, QMap< QString, QString > &results)
 Identify raster value(s) found on the point position. More...
 
QString identifyAsText (const QgsPoint &point)
 Identify arbitrary details from the WMS server found on the point position. More...
 
QString identifyAsHtml (const QgsPoint &point)
 Identify arbitrary details from the WMS server found on the point position. More...
 
bool isEditable () const
 Currently returns always false. More...
 
QString lastError ()
 [ data provider interface ] If an operation returns 0 (e.g. More...
 
QString lastErrorTitle ()
 [ data provider interface ] If an operation returns 0 (e.g. More...
 
QPixmap legendAsPixmap ()
 Get a legend image for this layer. More...
 
QPixmap legendAsPixmap (bool)
 Overloaded version of above function that can print layer name onto legend. More...
 
QPixmap legendAsPixmap (int theLabelCount)
 Use this method when you want an annotated legend suitable for print output etc. More...
 
double maximumValue (unsigned int theBand)
 Accessor for maximum value user for contrast enhancement. More...
 
double maximumValue (QString theBand)
 Accessor for maximum value user for contrast enhancement. More...
 
QString metadata ()
 Obtain GDAL Metadata for this layer. More...
 
double minimumValue (unsigned int theBand)
 Accessor for minimum value user for contrast enhancement. More...
 
double minimumValue (QString theBand)
 Accessor for minimum value user for contrast enhancement. More...
 
QPixmap paletteAsPixmap (int theBand=1)
 Get an 100x100 pixmap of the color palette. More...
 
QString providerKey () const
 [ data provider interface ] Which provider is being used for this Raster Layer? More...
 
double rasterUnitsPerPixel ()
 Returns the number of raster units per each raster pixel. More...
 
bool readColorTable (int theBandNumber, QList< QgsColorRampShader::ColorRampItem > *theList)
 Read color table from GDAL raster band. More...
 
void resetNoDataValue ()
 Simple reset function that set the noDataValue back to the value stored in the first raster band. More...
 
void setBlueBandName (const QString &theBandName)
 Mutator for blue band name mapping. More...
 
void setColorShadingAlgorithm (QgsRasterLayer::ColorShadingAlgorithm theShaderAlgorithm)
 Mutator for color shader algorithm. More...
 
void setColorShadingAlgorithm (QString theShaderAlgorithm)
 Mutator for color shader algorithm. More...
 
void setContrastEnhancementAlgorithm (QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm, bool theGenerateLookupTableFlag=true)
 Mutator for contrast enhancement algorithm. More...
 
void setContrastEnhancementAlgorithm (QString theAlgorithm, bool theGenerateLookupTableFlag=true)
 Mutator for contrast enhancement algorithm. More...
 
void setContrastEnhancementFunction (QgsContrastEnhancementFunction *theFunction)
 Mutator for contrast enhancement function. More...
 
void setDrawingStyle (const QString &theDrawingStyleQString)
 Overloaded version of the above function for convenience when restoring from xml. More...
 
void setGrayBandName (const QString &theBandName)
 Mutator for gray band name mapping. More...
 
void setGreenBandName (const QString &theBandName)
 Mutator for green band name mapping. More...
 
void setMaximumValue (unsigned int theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the maximum value for contrast enhancement. More...
 
void setMaximumValue (QString theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the maximum value for contrast enhancement. More...
 
void setMinimumMaximumUsingLastExtent ()
 Sets the minimum and maximum values for the band(s) currently being displayed using the only pixel values from the last/current extent. More...
 
void setMinimumMaximumUsingDataset ()
 Sets the minimum and maximum values for the band(s) currently being displayed using the only pixel values from the dataset min/max. More...
 
void setMinimumValue (unsigned int theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the minimum value for contrast enhancement. More...
 
void setMinimumValue (QString theBand, double theValue, bool theGenerateLookupTableFlag=true)
 Mutator for setting the minimum value for contrast enhancement. More...
 
void setNoDataValue (double theNoData)
 Mutator that allows the NO_DATA entry for this raster to be overridden. More...
 
void setRasterShaderFunction (QgsRasterShaderFunction *theFunction)
 Set the raster shader function to a user defined function. More...
 
void setRedBandName (const QString &theBandName)
 Mutator for red band name (allows alternate mappings e.g. More...
 
void setTransparentBandName (const QString &theBandName)
 Mutator for transparent band name mapping. More...
 
void showProgress (int theValue)
 [ data provider interface ] A wrapper function to emit a progress update signal More...
 
QStringList subLayers () const
 Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS. More...
 
void thumbnailAsPixmap (QPixmap *theQPixmap)
 Draws a thumbnail of the rasterlayer into the supplied pixmap pointer. More...
 
void thumbnailAsImage (QImage *thepImage)
 Draws a thumbnail of the rasterlayer into the supplied QImage pointer. More...
 
void triggerRepaint ()
 Emit a signal asking for a repaint. More...
 
virtual void setLayerOrder (const QStringList &layers)
 Reorders the previously selected sublayers of this layer from bottom to top. More...
 
virtual void setSubLayerVisibility (const QString &name, bool vis)
 Set the visibility of the given sublayer name. More...
 
virtual QDateTime timestamp () const
 Time stamp of data source in the moment when data/metadata were loaded by provider. More...
 
- Public Member Functions inherited from QgsMapLayer
 QgsMapLayer (QgsMapLayer::LayerType type=VectorLayer, QString lyrname=QString::null, QString source=QString::null)
 Constructor. More...
 
virtual ~QgsMapLayer ()
 Destructor. More...
 
QgsMapLayer::LayerType type () const
 Get the type of the layer. More...
 
QString id () const
 Get this layer's unique ID, this ID is used to access this layer from map layer registry. More...
 
Q_DECL_DEPRECATED QString getLayerID () const
 Get this layer's unique ID, this ID is used to access this layer from map layer registry. More...
 
void setLayerName (const QString &name)
 Set the display name of the layer. More...
 
QString const & name () const
 Get the display name of the layer. More...
 
virtual void drawLabels (QgsRenderContext &rendererContext)
 Draw labels. More...
 
QgsRectangle extent () const
 Return the extent of the layer as a QRect. More...
 
bool isValid ()
 
QString publicSource () const
 
QString const & source () const
 Returns the source for the layer. More...
 
virtual QStringList subLayers ()
 Returns the sublayers of this layer (Useful for providers that manage their own layers, such as WMS) More...
 
virtual void setLayerOrder (QStringList layers)
 Reorders the previously selected sublayers of this layer from bottom to top (Useful for providers that manage their own layers, such as WMS) More...
 
virtual void setSubLayerVisibility (QString name, bool vis)
 Set the visibility of the given sublayer name. More...
 
bool readXML (QDomNode &layer_node)
 sets state from Dom document More...
 
bool writeXML (QDomNode &layer_node, QDomDocument &document)
 stores state in Dom node More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for layer. More...
 
QVariant customProperty (const QString &value, const QVariant &defaultValue=QVariant()) const
 Read a custom property from layer. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from layer. More...
 
unsigned int getTransparency ()
 Accessor for transparency level. More...
 
void setTransparency (unsigned int)
 Mutator for transparency level. More...
 
const
QgsCoordinateReferenceSystem
crs ()
 Returns layer's spatial reference system. More...
 
Q_DECL_DEPRECATED const
QgsCoordinateReferenceSystem
srs ()
 Returns layer's spatial reference system. More...
 
void setCrs (const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
 Sets layer's spatial reference system. More...
 
virtual QString loadDefaultStyle (bool &theResultFlag)
 Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QString loadNamedStyle (const QString theURI, bool &theResultFlag)
 Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual bool loadNamedStyleFromDb (const QString db, const QString theURI, QString &qml)
 
virtual QString saveDefaultStyle (bool &theResultFlag)
 Save the properties of this layer as the default style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QString saveNamedStyle (const QString theURI, bool &theResultFlag)
 Save the properties of this layer as a named style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
QUndoStack * undoStack ()
 Return pointer to layer's undo stack. More...
 
QImage * cacheImage ()
 Get the QImage used for caching render operations. More...
 
void setCacheImage (QImage *thepImage)
 Set the QImage used for caching render operations. More...
 

Static Public Member Functions

static void buildSupportedRasterFileFilter (QString &fileFilters)
 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. More...
 
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. More...
 
static bool isValidRasterFileName (const QString &theFileNameQString)
 
static QDateTime lastModified (const QString &name)
 Return time stamp for given file name. More...
 
static void registerGdalDrivers ()
 ensures that GDAL drivers are registered, but only once More...
 
static QLibrary * loadProviderLibrary (QString theProviderKey)
 
static QgsRasterDataProviderloadProvider (QString theProviderKey, QString theDataSource=0)
 
- Static Public Member Functions inherited from QgsMapLayer
static QString capitaliseLayerName (const QString name)
 A convenience function to capitalise the layer name. More...
 

Protected Member Functions

bool readSymbology (const QDomNode &node, QString &errorMessage)
 Read the symbology for the current layer from the Dom node supplied. More...
 
bool readXml (QDomNode &layer_node)
 Reads layer specific state from project file Dom node. More...
 
bool writeSymbology (QDomNode &, QDomDocument &doc, QString &errorMessage) const
 Write the symbology for the layer into the docment provided. More...
 
bool writeXml (QDomNode &layer_node, QDomDocument &doc)
 Write layer specific state to project file Dom node. More...
 
- Protected Member Functions inherited from QgsMapLayer
void setValid (bool valid)
 set whether layer is valid or not - should be used in constructor. More...
 
void readCustomProperties (const QDomNode &layerNode, const QString &keyStartsWith="")
 Read custom properties from project file. More...
 
void writeCustomProperties (QDomNode &layerNode, QDomDocument &doc) const
 Write custom properties to project file. More...
 
void connectNotify (const char *signal)
 debugging member - invoked when a connect() is made to this object More...
 

Private Member Functions

void drawSingleBandColorData (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for color type data. More...
 
void drawMultiBandColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel)
 Drawing routine for multiband image. More...
 
void drawMultiBandSingleBandGray (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for multiband image, rendered as a single band image in grayscale. More...
 
void drawMultiBandSingleBandPseudoColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for multiband image, rendered as a single band image in pseudocolor. More...
 
void drawPalettedSingleBandColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for single band with a color map. More...
 
void drawPalettedSingleBandGray (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for paletted image, rendered as a single band image in grayscale. More...
 
void drawPalettedSingleBandPseudoColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for paletted image, rendered as a single band image in pseudocolor. More...
 
void drawPalettedMultiBandColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for paletted multiband image. More...
 
void drawSingleBandGray (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for single band grayscale image. More...
 
void drawSingleBandPseudoColor (QPainter *theQPainter, QgsRasterViewPort *theRasterViewPort, const QgsMapToPixel *theQgsMapToPixel, int theBandNoInt)
 Drawing routine for single band grayscale image, rendered in pseudocolor. More...
 
void closeDataProvider ()
 Close data provider and clear related members. More...
 
QString generateBandName (int)
 helper function to create zero padded band names More...
 
bool hasBand (const QString &theBandName)
 Find out whether a given band exists. More...
 
QString projectionWkt ()
 Query GDAL to find out the Wkt projection string for this layer. More...
 
void * readData (int bandNo, QgsRasterViewPort *viewPort)
 Allocate memory and load data to that allocated memory. More...
 
bool readFile (const QString &fileName)
 Load the given raster file. More...
 
double readValue (void *data, int type, int index)
 Read a raster value given position from memory block created by readData() More...
 
bool update ()
 Update the layer if it is outdated. More...
 
QString validateBandName (const QString &theBandName)
 Verify and transform band name for internal consistency. More...
 

Private Attributes

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

Additional Inherited Members

- Protected Attributes inherited from QgsMapLayer
unsigned int mTransparencyLevel
 Transparency level for this layer should be 0-255 (255 being opaque) More...
 
QgsRectangle mLayerExtent
 Extent of the layer. More...
 
bool mValid
 Indicates if the layer is valid and can be drawn. More...
 
QString mDataSource
 data source description string, varies by layer type More...
 
QString mLayerName
 Name of the layer - used for display. More...
 
QgsCoordinateReferenceSystemmCRS
 layer's Spatial reference system More...
 

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 MultiBandSingleBandGray -> 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)
{
}
else if (rasterLayer->rasterType()==QgsRasterLayer::Palette)
{
}
else // QgsRasterLayer::GrayOrUndefined
{
}

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 169 of file qgsrasterlayer.h.

Member Typedef Documentation

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

Definition at line 249 of file qgsrasterlayer.h.

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 258 of file qgsrasterlayer.h.

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 263 of file qgsrasterlayer.h.

Member Enumeration Documentation

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

Enumerator
UndefinedShader 
PseudoColorShader 
FreakOutShader 
ColorRampShader 
UserDefinedShader 

Definition at line 212 of file qgsrasterlayer.h.

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

Enumerator
UndefinedDrawingStyle 
SingleBandGray 
SingleBandPseudoColor 
PalettedColor 
PalettedSingleBandGray 
PalettedSingleBandPseudoColor 
PalettedMultiBandColor 
MultiBandSingleGandGray 
MultiBandSingleBandGray 
MultiBandSingleBandPseudoColor 
MultiBandColor 
SingleBandColorDataStyle 

Definition at line 222 of file qgsrasterlayer.h.

This enumerator describes the type of raster layer.

Enumerator
GrayOrUndefined 
Palette 
Multiband 
ColorLayer 

Definition at line 240 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 84 of file qgsrasterlayer.cpp.

References init(), QgsMapLayer::loadDefaultStyle(), QgsMapLayer::mValid, QgsDebugMsg, and setDataProvider().

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

Todo:
Rename into a general constructor when the old raster interface is retired parameter dummy is just there to distinguish this function signature from the old non-provider one.

Definition at line 124 of file qgsrasterlayer.cpp.

References QgsMapLayer::crs(), init(), QgsDebugMsg, setDataProvider(), and QgsMapLayer::statusChanged().

QgsRasterLayer::~QgsRasterLayer ( )

The destructor.

Definition at line 175 of file qgsrasterlayer.cpp.

References mDataProvider, mRasterShader, and QgsMapLayer::mValid.

Member Function Documentation

unsigned int QgsRasterLayer::bandCount ( )
const QString QgsRasterLayer::bandName ( int  theBandNoInt)

Get the name of a band given its number.

Definition at line 276 of file qgsrasterlayer.cpp.

References mRasterStatsList.

Referenced by metadata(), readXml(), setDataProvider(), and validateBandName().

int QgsRasterLayer::bandNumber ( const QString &  theBandName)

Get the number of a band given its name.

The name is the rewritten name set up in the constructor, and will not necessarily be the same as the name retrieved directly from gdal! If no matching band is found zero will be returned!

Definition at line 289 of file qgsrasterlayer.cpp.

References QgsRasterBandStats::bandName, QgsRasterBandStats::bandNumber, mRasterStatsList, and QgsDebugMsg.

Referenced by computeMinimumMaximumEstimates(), computeMinimumMaximumFromLastExtent(), draw(), drawMultiBandColor(), drawPalettedSingleBandColor(), drawPalettedSingleBandGray(), drawPalettedSingleBandPseudoColor(), drawSingleBandGray(), drawSingleBandPseudoColor(), maximumValue(), minimumValue(), setMaximumValue(), setMinimumMaximumUsingDataset(), and setMinimumValue().

const QgsRasterBandStats QgsRasterLayer::bandStatistics ( int  theBandNo)

Get RasterBandStats for a band given its number (read only)

Private method to calculate statistics for a band.

Populates rasterStatsMemArray. Calculates:

  • myRasterBandStats.elementCount
  • myRasterBandStats.minimumValue
  • myRasterBandStats.maximumValue
  • myRasterBandStats.sum
  • myRasterBandStats.range
  • myRasterBandStats.mean
  • myRasterBandStats.sumOfSquares
  • myRasterBandStats.stdDev
  • myRasterBandStats.colorTable
See Also
RasterBandStats
Note
This is a cpu intensive and slow task!

Definition at line 330 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::bandCount(), QgsRasterBandStats::bandNumber, QgsRasterDataProvider::bandStatistics(), ColorLayer, QgsMapLayer::drawingProgress(), mDataProvider, mHeight, mRasterStatsList, mRasterType, Palette, QgsDebugMsg, and QgsRasterBandStats::statsGathered.

Referenced by bandStatistics(), drawMultiBandColor(), drawPalettedSingleBandPseudoColor(), drawSingleBandGray(), drawSingleBandPseudoColor(), metadata(), populateHistogram(), and setMinimumMaximumUsingDataset().

const QgsRasterBandStats QgsRasterLayer::bandStatistics ( const QString &  theBandName)
QString QgsRasterLayer::blueBandName ( ) const
inline

Accessor for blue band name mapping.

Definition at line 313 of file qgsrasterlayer.h.

Referenced by setMinimumMaximumUsingLastExtent(), and writeSymbology().

QgsRasterLayer::RasterPyramidList QgsRasterLayer::buildPyramidList ( )

Accessor for ths raster layers pyramid list.

A pyramid list defines the POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers ACTUALLY exists you need to look at the existsFlag member in each struct stored in the list.

Definition at line 408 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::buildPyramidList(), and mDataProvider.

QString QgsRasterLayer::buildPyramids ( const RasterPyramidList theRasterPyramidList,
const QString &  theResamplingMethod = "NEAREST",
bool  theTryInternalFlag = false 
)
slot

Create GDAL pyramid overviews.

Definition at line 401 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::buildPyramids(), and mDataProvider.

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 195 of file qgsrasterlayer.cpp.

References cast_to_fptr, loadProviderLibrary(), and QgsDebugMsg.

void QgsRasterLayer::closeDataProvider ( )
private

Close data provider and clear related members.

Definition at line 2391 of file qgsrasterlayer.cpp.

References mContrastEnhancementList, mDataProvider, mHasPyramids, mPyramidList, mRasterShader, mRasterStatsList, and QgsMapLayer::mValid.

Referenced by readXml(), and update().

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

Accessor for color shader algorithm.

Definition at line 316 of file qgsrasterlayer.h.

Referenced by writeSymbology().

QString QgsRasterLayer::colorShadingAlgorithmAsString ( ) const

Accessor for color shader algorithm.

Definition at line 413 of file qgsrasterlayer.cpp.

References ColorRampShader, FreakOutShader, mColorShadingAlgorithm, PseudoColorShader, and UserDefinedShader.

Referenced by writeSymbology().

QList< QgsColorRampShader::ColorRampItem > * QgsRasterLayer::colorTable ( int  theBandNo)

Get a pointer to the color table.

Parameters
theBandNothe band number
Returns
pointer to the color table

Definition at line 584 of file qgsrasterlayer.cpp.

References mRasterStatsList.

Referenced by setDataProvider().

void QgsRasterLayer::computeMinimumMaximumEstimates ( int  theBand,
double *  theMinMax 
)

Wrapper for GDALComputeRasterMinMax with the estimate option.

Parameters
theBandThe band (number) for which to estimate the min max values
theMinMaxPointer to a double[2] which hold the estimated min max

Definition at line 440 of file qgsrasterlayer.cpp.

References bandCount(), QgsRasterDataProvider::maximumValue(), mDataProvider, and QgsRasterDataProvider::minimumValue().

Referenced by computeMinimumMaximumEstimates().

void QgsRasterLayer::computeMinimumMaximumEstimates ( QString  theBand,
double *  theMinMax 
)

Wrapper for GDALComputeRasterMinMax with the estimate option.

Parameters
theBandThe band (name) for which to estimate the min max values
theMinMaxPointer to a double[2] which hold the estimated min max

Definition at line 455 of file qgsrasterlayer.cpp.

References bandNumber(), and computeMinimumMaximumEstimates().

void QgsRasterLayer::computeMinimumMaximumEstimates ( int  theBand,
double &  theMin,
double &  theMax 
)

Wrapper for GDALComputeRasterMinMax with the estimate option.

Note
added in v1.6

Definition at line 460 of file qgsrasterlayer.cpp.

References computeMinimumMaximumEstimates().

void QgsRasterLayer::computeMinimumMaximumFromLastExtent ( int  theBand,
double *  theMinMax 
)

Compute the actual minimum maximum pixel values based on the current (last) display extent.

Parameters
theBandThe band (number) for which to calculate the min max values
theMinMaxPointer to a double[2] which hold the estimated min max

Definition at line 472 of file qgsrasterlayer.cpp.

References bandCount(), QgsRasterDataProvider::dataType(), QgsRasterViewPort::drawableAreaXDim, QgsRasterViewPort::drawableAreaYDim, MathUtils::max(), mDataProvider, mLastViewPort, mNoDataValue, mValidNoDataValue, readData(), readValue(), and TINY_VALUE.

Referenced by computeMinimumMaximumFromLastExtent(), and setMinimumMaximumUsingLastExtent().

void QgsRasterLayer::computeMinimumMaximumFromLastExtent ( QString  theBand,
double *  theMinMax 
)

Compute the actual minimum maximum pixel values based on the current (last) display extent.

Parameters
theBandThe band (name) for which to calculate the min max values
theMinMaxPointer to a double[2] which hold the estimated min max

Definition at line 515 of file qgsrasterlayer.cpp.

References bandNumber(), and computeMinimumMaximumFromLastExtent().

void QgsRasterLayer::computeMinimumMaximumFromLastExtent ( int  theBand,
double &  theMin,
double &  theMax 
)

Compute the actual minimum maximum pixel values based on the current (last) display extent.

Note
added in v1.6

Definition at line 520 of file qgsrasterlayer.cpp.

References computeMinimumMaximumFromLastExtent().

QgsContrastEnhancement * QgsRasterLayer::contrastEnhancement ( unsigned int  theBand)

Get a pointer to the contrast enhancement for the selected band.

Parameters
theBandThe band (number) for which to get the contrast enhancement for
Returns
Pointer to the contrast enhancement or 0 on failure

Definition at line 532 of file qgsrasterlayer.cpp.

References bandCount(), and mContrastEnhancementList.

Referenced by drawMultiBandColor(), and drawSingleBandGray().

QgsContrastEnhancement::ContrastEnhancementAlgorithm QgsRasterLayer::contrastEnhancementAlgorithm ( )
inline

Accessor for contrast enhancement algorithm.

Definition at line 319 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), and drawSingleBandGray().

QString QgsRasterLayer::contrastEnhancementAlgorithmAsString ( ) const
bool QgsRasterLayer::copySymbologySettings ( const QgsMapLayer theOther)
virtual

Copies the symbology settings from another layer.

Returns true in case of success

Note
Note implemented yet
Returns
always returns false

Implements QgsMapLayer.

Definition at line 570 of file qgsrasterlayer.cpp.

References QgsMapLayer::type().

void QgsRasterLayer::dataChanged ( )
signal

This is emitted whenever data or metadata (e.g.

color table, extent) has changed

Note
added in 1.7

Referenced by update().

QgsRasterDataProvider * QgsRasterLayer::dataProvider ( )

Returns the data provider.

Returns
0 if not using the data provider model (i.e. directly using GDAL)

Definition at line 592 of file qgsrasterlayer.cpp.

References mDataProvider.

Referenced by QgsComposerMap::containsWMSLayer().

const QgsRasterDataProvider * QgsRasterLayer::dataProvider ( ) const

Returns the data provider in a const-correct manner.

Returns
0 if not using the data provider model (i.e. directly using GDAL)

Definition at line 600 of file qgsrasterlayer.cpp.

References mDataProvider.

bool QgsRasterLayer::draw ( QgsRenderContext rendererContext)
virtual
void QgsRasterLayer::draw ( QPainter *  theQPainter,
QgsRasterViewPort myRasterViewPort,
const QgsMapToPixel theQgsMapToPixel = 0 
)
DrawingStyle QgsRasterLayer::drawingStyle ( )
inline

Accessor for drawing style.

Definition at line 325 of file qgsrasterlayer.h.

Referenced by setMinimumMaximumUsingDataset(), and setMinimumMaximumUsingLastExtent().

QString QgsRasterLayer::drawingStyleAsString ( ) const

Returns a string representation of drawing style.

Implemented mainly for serialisation / deserialisation of settings to xml. NOTE: May be deprecated in the future!. DrawingStyle drawingStyle() instead.

Definition at line 932 of file qgsrasterlayer.cpp.

References mDrawingStyle, MultiBandColor, MultiBandSingleBandGray, MultiBandSingleBandPseudoColor, PalettedColor, PalettedMultiBandColor, PalettedSingleBandGray, PalettedSingleBandPseudoColor, SingleBandColorDataStyle, SingleBandGray, and SingleBandPseudoColor.

Referenced by legendAsPixmap(), readSymbology(), and writeSymbology().

void QgsRasterLayer::drawMultiBandColor ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel 
)
private
void QgsRasterLayer::drawMultiBandSingleBandGray ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNoInt 
)
private

Drawing routine for multiband image, rendered as a single band image in grayscale.

Definition at line 3762 of file qgsrasterlayer.cpp.

References drawSingleBandGray().

Referenced by draw().

void QgsRasterLayer::drawMultiBandSingleBandPseudoColor ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNoInt 
)
private

Drawing routine for multiband image, rendered as a single band image in pseudocolor.

Definition at line 3769 of file qgsrasterlayer.cpp.

References drawSingleBandPseudoColor().

Referenced by draw().

void QgsRasterLayer::drawPalettedMultiBandColor ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNo 
)
private

Drawing routine for paletted multiband image.

This method is used to render a paletted raster layer as a color image – currently not supported.

Parameters
theQPainterpointer to the QPainter onto which the layer should be drawn.
theRasterViewPortpointer to the ViewPort struct containing dimensions of viewable area and subset area to be extracted from data file.
theQgsMapToPixeltransformation coordinate to map canvas pixel
theBandNothe number of the band which should be rendered.
Note
not supported at this time

Definition at line 4137 of file qgsrasterlayer.cpp.

References QgsDebugMsg.

Referenced by draw().

void QgsRasterLayer::drawPalettedSingleBandColor ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNo 
)
private

Drawing routine for single band with a color map.

This method is used to render a single band with a color map.

Parameters
theQPainterpointer to the QPainter onto which the layer should be drawn.
theRasterViewPortpointer to the ViewPort struct containing dimensions of viewable area and subset area to be extracted from data file.
theQgsMapToPixeltransformation coordinate to map canvas pixel
theBandNoband number

Definition at line 3783 of file qgsrasterlayer.cpp.

References QgsRasterTransparency::alphaValue(), bandNumber(), QgsRasterDataProvider::dataType(), QgsRasterViewPort::drawableAreaXDim, mDataProvider, mGeoTransform, mInvertColor, mNoDataValue, mRasterShader, mRasterTransparency, mTransparencyBandName, QgsMapLayer::mTransparencyLevel, mValidNoDataValue, QgsRasterImageBuffer::nextScanLine(), QgsDebugMsg, readValue(), QgsRasterImageBuffer::reset(), QgsRasterImageBuffer::setWritingEnabled(), QgsRasterShader::shade(), and TINY_VALUE.

Referenced by draw().

void QgsRasterLayer::drawPalettedSingleBandGray ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNo 
)
private

Drawing routine for paletted image, rendered as a single band image in grayscale.

This method is used to render a paletted raster layer as a gray image.

Parameters
theQPainterpointer to the QPainter onto which the layer should be drawn.
theRasterViewPortpointer to the ViewPort struct containing dimensions of viewable area and subset area to be extracted from data file.
theQgsMapToPixeltransformation between map coordinates and canvas pixels
theBandNoband number

Definition at line 3895 of file qgsrasterlayer.cpp.

References QgsRasterTransparency::alphaValue(), bandNumber(), QgsRasterDataProvider::dataType(), QgsRasterViewPort::drawableAreaXDim, mDataProvider, mGeoTransform, mInvertColor, mNoDataValue, mRasterShader, mRasterTransparency, mTransparencyBandName, QgsMapLayer::mTransparencyLevel, mValidNoDataValue, QgsRasterImageBuffer::nextScanLine(), QgsDebugMsg, readValue(), QgsRasterImageBuffer::reset(), QgsRasterImageBuffer::setWritingEnabled(), QgsRasterShader::shade(), and TINY_VALUE.

Referenced by draw().

void QgsRasterLayer::drawPalettedSingleBandPseudoColor ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNo 
)
private

Drawing routine for paletted image, rendered as a single band image in pseudocolor.

This method is used to render a paletted raster layer as a pseudocolor image.

Parameters
theQPainter- pointer to the QPainter onto which the layer should be drawn.
theRasterViewPort- pointer to the ViewPort struct containing dimensions of viewable area and subset area to be extracted from data file.
theQgsMapToPixeltransformation between map coordinates and canvas pixels
theBandNoband number gray.

Definition at line 4010 of file qgsrasterlayer.cpp.

References QgsRasterTransparency::alphaValue(), bandNumber(), bandStatistics(), QgsRasterDataProvider::dataType(), QgsRasterViewPort::drawableAreaXDim, QgsRasterBandStats::maximumValue, mDataProvider, QgsRasterBandStats::mean, mGeoTransform, QgsRasterBandStats::minimumValue, mInvertColor, mNoDataValue, mRasterShader, mRasterTransparency, mStandardDeviations, mTransparencyBandName, QgsMapLayer::mTransparencyLevel, mValidNoDataValue, QgsRasterImageBuffer::nextScanLine(), QgsDebugMsg, readValue(), QgsRasterImageBuffer::reset(), QgsRasterShader::setMaximumValue(), QgsRasterShader::setMinimumValue(), QgsRasterImageBuffer::setWritingEnabled(), QgsRasterShader::shade(), QgsRasterBandStats::stdDev, and TINY_VALUE.

Referenced by draw().

void QgsRasterLayer::drawSingleBandColorData ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNoInt 
)
private
void QgsRasterLayer::drawSingleBandGray ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNoInt 
)
private
void QgsRasterLayer::drawSingleBandPseudoColor ( QPainter *  theQPainter,
QgsRasterViewPort theRasterViewPort,
const QgsMapToPixel theQgsMapToPixel,
int  theBandNoInt 
)
private
QString QgsRasterLayer::generateBandName ( int  )
private

helper function to create zero padded band names

QString QgsRasterLayer::grayBandName ( ) const
inline

Accessor for gray band name mapping.

Definition at line 328 of file qgsrasterlayer.h.

Referenced by setMinimumMaximumUsingDataset(), setMinimumMaximumUsingLastExtent(), and writeSymbology().

QString QgsRasterLayer::greenBandName ( ) const
inline

Accessor for green band name mapping.

Definition at line 331 of file qgsrasterlayer.h.

Referenced by setMinimumMaximumUsingDataset(), setMinimumMaximumUsingLastExtent(), and writeSymbology().

bool QgsRasterLayer::hasBand ( const QString &  theBandName)
private

Find out whether a given band exists.

This method looks to see if a given band name exists.

Note
This function is no longer really needed and about to be removed

Definition at line 4396 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::bandCount(), QgsRasterDataProvider::colorInterpretationName(), QgsLogger::debug(), mDataProvider, QgsDebugMsg, and QgsDebugMsgLevel.

Referenced by paletteAsPixmap().

bool QgsRasterLayer::hasCompatibleSymbology ( const QgsMapLayer theOther) const
virtual

Checks if symbology is the same as another layers.

Note
Not implemented yet
Returns
always returns false

Implements QgsMapLayer.

Definition at line 978 of file qgsrasterlayer.cpp.

References QgsMapLayer::type().

bool QgsRasterLayer::hasPyramids ( )
inline

Accessor for mHasPyramids (READ ONLY)

Definition at line 334 of file qgsrasterlayer.h.

bool QgsRasterLayer::hasStatistics ( int  theBandNo)

Check whether a given band number has stats associated with it.

Parameters
theBandNoThe number of the band to check
Returns
true if statistics have already been build for this band otherwise false

Definition at line 992 of file qgsrasterlayer.cpp.

References mRasterStatsList.

Referenced by metadata().

bool QgsRasterLayer::hasUserDefinedGrayMinimumMaximum ( ) const
inline

Accessor for mUserDefinedGrayMinimumMaximum.

Definition at line 337 of file qgsrasterlayer.h.

Referenced by writeSymbology().

bool QgsRasterLayer::hasUserDefinedRGBMinimumMaximum ( ) const
inline

Accessor for mUserDefinedRGBMinimumMaximum.

Definition at line 340 of file qgsrasterlayer.h.

Referenced by writeSymbology().

int QgsRasterLayer::height ( )
inline

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

Definition at line 343 of file qgsrasterlayer.h.

bool QgsRasterLayer::identify ( const QgsPoint thePoint,
QMap< QString, QString > &  theResults 
)

Identify raster value(s) found on the point position.

Parameters
thePointthe QgsPoint for which to obtain pixel values
theResultsQMap to hold the pixel values at thePoint for each layer in the raster file
Returns
False if WMS layer and true otherwise

Definition at line 1010 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::identify(), mDataProvider, mProviderKey, and QgsDebugMsg.

QString QgsRasterLayer::identifyAsHtml ( const QgsPoint thePoint)

Identify arbitrary details from the WMS server found on the point position.

Note
added in 1.5
The arbitraryness of the returned document is enforced by WMS standards up to at least v1.3.0
Parameters
thePointan image pixel coordinate in the last requested extent of layer.
Returns
A html document containing the return from the WMS server

Definition at line 1041 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::identifyAsHtml(), mDataProvider, and mProviderKey.

QString QgsRasterLayer::identifyAsText ( const QgsPoint thePoint)

Identify arbitrary details from the WMS server found on the point position.

Note
The arbitraryness of the returned document is enforced by WMS standards up to at least v1.3.0
Parameters
thePointan image pixel coordinate in the last requested extent of layer.
Returns
A text document containing the return from the WMS server

Definition at line 1024 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::identifyAsText(), mDataProvider, and mProviderKey.

void QgsRasterLayer::init ( )
bool QgsRasterLayer::invertHistogram ( ) const
inline

Accessor to find out whether the histogram should be inverted.

Definition at line 346 of file qgsrasterlayer.h.

Referenced by writeSymbology().

bool QgsRasterLayer::isEditable ( ) const
virtual

Currently returns always false.

Note
Note implemented yet
Returns
Always returns false

Reimplemented from QgsMapLayer.

Definition at line 1056 of file qgsrasterlayer.cpp.

bool QgsRasterLayer::isGrayMinimumMaximumEstimated ( ) const
inline

Accessor for mGrayMinimumMaximumEstimated.

Definition at line 352 of file qgsrasterlayer.h.

Referenced by writeSymbology().

bool QgsRasterLayer::isNoDataValueValid ( ) const
inline

Is the NoDataValue Valid.

Definition at line 349 of file qgsrasterlayer.h.

bool QgsRasterLayer::isRGBMinimumMaximumEstimated ( ) const
inline

Accessor for mRGBMinimumMaximumEstimated.

Definition at line 355 of file qgsrasterlayer.h.

Referenced by writeSymbology().

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 218 of file qgsrasterlayer.cpp.

References cast_to_fptr, loadProviderLibrary(), and QgsDebugMsg.

Referenced by isValidRasterFileName().

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

Definition at line 239 of file qgsrasterlayer.cpp.

References isValidRasterFileName().

QString QgsRasterLayer::lastError ( )
virtual

[ data provider interface ] If an operation returns 0 (e.g.

draw()), this function returns the text of the error associated with the failure

Reimplemented from QgsMapLayer.

Definition at line 1061 of file qgsrasterlayer.cpp.

References mError.

QString QgsRasterLayer::lastErrorTitle ( )
virtual

[ data provider interface ] If an operation returns 0 (e.g.

draw()), this function returns the text of the error associated with the failure

Reimplemented from QgsMapLayer.

Definition at line 1066 of file qgsrasterlayer.cpp.

References mErrorCaption.

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

Return time stamp for given file name.

Definition at line 245 of file qgsrasterlayer.cpp.

References QgsDebugMsg.

Referenced by setDataProvider().

QPixmap QgsRasterLayer::legendAsPixmap ( )

Get a legend image for this layer.

This is an overloaded version of the legendAsPixmap( bool ) assumes false for the legend name flag.

Returns
a pixmap representing a legend image

Definition at line 1075 of file qgsrasterlayer.cpp.

Referenced by QgsLegendModel::addRasterLayerItem().

QPixmap QgsRasterLayer::legendAsPixmap ( bool  theWithNameFlag)

Overloaded version of above function that can print layer name onto legend.

Parameters
theWithNameFlag- boolena flag whether to overlay the legend name in the text
Returns
a pixmap representing a legend image

Definition at line 1084 of file qgsrasterlayer.cpp.

References QgsApplication::activeThemePath(), QgsRasterDataProvider::colorInterpretationName(), drawingStyleAsString(), FreakOutShader, mColorShadingAlgorithm, mDataProvider, mDrawingStyle, mHasPyramids, mInvertColor, mProviderKey, MultiBandColor, MultiBandSingleBandGray, MultiBandSingleBandPseudoColor, QgsMapLayer::name(), PalettedColor, PalettedMultiBandColor, PalettedSingleBandGray, PalettedSingleBandPseudoColor, QgsDebugMsg, SingleBandGray, and SingleBandPseudoColor.

QPixmap QgsRasterLayer::legendAsPixmap ( int  theLabelCount)

Use this method when you want an annotated legend suitable for print output etc.

Parameters
theLabelCountnumber of vertical labels to display
Returns
a pixmap representing a legend image

Definition at line 1352 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::colorInterpretationName(), FreakOutShader, mColorShadingAlgorithm, mDataProvider, mDrawingStyle, mInvertColor, MultiBandColor, MultiBandSingleBandGray, MultiBandSingleBandPseudoColor, QgsMapLayer::name(), PalettedMultiBandColor, PalettedSingleBandGray, PalettedSingleBandPseudoColor, QgsDebugMsg, SingleBandGray, and SingleBandPseudoColor.

QgsRasterDataProvider * QgsRasterLayer::loadProvider ( QString  theProviderKey,
QString  theDataSource = 0 
)
static

Definition at line 2064 of file qgsrasterlayer.cpp.

References cast_to_fptr, loadProviderLibrary(), QgsDebugMsg, and QgsLogger::warning().

Referenced by setDataProvider().

QLibrary * QgsRasterLayer::loadProviderLibrary ( QString  theProviderKey)
static
double QgsRasterLayer::maximumValue ( unsigned int  theBand)

Accessor for maximum value user for contrast enhancement.

Parameters
theBandthe band number for which to get the maximum pixel value
Returns
the maximum pixel value

Definition at line 1582 of file qgsrasterlayer.cpp.

References bandCount(), and mContrastEnhancementList.

Referenced by maximumValue().

double QgsRasterLayer::maximumValue ( QString  theBand)

Accessor for maximum value user for contrast enhancement.

Parameters
theBandthe band name for which to get the maximum pixel value
Returns
the maximum pixel value

Definition at line 1596 of file qgsrasterlayer.cpp.

References bandNumber(), and maximumValue().

QString QgsRasterLayer::metadata ( )
double QgsRasterLayer::minimumValue ( unsigned int  theBand)

Accessor for minimum value user for contrast enhancement.

Parameters
theBandthe band number for which to get the minimum pixel value
Returns
the minimum pixel value

Definition at line 1824 of file qgsrasterlayer.cpp.

References bandCount(), and mContrastEnhancementList.

Referenced by minimumValue().

double QgsRasterLayer::minimumValue ( QString  theBand)

Accessor for minimum value user for contrast enhancement.

Parameters
theBandthe band name for which to get the minimum pixel value
Returns
the minimum pixel value

Definition at line 1838 of file qgsrasterlayer.cpp.

References bandNumber(), and minimumValue().

double QgsRasterLayer::noDataValue ( bool *  isValid = 0)
inline

Accessor that returns the NO_DATA entry for this raster.

Definition at line 358 of file qgsrasterlayer.h.

void QgsRasterLayer::onProgress ( int  theType,
double  theProgress,
QString  theMesssage 
)
slot

recieve progress signal from provider

Definition at line 2851 of file qgsrasterlayer.cpp.

References progressUpdate(), and QgsDebugMsg.

Referenced by setDataProvider().

QPixmap QgsRasterLayer::paletteAsPixmap ( int  theBandNumber = 1)

Get an 100x100 pixmap of the color palette.

If the layer has no palette a white pixmap will be returned

Parameters
theBandNumberthe number of the band to use for generating a pixmap of the associated palette
Returns
a 100x100 pixel QPixmap of the bands palette

Definition at line 1847 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::colorTable(), QgsColorRampShader::DISCRETE, hasBand(), mDataProvider, mProviderKey, QgsDebugMsg, QgsColorRampShader::setColorRampItemList(), QgsColorRampShader::setColorRampType(), and QgsColorRampShader::shade().

void QgsRasterLayer::populateHistogram ( int  theBandNoInt,
int  theBinCountInt = 256,
bool  theIgnoreOutOfRangeFlag = true,
bool  theThoroughBandScanFlag = false 
)
slot

Populate the histogram vector for a given band.

Definition at line 1911 of file qgsrasterlayer.cpp.

References bandStatistics(), mDataProvider, and QgsRasterDataProvider::populateHistogram().

void QgsRasterLayer::progressUpdate ( int  theValue)
signal

Signal for notifying listeners of long running processes.

Referenced by onProgress(), and showProgress().

QString QgsRasterLayer::projectionWkt ( )
private

Query GDAL to find out the Wkt projection string for this layer.

Definition at line 4422 of file qgsrasterlayer.cpp.

References QgsDataProvider::crs(), mDataProvider, and QgsCoordinateReferenceSystem::toWkt().

QString QgsRasterLayer::providerKey ( ) const

[ data provider interface ] Which provider is being used for this Raster Layer?

Definition at line 1917 of file qgsrasterlayer.cpp.

References mProviderKey.

QgsRasterShader* QgsRasterLayer::rasterShader ( )
inline

Accessor for raster shader.

Definition at line 364 of file qgsrasterlayer.h.

QgsRasterTransparency* QgsRasterLayer::rasterTransparency ( )
inline

Returns a pointer to the transparency object.

Definition at line 361 of file qgsrasterlayer.h.

LayerType QgsRasterLayer::rasterType ( )
inline

Accessor for raster layer type (which is a read only property)

Definition at line 367 of file qgsrasterlayer.h.

Referenced by setMinimumMaximumUsingDataset(), and setMinimumMaximumUsingLastExtent().

double QgsRasterLayer::rasterUnitsPerPixel ( )

Returns the number of raster units per each raster pixel.

In a world file, this is normally the first row (without the sign)

Returns
the horizontal units per pixel as reported in the GDAL geotramsform[1]

Definition at line 1932 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::capabilities(), QgsRasterDataProvider::ExactResolution, QgsDataProvider::extent(), mDataProvider, QgsRectangle::width(), and QgsRasterDataProvider::xSize().

bool QgsRasterLayer::readColorTable ( int  theBandNumber,
QList< QgsColorRampShader::ColorRampItem > *  theList 
)

Read color table from GDAL raster band.

Definition at line 4947 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::colorTable(), and mDataProvider.

void * QgsRasterLayer::readData ( int  bandNo,
QgsRasterViewPort viewPort 
)
private
bool QgsRasterLayer::readFile ( const QString &  fileName)
private

Load the given raster file.

Definition at line 4472 of file qgsrasterlayer.cpp.

References QgsMapLayer::mValid.

bool QgsRasterLayer::readSymbology ( const QDomNode &  node,
QString &  errorMessage 
)
protectedvirtual
double QgsRasterLayer::readValue ( void *  data,
int  type,
int  index 
)
inlineprivate
bool QgsRasterLayer::readXml ( QDomNode &  layer_node)
protectedvirtual

Reads layer specific state from project file Dom node.

Raster layer project file XML of form:

<maplayer type="raster" visible="1" showInOverviewFlag="1">
<layername>Wynoochee_dem</layername>
<datasource>/home/mcoletti/mnt/MCOLETTIF8F9/c/Toolkit_Course/Answers/Training_Data/wynoochee_dem.img</datasource>
<zorder>0</zorder>
<transparencyLevelInt>255</transparencyLevelInt>
<rasterproperties>
<mDrawingStyle>SingleBandGray</mDrawingStyle>
<mInvertColor boolean="false"/>
<mStandardDeviations>0</mStandardDeviations>
<mRedBandName>Not Set</mRedBandName>
<mGreenBandName>Not Set</mGreenBandName>
<mBlueBandName>Not Set</mBlueBandName>
<mGrayBandName>Undefined</mGrayBandName>
</rasterproperties>
</maplayer>
Note
Called by QgsMapLayer::readXML().
Note
Make sure to read the file first so stats etc are initialised properly!

Reimplemented from QgsMapLayer.

Definition at line 3084 of file qgsrasterlayer.cpp.

References QgsCoordinateReferenceSystem::authid(), bandName(), closeDataProvider(), QgsMapLayer::crs(), init(), mBlueBandName, mCrs, mDrawingStyle, mFormat, mGrayBandName, mGreenBandName, mLayers, mProviderKey, mRedBandName, mStyles, MultiBandColor, QgsDebugMsg, readSymbology(), setDataProvider(), SingleBandColorDataStyle, and TRSTRING_NOT_SET.

QString QgsRasterLayer::redBandName ( ) const
inline

Accessor for red band name (allows alternate mappings e.g.

map blue as red color)

Definition at line 370 of file qgsrasterlayer.h.

Referenced by setMinimumMaximumUsingDataset(), setMinimumMaximumUsingLastExtent(), and writeSymbology().

void QgsRasterLayer::registerGdalDrivers ( )
static

ensures that GDAL drivers are registered, but only once

Definition at line 4940 of file qgsrasterlayer.cpp.

void QgsRasterLayer::reload ( )
virtual

Synchronises with changes in the datasource.

Note
added in version 1.6

Reimplemented from QgsMapLayer.

Definition at line 605 of file qgsrasterlayer.cpp.

References mDataProvider, and QgsDataProvider::reloadData().

void QgsRasterLayer::resetNoDataValue ( )

Simple reset function that set the noDataValue back to the value stored in the first raster band.

Definition at line 1949 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::bandCount(), QgsRasterDataProvider::isNoDataValueValid(), MathUtils::max(), mDataProvider, mNoDataValue, mValidNoDataValue, QgsRasterDataProvider::noDataValue(), and setNoDataValue().

void QgsRasterLayer::setBlueBandName ( const QString &  theBandName)

Mutator for blue band name mapping.

Definition at line 1978 of file qgsrasterlayer.cpp.

References mBlueBandName, and validateBandName().

Referenced by readSymbology().

void QgsRasterLayer::setColorShadingAlgorithm ( QgsRasterLayer::ColorShadingAlgorithm  theShaderAlgorithm)
void QgsRasterLayer::setColorShadingAlgorithm ( QString  theShaderAlgorithm)

Mutator for color shader algorithm.

Definition at line 2441 of file qgsrasterlayer.cpp.

References ColorRampShader, FreakOutShader, PseudoColorShader, QgsDebugMsg, setColorShadingAlgorithm(), UndefinedShader, and UserDefinedShader.

void QgsRasterLayer::setContrastEnhancementAlgorithm ( QgsContrastEnhancement::ContrastEnhancementAlgorithm  theAlgorithm,
bool  theGenerateLookupTableFlag = true 
)

Mutator for contrast enhancement algorithm.

Definition at line 2457 of file qgsrasterlayer.cpp.

References mContrastEnhancementAlgorithm, and mContrastEnhancementList.

Referenced by readSymbology(), setContrastEnhancementAlgorithm(), and setDataProvider().

void QgsRasterLayer::setContrastEnhancementAlgorithm ( QString  theAlgorithm,
bool  theGenerateLookupTableFlag = true 
)
void QgsRasterLayer::setContrastEnhancementFunction ( QgsContrastEnhancementFunction theFunction)

Mutator for contrast enhancement function.

Definition at line 2498 of file qgsrasterlayer.cpp.

References mContrastEnhancementList.

void QgsRasterLayer::setDataProvider ( const QString &  provider,
const QStringList &  layers,
const QStringList &  styles,
const QString &  format,
const QString &  crs 
)

Definition at line 2101 of file qgsrasterlayer.cpp.

Referenced by QgsRasterLayer(), readXml(), and update().

void QgsRasterLayer::setDataProvider ( const QString &  provider,
const QStringList &  layers,
const QStringList &  styles,
const QString &  format,
const QString &  crs,
bool  loadDefaultStyleFlag 
)

[ data provider interface ] Set the data provider

Copied from QgsVectorLayer::setDataProvider TODO: Make it work in the raster environment.

Definition at line 2113 of file qgsrasterlayer.cpp.

References QgsRasterDataProvider::addLayers(), QgsRasterDataProvider::ARGBDataType, QgsRasterDataProvider::bandCount(), QgsRasterBandStats::bandName, bandName(), QgsRasterBandStats::bandNumber, QgsRasterDataProvider::capabilities(), QgsRasterDataProvider::colorInterpretation(), ColorLayer, ColorRampShader, QgsRasterBandStats::colorTable, QgsRasterDataProvider::colorTable(), colorTable(), QgsCoordinateReferenceSystem::createFromOgcWmsCrs(), QgsDataProvider::crs(), QgsMapLayer::crs(), QgsRasterDataProvider::dataType(), QgsRasterDataProvider::ExactMinimumMaximum, QgsDataProvider::extent(), QgsRasterDataProvider::generateBandName(), GrayOrUndefined, QgsRasterBandStats::histogramVector, QgsRasterTransparency::initializeTransparentPixelList(), QgsColorRampShader::INTERPOLATED, QgsRasterDataProvider::isNoDataValueValid(), QgsDataProvider::isValid(), QgsCoordinateReferenceSystem::isValid(), lastModified(), loadProvider(), QgsRasterDataProvider::maximumValue(), mBandCount, mBlueBandName, mContrastEnhancementAlgorithm, mContrastEnhancementList, QgsMapLayer::mCRS, mDataProvider, QgsMapLayer::mDataSource, mDrawingStyle, mGrayBandName, mGreenBandName, mHeight, QgsRasterDataProvider::minimumValue(), mLastModified, QgsMapLayer::mLayerExtent, QgsMapLayer::mLayerName, mNoDataValue, mProviderKey, mRasterShader, mRasterStatsList, mRasterTransparency, mRasterType, mRedBandName, mTransparencyBandName, Multiband, MultiBandColor, QgsMapLayer::mValid, mValidNoDataValue, mWidth, QgsMapLayer::name(), QgsRasterDataProvider::noDataValue(), onProgress(), Palette, PalettedColor, QgsRasterDataProvider::PaletteIndex, QgsDebugMsg, QgsRasterShader::rasterShaderFunction(), QgsColorRampShader::setColorRampItemList(), QgsColorRampShader::setColorRampType(), setColorShadingAlgorithm(), setContrastEnhancementAlgorithm(), QgsRasterDataProvider::setImageCrs(), QgsRasterDataProvider::setImageEncoding(), QgsMapLayer::setLayerName(), setMaximumValue(), setMinimumValue(), setNoDataValue(), setStandardDeviations(), QgsCoordinateReferenceSystem::setValidationHint(), QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), SingleBandColorDataStyle, SingleBandGray, QgsRasterDataProvider::srcDataType(), QgsRasterBandStats::statsGathered, QgsMapLayer::statusChanged(), QgsContrastEnhancement::StretchToMinimumMaximum, QgsRectangle::toString(), QgsCoordinateReferenceSystem::toWkt(), TRSTRING_NOT_SET, QgsCoordinateReferenceSystem::validate(), QgsLogger::warning(), QgsRasterDataProvider::xSize(), and QgsRasterDataProvider::ySize().

void QgsRasterLayer::setDrawingStyle ( const DrawingStyle theDrawingStyle)
inline

Mutator for drawing style.

Definition at line 374 of file qgsrasterlayer.h.

Referenced by readSymbology().

void QgsRasterLayer::setDrawingStyle ( const QString &  theDrawingStyleQString)

Overloaded version of the above function for convenience when restoring from xml.

Implemented mainly for serialisation / deserialisation of settings to xml.

Note
May be deprecated in the future! Use setDrawingStyle( DrawingStyle ) instead.

Definition at line 2516 of file qgsrasterlayer.cpp.

References mDrawingStyle, MultiBandColor, MultiBandSingleBandGray, MultiBandSingleBandPseudoColor, PalettedColor, PalettedMultiBandColor, PalettedSingleBandGray, PalettedSingleBandPseudoColor, QgsDebugMsg, SingleBandColorDataStyle, SingleBandGray, SingleBandPseudoColor, and UndefinedDrawingStyle.

void QgsRasterLayer::setGrayBandName ( const QString &  theBandName)

Mutator for gray band name mapping.

Definition at line 2567 of file qgsrasterlayer.cpp.

References mGrayBandName, and validateBandName().

Referenced by readSymbology().

void QgsRasterLayer::setGrayMinimumMaximumEstimated ( bool  theBool)
inline

Mutator for mGrayMinimumMaximumEstimated.

Definition at line 377 of file qgsrasterlayer.h.

Referenced by readSymbology().

void QgsRasterLayer::setGreenBandName ( const QString &  theBandName)

Mutator for green band name mapping.

Definition at line 2572 of file qgsrasterlayer.cpp.

References mGreenBandName, and validateBandName().

Referenced by readSymbology().

void QgsRasterLayer::setInvertHistogram ( bool  theFlag)
inline

Mutator to alter the state of the invert histogram flag.

Definition at line 380 of file qgsrasterlayer.h.

Referenced by readSymbology().

void QgsRasterLayer::setLayerOrder ( const QStringList &  layers)
virtual

Reorders the previously selected sublayers of this layer from bottom to top.

(Useful for providers that manage their own layers, such as WMS)

Definition at line 2577 of file qgsrasterlayer.cpp.

References mDataProvider, QgsDebugMsg, and QgsDataProvider::setLayerOrder().

void QgsRasterLayer::setMaximumValue ( unsigned int  theBand,
double  theValue,
bool  theGenerateLookupTableFlag = true 
)

Mutator for setting the maximum value for contrast enhancement.

Definition at line 2589 of file qgsrasterlayer.cpp.

References bandCount(), mContrastEnhancementList, and QgsDebugMsg.

Referenced by drawMultiBandColor(), drawSingleBandGray(), readSymbology(), setDataProvider(), setMaximumValue(), setMinimumMaximumUsingDataset(), and setMinimumMaximumUsingLastExtent().

void QgsRasterLayer::setMaximumValue ( QString  theBand,
double  theValue,
bool  theGenerateLookupTableFlag = true 
)

Mutator for setting the maximum value for contrast enhancement.

Definition at line 2598 of file qgsrasterlayer.cpp.

References bandNumber(), and setMaximumValue().

void QgsRasterLayer::setMinimumMaximumUsingDataset ( )
void QgsRasterLayer::setMinimumMaximumUsingLastExtent ( )

Sets the minimum and maximum values for the band(s) currently being displayed using the only pixel values from the last/current extent.

Definition at line 2606 of file qgsrasterlayer.cpp.

References blueBandName(), computeMinimumMaximumFromLastExtent(), drawingStyle(), grayBandName(), GrayOrUndefined, greenBandName(), Multiband, MultiBandSingleBandGray, rasterType(), redBandName(), setMaximumValue(), setMinimumValue(), setUserDefinedGrayMinimumMaximum(), setUserDefinedRGBMinimumMaximum(), and SingleBandGray.

void QgsRasterLayer::setMinimumValue ( unsigned int  theBand,
double  theValue,
bool  theGenerateLookupTableFlag = true 
)

Mutator for setting the minimum value for contrast enhancement.

Definition at line 2670 of file qgsrasterlayer.cpp.

References bandCount(), mContrastEnhancementList, and QgsDebugMsg.

Referenced by drawMultiBandColor(), drawSingleBandGray(), readSymbology(), setDataProvider(), setMinimumMaximumUsingDataset(), setMinimumMaximumUsingLastExtent(), and setMinimumValue().

void QgsRasterLayer::setMinimumValue ( QString  theBand,
double  theValue,
bool  theGenerateLookupTableFlag = true 
)

Mutator for setting the minimum value for contrast enhancement.

Definition at line 2679 of file qgsrasterlayer.cpp.

References bandNumber(), and setMinimumValue().

void QgsRasterLayer::setNoDataValue ( double  theNoData)

Mutator that allows the NO_DATA entry for this raster to be overridden.

Definition at line 2688 of file qgsrasterlayer.cpp.

References mNoDataValue, mRasterStatsList, and mValidNoDataValue.

Referenced by readSymbology(), resetNoDataValue(), and setDataProvider().

void QgsRasterLayer::setRasterShaderFunction ( QgsRasterShaderFunction theFunction)

Set the raster shader function to a user defined function.

Note
ownership of the shader function is transfered to raster shader

Definition at line 2704 of file qgsrasterlayer.cpp.

References mColorShadingAlgorithm, mRasterShader, QgsRasterShader::setRasterShaderFunction(), UndefinedShader, and UserDefinedShader.

void QgsRasterLayer::setRedBandName ( const QString &  theBandName)

Mutator for red band name (allows alternate mappings e.g.

map blue as red color)

Definition at line 2719 of file qgsrasterlayer.cpp.

References mRedBandName, QgsDebugMsg, and validateBandName().

Referenced by readSymbology().

void QgsRasterLayer::setRGBMinimumMaximumEstimated ( bool  theBool)
inline

Mutator for mRGBMinimumMaximumEstimated.

Definition at line 383 of file qgsrasterlayer.h.

Referenced by readSymbology().

void QgsRasterLayer::setStandardDeviations ( double  theStandardDeviations)
inline

Mutator to alter the number of standard deviations that should be plotted.

Definition at line 386 of file qgsrasterlayer.h.

Referenced by readSymbology(), and setDataProvider().

void QgsRasterLayer::setSubLayerVisibility ( const QString &  name,
bool  vis 
)
virtual

Set the visibility of the given sublayer name.

Definition at line 2725 of file qgsrasterlayer.cpp.

References mDataProvider, QgsDebugMsg, and QgsDataProvider::setSubLayerVisibility().

void QgsRasterLayer::setTransparentBandName ( const QString &  theBandName)

Mutator for transparent band name mapping.

Definition at line 2736 of file qgsrasterlayer.cpp.

References mTransparencyBandName, and validateBandName().

void QgsRasterLayer::setUserDefinedGrayMinimumMaximum ( bool  theBool)
inline

Mutator for mUserDefinedGrayMinimumMaximum.

Definition at line 389 of file qgsrasterlayer.h.

Referenced by readSymbology(), setMinimumMaximumUsingDataset(), and setMinimumMaximumUsingLastExtent().

void QgsRasterLayer::setUserDefinedRGBMinimumMaximum ( bool  theBool)
inline

Mutator for mUserDefinedRGBMinimumMaximum.

Definition at line 392 of file qgsrasterlayer.h.

Referenced by readSymbology(), setMinimumMaximumUsingDataset(), and setMinimumMaximumUsingLastExtent().

void QgsRasterLayer::showProgress ( int  theValue)

[ data provider interface ] A wrapper function to emit a progress update signal

Definition at line 2741 of file qgsrasterlayer.cpp.

References progressUpdate().

void QgsRasterLayer::showStatusMessage ( const QString &  theMessage)
slot

Definition at line 2747 of file qgsrasterlayer.cpp.

References QgsMapLayer::statusChanged().

double QgsRasterLayer::standardDeviations ( ) const
inline

Accessor to find out how many standard deviations are being plotted.

Definition at line 395 of file qgsrasterlayer.h.

Referenced by writeSymbology().

QStringList QgsRasterLayer::subLayers ( ) const

Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS.

Definition at line 2757 of file qgsrasterlayer.cpp.

References mDataProvider, and QgsRasterDataProvider::subLayers().

Referenced by writeSymbology().

void QgsRasterLayer::thumbnailAsImage ( QImage *  thepImage)

Draws a thumbnail of the rasterlayer into the supplied QImage pointer.

Note
added in QGIS 1.6

Definition at line 2815 of file qgsrasterlayer.cpp.

References QgsRasterViewPort::bottomRightPoint, draw(), QgsRasterViewPort::drawableAreaXDim, QgsRasterViewPort::drawableAreaYDim, mProviderKey, and QgsRasterViewPort::topLeftPoint.

void QgsRasterLayer::thumbnailAsPixmap ( QPixmap *  theQPixmap)
virtual QDateTime QgsRasterLayer::timestamp ( ) const
inlinevirtual

Time stamp of data source in the moment when data/metadata were loaded by provider.

Reimplemented from QgsMapLayer.

Definition at line 651 of file qgsrasterlayer.h.

QString QgsRasterLayer::transparentBandName ( ) const
inline

Accessor for transparent band name mapping.

Definition at line 398 of file qgsrasterlayer.h.

void QgsRasterLayer::triggerRepaint ( )

Emit a signal asking for a repaint.

(inherited from maplayer)

Definition at line 2840 of file qgsrasterlayer.cpp.

References QgsMapLayer::repaintRequested().

bool QgsRasterLayer::update ( )
private
void QgsRasterLayer::updateProgress ( int  theProgress,
int  theMax 
)
slot

Propagate progress updates from GDAL up to the parent app.

Definition at line 2845 of file qgsrasterlayer.cpp.

References QgsMapLayer::drawingProgress().

bool QgsRasterLayer::usesProvider ( )

[ data provider interface ] Does this layer use a provider for setting/retrieving data?

Definition at line 4531 of file qgsrasterlayer.cpp.

References mProviderKey.

QString QgsRasterLayer::validateBandName ( const QString &  theBandName)
private

Verify and transform band name for internal consistency.

Return 'Not Set' on any type of failure

Definition at line 4536 of file qgsrasterlayer.cpp.

References bandName(), QgsRasterDataProvider::generateBandName(), mDataProvider, mRasterStatsList, QgsDebugMsg, QSTRING_NOT_SET, and TRSTRING_NOT_SET.

Referenced by setBlueBandName(), setGrayBandName(), setGreenBandName(), setRedBandName(), and setTransparentBandName().

int QgsRasterLayer::width ( )
inline

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

Definition at line 404 of file qgsrasterlayer.h.

bool QgsRasterLayer::writeSymbology ( QDomNode &  layer_node,
QDomDocument &  doc,
QString &  errorMessage 
) const
protectedvirtual
bool QgsRasterLayer::writeXml ( QDomNode &  layer_node,
QDomDocument &  doc 
)
protectedvirtual

Write layer specific state to project file Dom node.

Reimplemented from QgsMapLayer.

Definition at line 3506 of file qgsrasterlayer.cpp.

References mProviderKey, QgsLogger::warning(), and writeSymbology().

Member Data Documentation

int QgsRasterLayer::mBandCount
private

The number of bands in the dataset.

Definition at line 798 of file qgsrasterlayer.h.

Referenced by bandCount(), init(), and setDataProvider().

QString QgsRasterLayer::mBlueBandName
private

The band to be associated with the color blue - usually 3.

Definition at line 801 of file qgsrasterlayer.h.

Referenced by draw(), drawMultiBandColor(), init(), readXml(), setBlueBandName(), and setDataProvider().

ColorShadingAlgorithm QgsRasterLayer::mColorShadingAlgorithm
private

The raster shading algorithm being used.

Definition at line 804 of file qgsrasterlayer.h.

Referenced by colorShadingAlgorithmAsString(), init(), legendAsPixmap(), setColorShadingAlgorithm(), and setRasterShaderFunction().

QgsContrastEnhancement::ContrastEnhancementAlgorithm QgsRasterLayer::mContrastEnhancementAlgorithm
private

The contrast enhancement algorithm being used.

Definition at line 807 of file qgsrasterlayer.h.

Referenced by contrastEnhancementAlgorithmAsString(), init(), setContrastEnhancementAlgorithm(), and setDataProvider().

ContrastEnhancementList QgsRasterLayer::mContrastEnhancementList
private
QString QgsRasterLayer::mCrs
private

Definition at line 913 of file qgsrasterlayer.h.

Referenced by readXml(), and update().

QgsRasterDataProvider* QgsRasterLayer::mDataProvider
private
DrawingStyle QgsRasterLayer::mDrawingStyle
private
bool QgsRasterLayer::mEditable
private

[ data provider interface ] Flag indicating whether the layer is in editing mode or not

Definition at line 821 of file qgsrasterlayer.h.

QString QgsRasterLayer::mError
private

[ data provider interface ]The error message associated with the last error

Definition at line 824 of file qgsrasterlayer.h.

Referenced by lastError().

QString QgsRasterLayer::mErrorCaption
private

[ data provider interface ] The error caption associated with the last error

Definition at line 827 of file qgsrasterlayer.h.

Referenced by lastErrorTitle().

QString QgsRasterLayer::mFormat
private

Definition at line 912 of file qgsrasterlayer.h.

Referenced by readXml(), and update().

double QgsRasterLayer::mGeoTransform[6]
private

Pointer to the gdaldataset.

Pointer to the gdaldataset (possibly warped vrt) Values for mapping pixel to world coordinates. Contents of this array are the same as the GDAL adfGeoTransform

Definition at line 836 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), drawPalettedSingleBandColor(), drawPalettedSingleBandGray(), drawPalettedSingleBandPseudoColor(), drawSingleBandColorData(), drawSingleBandGray(), drawSingleBandPseudoColor(), and init().

QString QgsRasterLayer::mGrayBandName
private

The band to be associated with the grayscale only output - usually 1.

Definition at line 839 of file qgsrasterlayer.h.

Referenced by draw(), init(), readSymbology(), readXml(), setDataProvider(), setGrayBandName(), and setMinimumMaximumUsingDataset().

bool QgsRasterLayer::mGrayMinimumMaximumEstimated
private

Flag to indicate of the min max values are actual or estimates/user defined.

Definition at line 842 of file qgsrasterlayer.h.

Referenced by drawSingleBandGray(), and init().

QString QgsRasterLayer::mGreenBandName
private

The band to be associated with the color green - usually 2.

Definition at line 845 of file qgsrasterlayer.h.

Referenced by draw(), drawMultiBandColor(), init(), readSymbology(), readXml(), setDataProvider(), setGreenBandName(), and setMinimumMaximumUsingDataset().

bool QgsRasterLayer::mHasPyramids
private

Whether this raster has overviews / pyramids or not.

Definition at line 848 of file qgsrasterlayer.h.

Referenced by closeDataProvider(), init(), and legendAsPixmap().

int QgsRasterLayer::mHeight
private

Raster height.

Definition at line 854 of file qgsrasterlayer.h.

Referenced by bandStatistics(), draw(), and setDataProvider().

bool QgsRasterLayer::mInvertColor
private

Flag indicating whether the color of pixels should be inverted or not.

Definition at line 857 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), drawPalettedSingleBandColor(), drawPalettedSingleBandGray(), drawPalettedSingleBandPseudoColor(), drawSingleBandGray(), drawSingleBandPseudoColor(), and legendAsPixmap().

QDateTime QgsRasterLayer::mLastModified
private

[ data provider interface ] Timestamp, the last modified time of the data source when the layer was created

Definition at line 860 of file qgsrasterlayer.h.

Referenced by setDataProvider().

QgsRasterViewPort QgsRasterLayer::mLastViewPort
private

Definition at line 862 of file qgsrasterlayer.h.

Referenced by computeMinimumMaximumFromLastExtent(), draw(), and init().

QStringList QgsRasterLayer::mLayers
private

WMS parameters.

Definition at line 910 of file qgsrasterlayer.h.

Referenced by readXml(), and update().

bool QgsRasterLayer::mModified
private

[ data provider interface ] pointer for loading the provider library

[ data provider interface ] Flag indicating whether the layer has been modified since the last commit

Definition at line 868 of file qgsrasterlayer.h.

double QgsRasterLayer::mNoDataValue
private
QString QgsRasterLayer::mProviderKey
private
RasterPyramidList QgsRasterLayer::mPyramidList
private

This list holds a series of RasterPyramid structs which store information for each potential pyramid level.

Definition at line 877 of file qgsrasterlayer.h.

Referenced by closeDataProvider().

QgsRasterShader* QgsRasterLayer::mRasterShader
private
RasterStatsList QgsRasterLayer::mRasterStatsList
private

A collection of stats - one for each band in the layer.

Definition at line 883 of file qgsrasterlayer.h.

Referenced by bandName(), bandNumber(), bandStatistics(), closeDataProvider(), colorTable(), hasStatistics(), setDataProvider(), setNoDataValue(), and validateBandName().

QgsRasterTransparency QgsRasterLayer::mRasterTransparency
private
LayerType QgsRasterLayer::mRasterType
private

Definition at line 888 of file qgsrasterlayer.h.

Referenced by bandStatistics(), init(), and setDataProvider().

QString QgsRasterLayer::mRedBandName
private

The band to be associated with the color red - usually 1.

Definition at line 891 of file qgsrasterlayer.h.

Referenced by draw(), drawMultiBandColor(), init(), readSymbology(), readXml(), setDataProvider(), setMinimumMaximumUsingDataset(), and setRedBandName().

bool QgsRasterLayer::mRGBMinimumMaximumEstimated
private

Flag to indicate of the min max values are actual or estimates/user defined.

Definition at line 894 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), and init().

double QgsRasterLayer::mStandardDeviations
private

Number of stddev to plot (0) to ignore.

Not applicable to all layer types

Definition at line 813 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), drawPalettedSingleBandPseudoColor(), drawSingleBandGray(), and drawSingleBandPseudoColor().

QStringList QgsRasterLayer::mStyles
private

Definition at line 911 of file qgsrasterlayer.h.

Referenced by readXml(), and update().

QString QgsRasterLayer::mTransparencyBandName
private
bool QgsRasterLayer::mUserDefinedGrayMinimumMaximum
private

Flag to indicate if the user entered custom min max values.

Definition at line 900 of file qgsrasterlayer.h.

Referenced by drawSingleBandGray(), and init().

bool QgsRasterLayer::mUserDefinedRGBMinimumMaximum
private

Flag to indicate if the user entered custom min max values.

Definition at line 903 of file qgsrasterlayer.h.

Referenced by drawMultiBandColor(), and init().

bool QgsRasterLayer::mValidNoDataValue
private
int QgsRasterLayer::mWidth
private

Raster width.

Definition at line 851 of file qgsrasterlayer.h.

Referenced by draw(), and setDataProvider().

const QString QgsRasterLayer::QSTRING_NOT_SET
private

Constant defining flag for XML and a constant that signals property not used.

Definition at line 794 of file qgsrasterlayer.h.

Referenced by validateBandName(), and writeSymbology().

const QString QgsRasterLayer::TRSTRING_NOT_SET
private

Definition at line 795 of file qgsrasterlayer.h.

Referenced by draw(), init(), readXml(), setDataProvider(), validateBandName(), and writeSymbology().


The documentation for this class was generated from the following files: