阅读:1749回复:1
Raster图层某点的value值的读取
<P>'IRasterLayer,pPoint 的接口很简单,这里不祥细介绍了</P>
<P>Function GetPixelValue(pRlayer As IRasterLayer, pPoint As IPoint) As String Dim pBlockSize As IPnt Set pBlockSize = New DblPnt pBlockSize.SetCoords 1#, 1#</P> <P>Dim pPixelBlock As IPixelBlock Dim vValue As Variant Dim i As Long, j As Long Dim sPixelVals As String</P> <P>sPixelVals = ""</P> <P>Dim pRasterProps As IRasterProps Dim dXSize As Double, dYSize As Double Dim pPixel As IPnt Set pPixel = New DblPnt</P> <P>Set pPixelBlock = pRlayer.Raster.CreatePixelBlock(pBlockSize)</P> <P>Set pRasterProps = pRlayer.Raster dXSize = pRasterProps.Extent.XMax - pRasterProps.Extent.XMin dYSize = pRasterProps.Extent.YMax - pRasterProps.Extent.YMin</P> <P>dXSize = dXSize / pRasterProps.Width dYSize = dYSize / pRasterProps.Height</P> <P>pPixel.x = (pPoint.x - pRasterProps.Extent.XMin) / dXSize pPixel.y = (pRasterProps.Extent.YMax - pPoint.y) / dYSize</P> <P>pRlayer.Raster.Read pPixel, pPixelBlock For j = 0 To pPixelBlock.Planes - 1</P> <P> vValue = pPixelBlock.GetVal(0, 0, 0) sPixelVals = sPixelVals ; Format(vValue, "##.0") Next j GetPixelValue = sPixelVals End Function</P> |
|
1楼#
发布于:2004-06-01 09:07
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" />
|
|
|