eagling
路人甲
路人甲
  • 注册日期2004-10-21
  • 发帖数126
  • QQ
  • 铜币540枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2157回复:5

遇到奇怪问题,探讨探讨

楼主#
更多 发布于:2006-10-04 16:15
我的想法是要把栅格文件类型中每个cell的值读出来,现在只能做出有某个值的cell有多少个(如值是5的cell有1022个)。但是遇到了奇怪的问题,我这段码对jpg,dem等都有效,不过遇到由ploygon转过来(用feature to raster)的栅格文件就会出现错误,此栅格文件有属性表。错误截图附上,请问是为什么??大家讨论下!<br>
[此贴子已经被作者于2006-10-4 16:18:12编辑过]
喜欢0 评分0
中国GIS的未来,要靠GIS农民创造.
eagling
路人甲
路人甲
  • 注册日期2004-10-21
  • 发帖数126
  • QQ
  • 铜币540枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-10-07 10:19
<P>Sub countnumber()</P>
<P>Dim pMap As IMap<BR>Dim pMxDocument As IMxDocument<BR>Set pMxDocument = ThisDocument<BR>Set pMap = pMxDocument.FocusMap</P>
<P>Dim pRasterlayer As IRasterLayer<BR>Set pRasterlayer = pMap.Layer(0)</P>
<P>Dim pRaster As IRaster<BR>Set pRaster = pRasterlayer.Raster</P>
<P>Dim pRasBC As IRasterBandCollection<BR>Set pRasBC = pRaster</P>
<P>Dim pRasterBand As IRasterBand<BR>Set pRasterBand = pRasBC.Item(0)</P>
<P>' This example shows the usage of the IRawPixels interface to<BR>' Read and write pixels to a raster band that is passed in.<BR>' QI for the IRawPixels interface<BR>Dim pRawPixels As IRawPixels<BR>Set pRawPixels = pRasterBand</P>
<P>' QI for the IRasterProps interface to get height and width<BR>Dim pProps As IRasterProps<BR>Set pProps = pRaster</P>
<P>Dim pPnt As IPnt<BR>Set pPnt = New DblPnt<BR>pPnt.SetCoords pProps.Width, pProps.Height</P>
<P>' Use the RawPixels interface to create a new PixelBlock<BR>Dim pPixelBlock As IPixelBlock<BR>Set pPixelBlock = pRawPixels.CreatePixelBlock(pPnt)<BR>' Create a new point to specify where to begin reading, then read<BR>' Note:the origin is specified in pixel (or image) coordinates<BR>Dim pOrigin As IPnt<BR>Set pOrigin = New DblPnt<BR>pOrigin.SetCoords 0, 0<BR>pRawPixels.Read pOrigin, pPixelBlock</P>
<P>' get the variant SafeArray from the pixelblock<BR>Dim vPixels As Variant<BR>vPixels = pPixelBlock.SafeArray(0)</P>
<P>Dim i As Long, j As Long, sum As Long, value As Double</P>
<P>value = InputBox("请输入元胞的值:", "输入框")</P>
<P>For i = 0 To pProps.Width - 1<BR>For j = 0 To pProps.Height - 1<BR> If vPixels(i, j) = value Then sum = sum + 1<BR> Next<BR>Next</P>
<P>MsgBox "此栅格图层中值为" ; value ; "的元胞有" ; sum ; "个"</P>
<P>End Sub<BR></P>
中国GIS的未来,要靠GIS农民创造.
举报 回复(0) 喜欢(0)     评分
whmwxhanshan123
路人甲
路人甲
  • 注册日期2006-06-17
  • 发帖数3108
  • QQ
  • 铜币6445枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-10-07 21:05
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" />
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-10-08 22:02
<img src="images/post/smile/dvbbs/em08.gif" /><img src="images/post/smile/dvbbs/em03.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
eagling
路人甲
路人甲
  • 注册日期2004-10-21
  • 发帖数126
  • QQ
  • 铜币540枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-10-10 12:19
兄弟们有没遇到过这种问题啊??
中国GIS的未来,要靠GIS农民创造.
举报 回复(0) 喜欢(0)     评分
eagling
路人甲
路人甲
  • 注册日期2004-10-21
  • 发帖数126
  • QQ
  • 铜币540枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-10-14 16:53
我发现有些有属性表的栅格文件也能用,只不过它的pixle type是unsigned integer的,这个unsigned integer是什么意思,有什么办法可以把signed integer的改成unsigned integer的
中国GIS的未来,要靠GIS农民创造.
举报 回复(0) 喜欢(0)     评分
游客

返回顶部