moline
路人甲
路人甲
  • 注册日期2003-10-27
  • 发帖数36
  • QQ
  • 铜币53枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1580回复:1

Raster图层某点的value值的读取

楼主#
更多 发布于:2004-05-30 21:19
<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>
喜欢0 评分0
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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" />
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部