ybtang
路人甲
路人甲
  • 注册日期2005-05-04
  • 发帖数15
  • QQ
  • 铜币175枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2034回复:2

AO开发:将TIn 转换为栅格Grid需要的接口是那些?

楼主#
更多 发布于:2006-05-19 16:04
现在我需要将Tin生成Slope,在ArcMap里面当然可以直接生成了,但是用AO进行二次开发就是找不到需要的接口,希望知道的能指点一下,如果能列出AO里的samoles那跟更好了,呵呵。还有就是对生成的SLope栅格,表数据我查询了一下,有一个字段是“strech value”,另外一个是“slope value”,怎么获取这些点的值呢?希望大家能指点迷津,谢谢了。
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-05-19 17:34
<P>   这个函数可以转,</P>

<P> ' Supported pixel types limited to float and long because output currently limited to native ESRI Grid<BR>    ' This routine handles cancel tracking so passed TIN should not have its CancelTracker set.<BR>    Public Function TinToRaster(ByRef pTin As ESRI.ArcGIS.Geodatabase.ITinAdvanced, ByRef eRastConvType As ESRI.ArcGIS.Geodatabase.esriRasterizationType, ByRef sDir As String, ByRef sName As String, ByRef ePixelType As ESRI.ArcGIS.Geodatabase.rstPixelType, ByRef cellsize As Double, ByRef pExtent As ESRI.ArcGIS.Geometry.IEnvelope, ByRef bPerm As Boolean) As ESRI.ArcGIS.Geodatabase.IRasterDataset</P>
<P>        ' The origin used by CreateRasterDataset is the lower left cell corner.<BR>        ' The extent passed is that of the TIN's.<BR>        ' Define the raster origin and number of rows and columns so that the raster<BR>        ' is of sufficient extent to capture area defined by passed envelope. The cell<BR>        ' center is located at the origin.<BR>        Dim pOrigin As ESRI.ArcGIS.Geometry.IPoint<BR>        pOrigin = pExtent.LowerLeft<BR>        pOrigin.X = pOrigin.X - (cellsize * 0.5)<BR>        pOrigin.Y = pOrigin.Y - (cellsize * 0.5)</P>
<P>        Dim nCol, nRow As Integer<BR>        nCol = System.Math.Round(pExtent.Width / cellsize) + 1<BR>        nRow = System.Math.Round(pExtent.Height / cellsize) + 1</P>
<P>        Dim pGDS As ESRI.ArcGIS.Geodatabase.IGeoDataset<BR>        pGDS = pTin<BR>        Dim pSR As ESRI.ArcGIS.Geometry.ISpatialReference2<BR>        pSR = pGDS.SpatialReference</P>
<P>        Dim pRDS As ESRI.ArcGIS.Geodatabase.IRasterDataset<BR>        pRDS = dbUtil.CreateRasterSurf(sDir, sName, "GRID", pOrigin, nCol, nRow, cellsize, cellsize, ePixelType, pSR, bPerm)</P>
<P>        System.Windows.Forms.Application.DoEvents()</P>
<P>        Dim pRawPixels As ESRI.ArcGIS.DataSourcesRaster.IRawPixels<BR>        pRawPixels = dbUtil.GetRawPixels(pRDS, 0)</P>
<P>        Dim pCache As stdole.IUnknown<BR>        pCache = pRawPixels.AcquireCache</P>
<P>        Dim pTinSurf As ESRI.ArcGIS.Geodatabase.ITinSurface<BR>        pTinSurf = pTin</P>
<P>        Dim pRasterProps As ESRI.ArcGIS.DataSourcesRaster.IRasterProps<BR>        pRasterProps = pRawPixels</P>
<P>        Dim nodataFloat As Single<BR>        Dim nodataInt As Integer</P>
<P>        Dim dZMin As Double</P>
<P>        dZMin = pTin.Extent.ZMin</P>
<P>        Dim vNoData As Object<BR>        If (ePixelType = ESRI.ArcGIS.Geodatabase.rstPixelType.PT_FLOAT) Then</P>
<P>            vNoData = CSng(dZMin - 1)<BR>        Else</P>
<P>            vNoData = CInt(dZMin - 1)<BR>        End If</P>
<P>        '<BR>        pRasterProps.NoDataValue = -9999 'vNoData</P>
<P>        Dim pOffset As ESRI.ArcGIS.Geodatabase.IPnt<BR>        pOffset = New ESRI.ArcGIS.DataSourcesRaster.DblPnt</P>
<P>        ' Set blocksize. Restrict how large it is as not to consume too much memory for<BR>        ' big output datasets.<BR>        Dim lMaxBlockX As Integer<BR>        lMaxBlockX = 2048<BR>        If (nCol < lMaxBlockX) Then<BR>            lMaxBlockX = nCol<BR>        End If</P>
<P>        Dim lMaxBlockY As Integer<BR>        lMaxBlockY = 2048<BR>        If (nRow < lMaxBlockY) Then<BR>            lMaxBlockY = nRow<BR>        End If</P>
<P>        Dim pBlockSize As ESRI.ArcGIS.Geodatabase.IPnt<BR>        pBlockSize = New ESRI.ArcGIS.DataSourcesRaster.DblPnt<BR>        pBlockSize.X = lMaxBlockX<BR>        pBlockSize.Y = lMaxBlockY</P>
<P>        Dim pPixelBlock As ESRI.ArcGIS.DataSourcesRaster.IPixelBlock3<BR>        pPixelBlock = pRawPixels.CreatePixelBlock(pBlockSize)</P>
<P>        Dim blockArray As Object<BR>    <BR>        blockArray = pPixelBlock.PixelDataByRef(0)</P>
<P>        Dim lBlockCount As Integer<BR>        lBlockCount = System.Math.Round((nCol / lMaxBlockX) + 0.49) * System.Math.Round((nRow / lMaxBlockY) + 0.49)</P>
<P>        Dim pBlockOrigin As ESRI.ArcGIS.Geometry.IPoint<BR>        pBlockOrigin = New ESRI.ArcGIS.Geometry.Point</P>
<P>        Dim lColOffset As Integer<BR>        Dim lRowOffset As Integer</P>
<P>        ' Left to right, top to bottom, iteration of pixel blocks.<BR>        Dim bReset As Boolean<BR>        For lRowOffset = 0 To (nRow - 1) Step lMaxBlockY</P>
<P>            For lColOffset = 0 To (nCol - 1) Step lMaxBlockX</P>
<P>                ' See if pixelblock needs to be resized in X for last column chunk.<BR>                ' RawPixel.Write will clip the pixelblock if it's too big, so the resize<BR>                ' isn't absolutely necessary, but resizing will eliminate unecessary<BR>                ' effort for TIN's QueryPixelBlock.<BR>                If ((nCol - lColOffset) < lMaxBlockX) Then<BR>                    pBlockSize.X = (nCol - lColOffset)<BR>                    pPixelBlock = pRawPixels.CreatePixelBlock(pBlockSize)<BR>                  <BR>                    blockArray = pPixelBlock.PixelDataByRef(0)<BR>                End If</P>
<P>                ' QueryPixelBlock takes an origin representing the upper left cell center.<BR>                ' Calculate that cell center's position here. Calculate it based on the<BR>                ' raster's origin (lower left) and current row/col offset.<BR>                pBlockOrigin.X = pOrigin.X + (lColOffset * cellsize) + (cellsize * 0.5)<BR>                pBlockOrigin.Y = pOrigin.Y + ((nRow - lRowOffset) * cellsize) - (cellsize * 0.5)</P>
<P><BR>                pTinSurf.QueryPixelBlock(pBlockOrigin.X, pBlockOrigin.Y, cellsize, cellsize, eRastConvType, vNoData, blockArray)</P>
<P>                pOffset.X = lColOffset<BR>                pOffset.Y = lRowOffset</P>
<P>                ' The offset for 'write' is the upper left of the pixel block by col/row number.<BR>                ' Base is 0.</P>
<P>                pRawPixels.Write(pOffset, pPixelBlock)</P>

<P>            Next lColOffset</P>
<P>            ' See if pixelblock size needs to be reset for columns<BR>            bReset = False<BR>            If (pBlockSize.X <> lMaxBlockX) Then<BR>                pBlockSize.X = lMaxBlockX<BR>                bReset = True<BR>            End If</P>
<P>            ' See if pixelblock size needs to be reset for rows<BR>            If ((nRow - lRowOffset) < lMaxBlockY) Then<BR>                pBlockSize.Y = (nRow - lRowOffset)<BR>                bReset = True<BR>            End If</P>
<P>            If (bReset) Then<BR>                pPixelBlock = pRawPixels.CreatePixelBlock(pBlockSize)<BR>              <BR>                blockArray = pPixelBlock.PixelDataByRef(0)<BR>            End If</P>
<P>        Next lRowOffset</P>
<P>        pRawPixels.ReturnCache(pCache)</P>
<P>        pCache = Nothing</P>

<P>        pRDS = Nothing</P>
<P>        pRawPixels = Nothing</P>
<P>        pPixelBlock = Nothing</P>
<P>        pRasterProps = Nothing</P>
<P>        blockArray = 0<BR>        pRDS = dbUtil.OpenRasterDataset(sDir, sName)</P>
<P><BR>        If (lBlockCount = 1) Then</P>
<P>            pTin.TrackCancel = Nothing<BR>        End If</P>
<P>        TinToRaster = pRDS<BR>        Exit Function<BR>        '</P>
<P>    End Function</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
ybtang
路人甲
路人甲
  • 注册日期2005-05-04
  • 发帖数15
  • QQ
  • 铜币175枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-05-20 00:10
居然有这个函数,我找了Tin开头和raster开头得借口没有发现,真是太感谢了,明天去试试。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部