Public Function GenerateClassBreaks(pFeatLayer As IFeatureLayer, sValFieldName As String, lNClass As Long, sClassification As String) As Variant ' classifies data using IClassify2 and Quantile classification, ' then creates ClassBreaksRenderer using these breaks, ' and assigns to first layer in the map On Error GoTo ErrorHandler Dim pFClass As IFeatureClass Dim pFeature As IFeature Dim pFCursor As IFeatureCursor Dim pTable As ITable Dim pClassifyGEN As IClassifyGEN Dim pTableHistogram As ITableHistogram Dim pHistogram As IHistogram Dim frqs As Variant, xVals As Variant Dim i As Integer Set pFClass = pFeatLayer.FeatureClass Set pFCursor = pFClass.Search(Nothing, False) Set pFeature = pFCursor.NextFeature Set pTable = pFClass 'Set pClassifyGEN = New Quantile Select Case sClassification Case "Equal Interval" Set pClassifyGEN = New EqualInterval Case "Natual Breaks" Set pClassifyGEN = New NaturalBreaks Case "Quantile" Set pClassifyGEN = New Quantile Case "Standard Deviation" Set pClassifyGEN = New StandardDeviation End Select 'Set pClassifyGEN = New EqualInterval Set pTableHistogram = New TableHistogram Set pHistogram = pTableHistogram pTableHistogram.Field = sValFieldName ' matches renderer field Set pTableHistogram.Table = pTable pHistogram.GetHistogram xVals, frqs pClassifyGEN.Classify xVals, frqs, lNClass ' use "iNClass" number of classes GenerateClassBreaks = pClassifyGEN.ClassBreaks GoTo Endproc ErrorHandler: MsgBox Err.Description, vbInformation, "GenerateClassBreaks" Endproc: Set pFClass = Nothing Set pFeature = Nothing Set pFCursor = Nothing Set pTable = Nothing Set pClassifyGEN = Nothing Set pTableHistogram = Nothing Set pHistogram = Nothing End Function
Dim pFClass As IFeatureClass Set pFClass = pFeatLayer.FeatureClass
Dim pFClass As IFeatureClass = pFeatLayer.FeatureClass
Public Function GenerateClassBreaks(pFeatLayer As IFeatureLayer, sValFieldName As String, lNClass As Integer, sClassification As String) As Object ' classifies data using IClassify2 and Quantile classification, ' then creates ClassBreaksRenderer using these breaks, ' and assigns to first layer in the map Try Dim pFClass As IFeatureClass Dim pFeature As IFeature Dim pFCursor As IFeatureCursor Dim pTable As ITable Dim pClassifyGEN As IClassifyGEN Dim pTableHistogram As ITableHistogram Dim pHistogram As IHistogram Dim frqs, xVals As Object Dim i As Integer pFClass = pFeatLayer.FeatureClass pFCursor = pFClass.Search(Nothing, False) pFeature = pFCursor.NextFeature pTable = pFClass 'Set pClassifyGEN = New Quantile Select Case sClassification Case "Equal Interval" pClassifyGEN = New EqualInterval() Case "Natual Breaks" pClassifyGEN = New NaturalBreaks() Case "Quantile" pClassifyGEN = New Quantile() Case "Standard Deviation" pClassifyGEN = New StandardDeviation() End Select 'Set pClassifyGEN = New EqualInterval pTableHistogram = New TableHistogram() pHistogram = pTableHistogram pTableHistogram.Field = sValFieldName ' matches renderer field pTableHistogram.Table = pTable pHistogram.GetHistogram(xVals, frqs) pClassifyGEN.Classify(xVals, frqs, lNClass) ' use "iNClass" number of classes GenerateClassBreaks = pClassifyGEN.ClassBreaks Catch ex As Exception MessageBox.Show(Information.Err().Description, "GenerateClassBreaks", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try End Function
Public Function GenerateClassBreaks(pFeatLayer As IFeatureLayer, sValFieldName As String, lNClass As Integer, sClassification As String) As Object
dim breaks() as double = pClassifyGEN. pClassifyGEN.ClassBreaks
Dim dataFrequency As Object = Nothing Dim dataValues As Object = Nothing Dim frqs As Integer() = TryCast(dataFrequency, Integer()) Dim xVals As Double() = TryCast(dataValues, Double())