private static async void SetRasterColorByAttributeField(RasterLayer raster, string fieldName, StyleProjectItem styleProjItem)
 {
     await QueuedTask.Run(() =>
     {
         var ramps = styleProjItem.SearchColorRamps("Green Blues");
         CIMColorRamp colorRamp = ramps[0].ColorRamp;
         var colorizerDef       = new UniqueValueColorizerDefinition(fieldName, colorRamp);
         var colorizer          = raster.CreateColorizer(colorizerDef);
         // fix up colorizer ... due to a problem with getting the values for different attribute table fields:
         // we use the Raster's attribute table to collect a dictionary with the correct replacement values
         Dictionary <string, string> landuseToFieldValue = new Dictionary <string, string>();
         if (colorizer is CIMRasterUniqueValueColorizer uvrColorizer)
         {
             var rasterTbl = raster.GetRaster().GetAttributeTable();
             var cursor    = rasterTbl.Search();
             while (cursor.MoveNext())
             {
                 var row          = cursor.Current;
                 var correctField = row[fieldName].ToString();
                 var key          = row[uvrColorizer.Groups[0].Heading].ToString();
                 landuseToFieldValue.Add(key.ToLower(), correctField);
             }
             uvrColorizer.Groups[0].Heading = fieldName;
             for (var idxGrp = 0; idxGrp < uvrColorizer.Groups[0].Classes.Length; idxGrp++)
             {
                 var grpClass       = uvrColorizer.Groups[0].Classes[idxGrp];
                 var oldValue       = grpClass.Values[0].ToLower();
                 var correctField   = landuseToFieldValue[oldValue];
                 grpClass.Values[0] = correctField;
                 grpClass.Label     = $@"{correctField}";
             }
         }
         raster.SetColorizer(colorizer);
     });
 }
        private static async void SetRasterColorByRGBAttributeFields(RasterLayer raster, List <string> fields)
        {
            await QueuedTask.Run(() =>
            {
                // set fieldName to the first column
                var fieldName     = "n/a";
                bool setFieldName = false;
                foreach (var attributeColumn in fields)
                {
                    if (attributeColumn.Equals("value", StringComparison.OrdinalIgnoreCase))
                    {
                        setFieldName = true;
                    }
                    else
                    {
                        if (setFieldName)
                        {
                            fieldName = attributeColumn;
                            break;
                        }
                    }
                }
                var colorizerDef = new UniqueValueColorizerDefinition(fieldName);
                var colorizer    = raster.CreateColorizer(colorizerDef);

                raster.SetColorizer(colorizer);
            });
        }