Raster Layer ColorCategory possible bug

Jan 14, 2011 at 10:59 AM

I am using something simmilar to the following code to add a color map to a raster. 
The problem is that for a value that is exactly the same as the ValueFrom 
is not displaying the correct color but instead black. Everything else works ! this is a weird behaviour
I will try and search why this happens if anyone points me where to look at on the endless dotspatial code.
Any ideas why this happens ? Have i misunderstood something ?

  For i As Integer = 0 To legend.items.Count - 1
            Dim cat As ColorCategory
            cat = New ColorCategory(valueFrom, valueTo, TheColor, TheColor)
                cat.LegendText = catName

            cat.LegendItemVisible = true
            RasterSymbSchemeCats.Add(cat)
        Next
        RasterSymbScheme.Categories = RasterSymbSchemeCats
        RasterSymb.Scheme = RasterSymbScheme
 Dim mrl As New MapRasterLayer(fn, RasterSymb)
themap.Layers.Add(mrl)

May 26, 2011 at 3:14 PM

Actually the bug seems to be on the right bound of applied colour , when the value is exactly equal to the right bound(the so called endvalue) so it does not display the chosen highColor but instead the NoData color.

This bug happens when you display bgd raster files.

I will investigate this errors since it is a little urgent and i will post my findings here..

May 26, 2011 at 7:13 PM

These are two examples of how 0 and 1 values are drawn with high and low color and without:



here is a simple code sample on how to test this

   if (map1.Layers.Count > 0 )
            {
                MapRasterLayer mrl = (MapRasterLayer) map1.Layers[0];

                RasterSymbolizer RasterSymb = new  RasterSymbolizer();
                ColorScheme RasterSymbScheme = new  ColorScheme();
                ColorCategoryCollection RasterSymbSchemeCats = new ColorCategoryCollection() ;
                RasterSymb.NoDataColor = Color.Red;

    ColorCategory cat0 = new ColorCategory(-40, -30, Color.FromArgb(160, 160, 160), Color.FromArgb(0, 84, 255));
                ColorCategory cat1 = new ColorCategory(-30, -20, Color.FromArgb(0, 84, 255), Color.FromArgb(138, 200, 230));
                ColorCategory cat2 = new ColorCategory(-20, -10, Color.FromArgb(138, 200, 230), Color.FromArgb(0, 240, 255));
                ColorCategory cat3 = new ColorCategory(-10, 0, Color.FromArgb(0, 240, 255), Color.FromArgb(138, 240, 145));
                ColorCategory cat4 = new ColorCategory(0, 10, Color.FromArgb(138, 240, 145), Color.FromArgb(255, 255, 0));
                ColorCategory cat5 = new ColorCategory(10, 20, Color.FromArgb(255, 255, 0), Color.FromArgb(255, 143, 0));
                ColorCategory cat6 = new ColorCategory(20, 30, Color.FromArgb(255, 143, 0), Color.FromArgb(255, 84, 0));

                cat0.LegendText = "Cat0";
                cat0.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat0);
                cat1.LegendText = "Cat1";
                cat1.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat1);
                cat2.LegendText = "Cat2";
                cat2.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat2);
                cat3.LegendText = "Cat3";
                cat3.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat3);
                cat4.LegendText = "Cat4";
                cat4.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat4);
                cat5.LegendText = "Cat5";
                cat5.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat5);
                cat6.LegendText = "Cat6";
                cat5.LegendItemVisible = true;
                RasterSymbSchemeCats.Add(cat6);

               RasterSymbScheme.Categories = RasterSymbSchemeCats;
                RasterSymb.Scheme = RasterSymbScheme;
                RasterSymb.ColorSchemeHasUpdated = true;
                mrl.Symbolizer = RasterSymb;
                mrl.WriteBitmap();
                RasterSymbolizer iRS = (RasterSymbolizer) mrl.Symbolizer;
                mrl.Symbolizer = RasterSymb;
                map1.ViewExtents = mrl.Extent;
                map1.Refresh();

Jun 2, 2011 at 11:56 PM

anyone if this is the appropriate method to use a color table ? the tutorial on raster seems a little bit different ...

Sep 24, 2012 at 3:37 PM

Hi,

i've got the same problem, no color on limit.

Is someone found a solution ?

Best regards.

Developer
May 3, 2016 at 8:52 PM
So working with loading a raster and basically cloned my scheme from MapWindow. Right away I noticed the holes and it looks like this is still an issue. So do we have to adjust manually for the symbolizing of the end as < Val rather than <= Val. If that's the case then it looks like the start is > Val so really it is not inclusive on either boundary. Is that the way it should be?

~AGP