This document is archived and information here might be outdated.  Recommended version.

IMapServer4.GenerateDataClasses Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMapServer4 Interface > IMapServer4.GenerateDataClasses Method
ArcGIS Developer Help

IMapServer4.GenerateDataClasses Method

Returns the class breaks or unique values for the specified dynamic layer.

[Visual Basic .NET]
Public Function GenerateDataClasses ( _
    ByVal MapName As String, _
    ByVal pTableDescription As IMapTableDescription, _
    ByVal pDataClassificationDef As IDataClassificationDef _
) As IFeatureRenderer
public IFeatureRenderer GenerateDataClasses (
    string MapName,
    IMapTableDescription pTableDescription,
    IDataClassificationDef pDataClassificationDef
HRESULT GenerateDataClasses(
  BSTR MapName,
  IMapTableDescription* pTableDescription,
  IDataClassificationDef* pDataClassificationDef
MapName [in]

MapName is a parameter of type BSTR pTableDescription [in]
pTableDescription is a parameter of type IMapTableDescription* pDataClassificationDef [in]
pDataClassificationDef is a parameter of type IDataClassificationDef*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


GenerateDataClasses is a helper function that allows clients to generate classes based on a classification method or get distinct values from single or multiple fields. This eliminates the need to download entire dataset on the client side to compute class breaks or find out distint values from a field. Since the result is a IFeatureRenderer, the result is primarily used to change the renderer of a layer without needing to access fine grained ArcObjects or restarting a mapservice by simply making coarse grain MapServer function call. Please check IMapServer::ExportMapImage function help for more information on this.

The type of renderer that is returned by this function depends on DataClassificationDef parameter - for example, if an object of type IClassBreakDef is passed in, the result will be a ClassBreaksRenderer, of if IUniqueValuesDef is passed in you will get back a UniqueValueRenderer object.

Please note that when this function is called with a standalone table as an input parameter, it does not return symbol for each class in the returned IFeatureRenderer unless IDataClassificationDef::BaseSymbol is specified.

You can control the returned symbols in the result by specifying BaseSymbol and/or ColorRamp. If these are not specified, the function returns symbol with default values in case the input is a layer. The default ColorRamp is "Green to Blue". The color of returned symbol is always RgbColor.

This function honors the definition expression set on the queried table or layer.

For performance reason, you should always run this on a base table or layer instead of joined table or table.



In order to compute breaks for a class break renderer, MapServer needs to read all records from a layer/table, which may take longer time to process depending on the number of records the layer/table has. For that reason, MapServer uses the value set to MaxSampleSize property to limit the number of records it needs to process. If you find the value set by default does not satisfy your needs, you can change that in a map service's configuration.


Sample code to generate 5 different classes based on LANDVAL field using EqualInterval classification method

IClassBreaksDef pCBDef = new ClassBreaksDef() as IClassBreaksDef;
pCBDef.ClassificationField = "LANDVAL";
pCBDef.ClassificationMethod = esriClassifyMethod.esriClassifyEqualInterval;
pCBDef.BreakCount = 5;

IHsvColor pColorStart = new HsvColor();
pColorStart.Hue = 60;
pColorStart.Saturation = 50;
pColorStart.Value = 100;
IHsvColor pColorMiddle = new HsvColor();
pColorMiddle.Hue = 37;
pColorMiddle.Saturation = 81;
pColorMiddle.Value = 95;
IHsvColor pColorEnd = new HsvColor();
pColorEnd.Hue = 0;
pColorEnd.Saturation = 100;
pColorEnd.Value = 42;

IAlgorithmicColorRamp pAlgorithmicColorRamp1 = new AlgorithmicColorRamp();
pAlgorithmicColorRamp1.FromColor = pColorStart;
pAlgorithmicColorRamp1.ToColor = pColorMiddle;
IAlgorithmicColorRamp pAlgorithmicColorRamp2 = new AlgorithmicColorRamp();
pAlgorithmicColorRamp2.FromColor = pColorMiddle;
pAlgorithmicColorRamp2.ToColor = pColorEnd;

IMultiPartColorRamp pMultiPartColorRamp = new MultiPartColorRamp();
pMultiPartColorRamp.Name = "Yellow to Dark Red"; //optional

pCBDef.ColorRamp = pMultiPartColorRamp;

IFeatureRenderer pFeatureRenderer = pMapServer.GenerateDataClasses(strMapName, pLayerDescription, pCBDef);

See Also

IMapServer4 Interface