阅读:1864回复:2
[讨论]内插等值线和等值面的奇怪现象
<P>
<P>Public Function ContourPolygon(sRasterPath As String, sRasterName As String, nInterval As Double, pMap As IMap)<BR> <BR> Dim pMathOp As IMathOp<BR> Set pMathOp = New RasterMathOps</P> <P> Dim pInputDataset As IGeoDataset<BR> <BR> Set pInputDataset = OpenRasterDataset(sRasterPath, sRasterName)</P> <P> Dim pOutputDataset As IGeoDataset<BR> Set pOutputDataset = pMathOp.Int(pInputDataset)<BR> <BR> Dim pRaster As IRaster<BR> Set pRaster = pOutputDataset<BR> Dim pRasterBands As IRasterBandCollection<BR> Set pRasterBands = pRaster</P> <P> Dim pRasterBand As IRasterBand<BR> Set pRasterBand = pRasterBands.Item(0)</P> <P> Dim pStats As IRasterStatistics<BR> Set pStats = pRasterBand.Statistics</P> <P> Dim nClass As Long<BR> nClass = CLng((pStats.Maximum - pStats.Minimum) / nInterval) + 1<BR> <BR> <BR> Dim pRasterLy As IRasterLayer<BR> Set pRasterLy = New RasterLayer<BR> pRasterLy.CreateFromRaster pRaster<BR> pRasterLy.Name = "等值面"<BR> <BR> 'UsingRasterStretchColorRampRender:方法来自AO Help<BR> ' Get raster input from layer<BR> <BR> ' Create classfy renderer and QI RasterRenderer interface<BR> Dim pClassRen As IRasterClassifyColorRampRenderer<BR> Set pClassRen = New RasterClassifyColorRampRenderer<BR> Dim pRasRen As IRasterRenderer<BR> Set pRasRen = pClassRen</P> <P> ' Set raster for the render and update<BR> Set pRasRen.Raster = pRaster<BR> pClassRen.ClassCount = nClass</P> <P>' pRasRen.Update</P> <P> ' Set raster for the renderer and update</P> <P> ' Define two colors<BR> Dim pFromColor As IColor<BR> Dim pToColor As IColor<BR> Set pFromColor = New RgbColor<BR> pFromColor.RGB = RGB(192, 101, 73)<BR> Set pToColor = New RgbColor<BR> pToColor.RGB = RGB(43, 255, 195)</P> <P> ' Create color ramp<BR> Dim pRamp As IAlgorithmicColorRamp<BR> Set pRamp = New AlgorithmicColorRamp<BR> pRamp.Size = nClass<BR> pRamp.FromColor = pFromColor<BR> pRamp.ToColor = pToColor<BR> pRamp.Algorithm = esriCIELabAlgorithm<BR> pRamp.CreateRamp True</P> <P> Dim pFSymbol As IFillSymbol<BR> Set pFSymbol = New SimpleFillSymbol</P> <P> ' loop through the classes and apply the color and label<BR> Dim i As Integer<BR> For i = 0 To pClassRen.ClassCount - 1<BR> pFSymbol.Color = pRamp.Color(i)<BR> pClassRen.Symbol(i) = pFSymbol<BR> pClassRen.Label(i) = "vaule" ; CStr(i)<BR> Next i</P> <P> pRasRen.Update</P> <P> ' Plug this colorramp into renderer and select a band</P> <P><BR> ' Update the renderer with new settings and plug into layer</P> <P> Set pRasterLy.Renderer = pClassRen<BR> pMap.AddLayer pRasterLy<BR> pMap.MoveLayer pRasterLy, pMap.LayerCount() - 1</P> <P> Set pRamp = Nothing<BR> Set pClassRen = Nothing<BR> Set pFSymbol = Nothing<BR></P> |
|
1楼#
发布于:2006-04-13 12:12
等值线,应该是四舍五入后得到的整型值来画的,所以。。。
|
|
2楼#
发布于:2006-04-13 12:17
等值线,应该是四舍五入后得到的整型值来画的,所以。。。
|
|