阅读:4952回复:11
ArcEngine的分级显示问题(ClassbreakRenderer)
<P>请问各位大侠,在VB中如何用ArcGIS Engine对图层进行分组(分级)显示啊(ClassbreakRenderer)? 帮助文件中有如下代码:</P>
<P>Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim pTable As ITable Dim pClassify As IClassify Dim pTableHistogram As ITableHistogram Dim pHistogram As IHistogram Dim dataFrequency As Object Dim dataValues As Object Dim strOutput As String ' We're going to retrieve frequency data from a population field ' and then classify this data ' pTable = m_pGeoFeatureLayer pTableHistogram = New TableHistogram pHistogram = pTableHistogram</P> <P> ' Get values and frequencies for the population field ' into a table histogram object pTableHistogram.Field = strPopField1 pTableHistogram.Table = pTable pHistogram.GetHistogram(dataValues, dataFrequency)</P> <P> ' Put the values and frequencies into an Equal Interval classify object ' pClassify = New EqualInterval pClassify.SetHistogramData(dataValues, dataFrequency)</P> <P> ' Now a generate the classes ' Note: ' 1/ The number of classes returned may be different from requested ' (depends on classification algorithm) ' 2/ The classes array starts at index 0 and has datavalues starting ' from the minumum value, going to maximum ' Dim Classes() As Double Dim ClassesCount As Long</P> <P> pClassify.Classify(numDesiredClasses) Classes = pClassify.ClassBreaks ClassesCount = UBound(Classes)</P> <P> ' Initialise a new class breaks renderer and supply the number of ' class breaks and the field to perform the class breaks on. ' Dim pClassBreaksRenderer As IClassBreaksRenderer</P> <P> pClassBreaksRenderer = New ClassBreaksRenderer pClassBreaksRenderer.Field = strPopField1 pClassBreaksRenderer.BreakCount = ClassesCount pClassBreaksRenderer.SortClassesAscending = True</P> <P> ' Use an algorithmic color ramp to generate an range of colors between ' yellow to red (taken from ArcMaps colorramp properties) '</P> <P> ' Set the initial color to yellow ' Dim pFromColor As IHsvColor</P> <P> pFromColor = New HsvColor pFromColor.Hue = 60 ' Yellow pFromColor.Saturation = 100 pFromColor.Value = 96</P> <P> ' Set the final color to be red ' Dim pToColor As IHsvColor</P> <P> pToColor = New HsvColor pToColor.Hue = 0 ' Red pToColor.Saturation = 100 pToColor.Value = 96</P> <P> ' Set up the HSV colour ramp to span from yellow to red ' Dim pRamp As IAlgorithmicColorRamp Dim pEnumColors As IEnumColors Dim ok As Boolean</P> <P> pRamp = New AlgorithmicColorRamp pRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm pRamp.FromColor = pFromColor pRamp.ToColor = pToColor pRamp.Size = ClassesCount pRamp.CreateRamp(ok) pEnumColors = pRamp.Colors</P> <P> ' Iterate through each class brake, setting values and corresponding ' fill symbols for each polygon, note we skip the minimum value (classes(0)) ' Dim pColor As IColor Dim pFillSymbol As ISimpleFillSymbol Dim breakIndex As Long</P> <P> For breakIndex = 0 To ClassesCount - 1</P> <P> ' Retrieve a color and set up a fill symbol, ' put this in the symbol array corresponding to the class value ' pColor = pEnumColors.Next pFillSymbol = New SimpleFillSymbol pFillSymbol.Color = pColor pFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid pClassBreaksRenderer.Symbol(breakIndex) = pFillSymbol pClassBreaksRenderer.Break(breakIndex) = Classes(breakIndex + 1)</P> <P> ' Store each break value for user output strOutput = strOutput ; "- " ; Classes(breakIndex + 1) ; vbNewLine</P> <P> Next breakIndex</P> <P> ' Assign the renderer to the layer and update the display ' m_pGeoFeatureLayer.Renderer = pClassBreaksRenderer</P> <P> 'MapControl1.Refresh(esriViewGeography)</P> <P> 'txbOutput.Text = "Class Breaks Renderer" ; vbNewLine ; vbNewLine ; _ '"Fills the States polygons with a color according to population from field " ; strPopField1 ; "." ; vbNewLine ; _ '"Colors range from yellow (low) to red (high)." ; vbNewLine ; _ '"The " ; pClassify.MethodName ; " classification is used to generate " ; ClassesCount ; " classes." ; _ '"Class breaks are:" ; vbNewLine ; _ 'strOutput End Sub</P> <P>可是实际上这段代码无法工作,因为找不到"Dim pHistogram As IHistogram"和"pTableHistogram = New TableHistogram"这两行代码所定义的类型. 我把所有Engine的类库都添加引用,但还是没发现有这两个类, 请大侠指点!! <a href="mailttfsgis2@zaas.org" target="_blank" >tfsgis2@zaas.org</A></P> |
|
1楼#
发布于:2005-04-26 16:01
<P>你找不到这两行代码的定义类型是因为你没有引入必要的类库,同时,这段代码移植到VB.NET中是无法使用的,这是ESRI的一个BUG。呵呵</P>
|
|
2楼#
发布于:2005-04-27 11:25
帮助里没有IHistogram这个接口说明,但是engine是有这个接口的,我这里是有的,我只引用了所有engine的类型库
|
|
3楼#
发布于:2005-05-17 12:41
我把所有的Engine类库都引用了还是找不到, 在VB里和VS.NET里都不能用啊,
|
|
4楼#
发布于:2005-06-18 20:52
IHistogram和TableHistogram是desktop库中的接口和对象,用engine中相应的接口和对象替换就行了,分别是IBasicHistogram和BasicTableHistogram
|
|
5楼#
发布于:2005-06-28 16:15
谢谢这位大哥! 我原先就按这样改了,还是不行.
|
|
6楼#
发布于:2005-06-29 12:05
<H1>IHistogram Interface (<a href="mk:@MSITStore:C:\Program%20Files\ArcGIS\DeveloperKit\Help\Com\VB\esriCartoUI.chm::/CartoUI_library.htm" target="_blank" >esriCartoUI</A>)</H1>
<br> <P></P> <P>Provides access to members that control histogram objects created from different data sources. </P> <P><B>Product Availability</B></P> <DIV>Available with ArcGIS Desktop.</DIV> |
|
|
7楼#
发布于:2005-07-11 21:26
GIS说的对,IHistogram在 esriCartoUI中,以后遇到这种问题,用Develop Tools里的Esri Library Locator工具。
|
|
|
8楼#
发布于:2005-08-04 18:02
大哥,能具体点说说吗? 谢谢!
|
|
9楼#
发布于:2006-06-23 14:19
不错
|
|
上一页
下一页