[Qgis-developer] How to color a raster with a color table with values From - To?

SupportLists supportlists at qlands.com
Mon Aug 13 04:12:16 PDT 2012


Hi,

I am using 1.8.0 but tests/src/core/testqgsrasterlayer.cpp is defined as:

void TestQgsRasterLayer::pseudoColor()
{
   mpRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
   mpRasterLayer->setColorShadingAlgorithm( 
QgsRasterLayer::PseudoColorShader );
   mpRasterLayer->setContrastEnhancementAlgorithm(
     QgsContrastEnhancement::StretchToMinimumMaximum, false );
   mpRasterLayer->setMinimumValue( mpRasterLayer->grayBandName(), 0.0, 
false );
   mpRasterLayer->setMaximumValue( mpRasterLayer->grayBandName(), 10.0 );
   mpMapRenderer->setExtent( mpRasterLayer->extent() );
   QVERIFY( render( "raster_pseudo" ) );
}

I cannot locate the code using ColorRampItem.

Many thanks,
Carlos.

On 08/08/2012 08:07 PM, Etienne Tourigny wrote:
> Hi,
>
> which version of the api are you using? If you are using the
> development version (1.9), there is support for more flexible color
> ramps with rasters, using QgsVectorColorRampV2. Beware, however, that
> the api is going to suffer some changes in the near future. There are
> various recent threads on this subject in this mailing list.
>
> Another option (and the only available if using 1.8) is to follow the
> approach used in the rasterlayer test in
> tests/src/core/testqgsrasterlayer.cpp .
> TestQgsRasterLayer::pseudoColor() uses a ColorRampItem vector and
> calls colorRampShader->setColorRampItemList(items)
>
> Etienne
>
> On Wed, Aug 8, 2012 at 3:42 AM, SupportLists <supportlists at qlands.com> wrote:
>> Hi,
>>
>> I am using QGIS API to develop a custom application. Currently I'm using
>> QgsRasterLayer::PalettedColor + QgsRasterLayer::ColorRampShader  +
>> QgsColorRampShader::ColorRampItem to render a raster using a specific color
>> map.
>>
>> Now, I need to render the raster with a colormap using value From - To
>> however, ColorRampItem struct only accepts one value. Is there another way
>> around? Or, its it possible to create user defined DrawingStyles and
>> ColorShadingAlgorithms? If so how?
>>
>> Any help is very much appreciated.
>>
>> Regards,
>> Carlos.
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer




More information about the Qgis-developer mailing list