ThinkGeo.com    |     Documentation    |     Premium Support

Applying a gradient to a GRID

Hi all,


I am loading an ERSI Grid file and displaying it.   All works well, but I am wondering if it is possible to apply a smooth gradient between color breaks?  Example source code is below for how I'm defining classbreaks now.   Can this method be modified so the grid file has a nice smooth transitions rather than the jagged picture shown in the attachements.


 



double tempmax = (double)e.Result;
ClassBreakStyle gridClassBreakStyle = new ClassBreakStyle("CellValue");
int Alpha = 175;

gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.0003 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent))));
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.0009 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 0, 255, 255)))));  //cyan
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.002 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 0, 0, 255))))); //blue
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.006 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 34, 139, 34))))); //green
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.018 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 225, 255, 0)))));  //yellow
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.049 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 165, 132)))));  //orange
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.13 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 0, 128))))); //red 
gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(0.36 * tempmax, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 160, 32, 0))))); //purlpe


GridFeatureLayer gridFeatureLayer = new GridFeatureLayer("weather.grd");
gridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(gridClassBreakStyle);
gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;


LayerOverlay staticplumeOverlay = new LayerOverlay();
staticplumeOverlay.Layers.Add("GridFeatureLayer", gridFeatureLayer);
wpfMap1.Overlays.Add(staticplumeOverlay);
wpfMap1.Refresh();




 Brad,



You can create a Color Collection in a Family and apply them to a ClassBreakStyle, as following for example. 



        //Create a series of colors from blue to red that we will use for the breaks
        Collection<GeoColor> colors = GeoColor.GetColorsInQualityFamily(GeoColor.StandardColors.Blue, GeoColor.StandardColors.Red, 
            levels.Count, ColorWheelDirection.Clockwise);
 
        //Setup a class break style based on the colors
        ClassBreakStyle classBreakStyle = new ClassBreakStyle(dataValueColumnName);
        LineStyle firstStyle = new LineStyle(new GeoPen(colors[0], 3));
        classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, firstStyle));
        for (int i = 0; i < colors.Count - 1; i++)
        {
            LineStyle style = new LineStyle(new GeoPen(levels[i + 1], 3));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(levels[i], style));
        }
        Layer.CustomStyles.Add(classBreakStyle);


You would get something like this.



Thanks,


Ben