QGIS-2.8-PyQGISDeveloperCookbook-en(16)
时间:2025-03-11
时间:2025-03-11
为开发人员准备的文档,涵盖QGIS的多种功能实现和代码。
dex
2
3
4
5
7
8
9QgsRasterLater.XSingleBandPseudoColorPalettedColorPalettedSingleBandGrayPalettedSingleBandPseudo-ColorMultiBandSingleBandGrayMultiBandSingle-BandPseudoColorMultiBandColor
Singlebandimagedrawnusingapseudocoloralgorithm“Palette”imagedrawnusingcolortable“Palette”layerdrawningrayscale“Palette”layerdrawnusingapseudocoloralgorithmLayercontaining2ormorebands,butasinglebanddrawnasarangeofgraycolorsLayercontaining2ormorebands,butasinglebanddrawnusingapseudocoloralgorithmLayercontaining2ormorebands,mappedtoRGBcolorspace.
Toquerythecurrentdrawingstyle:
Singlebandrasterlayerscanbedrawneitheringraycolors(lowvalues=black,highvalues=white)orwitha
pseudocoloralgorithmthatassignscolorsforvaluesfromthesingleband.Singlebandrasterswithapalettecan
beadditionallydrawnusingtheirpalette.MultibandlayersaretypicallydrawnbymappingthebandstoRGB
colors.Otherpossibilityistousejustonebandforgrayorpseudocolordrawing.
Thefollowingsectionsexplainhowtoqueryandmodifythelayerdrawingstyle.Afterdoingthechanges,you
mightwanttoforceupdateofmapcanvas,seeRefreshingLayers.
TODO:contrastenhancements,transparency(nodata),userde nedmin/max,bandstatistics
4.2.1SingleBandRasters
Theyarerenderedingraycolorsbydefault.Tochangethedrawingstyletopseudocolor:
ThePseudoColorShaderisabasicshaderthathighlightslowvaluesinblueandhighvaluesinred.Thereis
alsoColorRampShaderwhichmapsthecolorsasspeci edbyitscolormap.Ithasthreemodesof
interpolationofvalues:
linear(INTERPOLATED):resultingcolorislinearlyinterpolatedfromthecolormapentriesaboveand
belowtheactualpixelvalue
discrete(DISCRETE):colorisusedfromthecolormapentrywithequalorhighervalue
exact(EXACT):colorisnotinterpolated,onlythepixelswithvalueequaltocolormapentriesaredrawn
Tosetaninterpolatedcolorrampshaderrangingfromgreentoyellowcolor(forpixelvaluesfrom0to255):