public static void CategorizeNumericPointLayer(Shapefile sf, int classificationField = 1,
                                                       tkClassificationType Method           = tkClassificationType.ctNaturalBreaks)
        {
            float ptSize = 0;

            if (sf.Categories.Generate(classificationField, Method, NumberOfCategories))
            {
                for (int n = 0; n < sf.Categories.Count; n++)
                {
                    var category = sf.Categories.Item[n];
                    ptSize = PointSizeOfMaxCategory * ((float)(n + 1) / sf.Categories.Count);
                    category.DrawingOptions.PointSize = ptSize;
                    category.DrawingOptions.LineColor = new Utils().ColorByName(tkMapColor.White);
                }
            }
            var   cat0 = sf.Categories.Add("zero");
            Field f    = sf.Field[classificationField];

            cat0.Expression = $"[{f.Name}]=0";
            cat0.DrawingOptions.PointSize   = 0;
            cat0.DrawingOptions.FillVisible = false;
            cat0.DrawingOptions.LineVisible = false;
            sf.Categories.ApplyExpression(sf.Categories.CategoryIndex[cat0]);
        }
 /// <summary>
 /// Creates the specified number of visualization categories and expressions for them.
 /// </summary>
 /// <remarks>The method can be useful to override generation routine provided in ShapefileCategories.GenerateCategories()
 /// which always generate categories covering the full range of values of the specified field. This method can
 /// define the range of values explicitly, therefore certain values can be excluded from classification or on contrary
 /// categories can be added for the values which aren't yet present in the table.</remarks>
 /// <param name="FieldIndex">The index of the field to build classification by.</param>
 /// <param name="ClassificationType">The type of the classification.</param>
 /// <param name="numClasses">The number of categories to add. If ClassificationType equals ctUniqueValues this value will be skipped.</param>
 /// <param name="MinValue">The minimal value of the field to include in the classification.</param>
 /// <param name="MaxValue">Th maximum value of the field to include in the classification.</param>
 /// <returns>True on successful adding and false otherwise.</returns>
 public bool AddRange(int FieldIndex, tkClassificationType ClassificationType, int numClasses, object MinValue, object MaxValue)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Generates categories based on specified field.
 /// </summary>
 /// <param name="FieldName">Name of the field.</param>
 /// <param name="ClassificationType">Type of the classification.</param>
 /// <param name="numClasses">The number classes.</param>
 /// <returns>True on success.</returns>
 /// \new494 Added in version 4.9.4
 public bool Generate2(string FieldName, tkClassificationType ClassificationType, int numClasses)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Generates visualization categories by certain attribute
 /// </summary>
 /// <param name="FieldIndex">The index of the field to generate categories by.</param>
 /// <param name="ClassificationType">The type of classification.</param>
 /// <param name="numClasses">Number of classes to generate. The parameter is omitted
 /// in case unique values classification is used.</param>
 /// <returns>True on successful generation and false otherwise.</returns>
 public bool Generate(int FieldIndex, tkClassificationType ClassificationType, int numClasses)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 /// <summary>
 /// Builds classification for the raster band.
 /// </summary>
 /// <param name="MinValue">The minimum value.</param>
 /// <param name="MaxValue">The maximum value.</param>
 /// <param name="classification">The classification type.</param>
 /// <param name="NumCategories">The number of categories.</param>
 /// <returns>Resulting classification.</returns>
 public GridColorScheme Classify(double MinValue, double MaxValue, tkClassificationType classification, int NumCategories)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 /// <summary>
 /// Generates visualization categories for OGR layer.
 /// </summary>
 /// <param name="Fieldname">%Field name to use as a base for classification.</param>
 /// <param name="ClassificationType">Type of classification.</param>
 /// <param name="numClasses">Number of classes (is not used with unique values classification type).</param>
 /// <param name="colorStart">Starting color for the color scheme.</param>
 /// <param name="colorEnd">End color for the color scheme.</param>
 /// <param name="schemeType">Type of color scheme.</param>
 /// <returns>True on success.</returns>
 /// <remarks> The whole set of features will be used during classification, not only those currently loaded into memory.
 /// Therefore the method has definite advantage over calling OgrLayer.GetBuffer.Categories.Generate
 /// directly for large layers.\n\n
 ///
 /// Categories will be added to underlying shapefile (OgrLayer.GetBuffer). This method
 /// will trigger the population of this shapefile if it's not yet in memory. \n
 ///
 /// The following code opens "buildings" layer, generates categories based on "population"
 /// field and then saves them as a "new_style" to the datasource.\n
 ///
 /// \code
 /// var layer = new OgrLayer();
 /// if (!layer.OpenFromDatabase(CONNECTION_STRING, "buildings"))
 /// {
 ///     Debug.WriteLine("Failed to open the layer: " + layer.GdalLastErrorMsg);
 /// }
 /// else
 /// {
 ///     layer.LabelExpression = "[Name]";
 ///     layer.LabelPosition = tkLabelPositioning.lpCenter;
 ///     layer.GlobalCallback = this;
 ///
 ///     if (!layer.GenerateCategories("population", tkClassificationType.ctEqualIntervals,
 ///         10, tkMapColor.Blue, tkMapColor.Yellow, tkColorSchemeType.ctSchemeGraduated))
 ///     {
 ///         Debug.WriteLine("Failed to generated categories: " + layer.get_ErrorMsg(layer.LastErrorCode));
 ///     }
 ///     else
 ///     {
 ///         var sf = layer.GetBuffer();
 ///         Debug.WriteLine("Number of generated categories: " + sf.Categories.Count);
 ///
 ///         // save it as a new style
 ///         if (!layer.SaveStyle("new_style"))
 ///         {
 ///             Debug.WriteLine("Failed to save style: " + layer.GdalLastErrorMsg);
 ///         }
 ///         else
 ///         {
 ///             Debug.WriteLine("The new style has been saved.");
 ///         }
 ///     }
 ///     layer.Close();
 /// }
 /// \endcode
 /// </remarks>
 public bool GenerateCategories(string Fieldname, tkClassificationType ClassificationType, int numClasses,
                                tkMapColor colorStart, tkMapColor colorEnd, tkColorSchemeType schemeType)
 {
     throw new NotImplementedException();
 }