阅读:2595回复:5
关于调用shapefile文件属性表中的数据
<P>我是用VBA进行的开发,但一开始就遇到这个最基础的问题了。我要做的是在Arcmap中镶嵌一个自己专业方面的模块,选择模块后会将shapefile文件中的属性表里拿出数据进行操作,翻了很多资料,不知道用什么方法。倒是看到很多直接应用Table的命令,但这个Table不是我shapefile中attribute table 啊,请问有什么方法可以直接调用shapefile中属性数据的??</P>
|
|
|
1楼#
发布于:2007-03-03 20:29
<P>大概过程如下所示:</P>
<P> dim pfeatcls as ifeatureclass'</P> <P> dim peatlayer as ifeaturelayer</P> <P> dim pdoc as imxdocument</P> <P> dim pmap as imap</P> <P> set pmap =thisdocument.maps.item(0)</P> <P> set pfeatlayer = pmap.layer(0)</P> <P> set pfeatcls = pfeatlyaer.featureclass</P> <P> 上面着段代码主要是找到需要的要素类.如线,面,点类等,下面的代码用与读取</P> <P>字段数据:</P> <P> dim ptable as itable</P> <P> set ptable = pfeatlayer.attributetable</P> <P> 接下来,就可以采用itable 提供的方法,来对表中的数据进行运算了.</P> <P> 如有问题,在说</P> <P> </P> <P> </P> |
|
2楼#
发布于:2007-03-03 20:37
感谢楼主的辛苦劳动
|
|
3楼#
发布于:2007-03-04 09:31
<P>非常感谢<STRONG><FONT face=Verdana color=#61b713>zpgis2002!!!不过我发现Ifeaturelayer和Ifeatreclass接口都没有attributetalbe的方法/属性啊,查了arcgis developer help,也没有的。</FONT></STRONG></P>
[此贴子已经被作者于2007-3-4 9:47:09编辑过]
|
|
|
4楼#
发布于:2007-03-04 10:07
<P>不过倒是有iattributetable这个接口,但不知道怎么把这个给调用出来。怎么个QI法不清楚啊,讨论讨论!!</P>
<P>我看到rasterband是有attributertable这个方法属性的,但对feature来说,真的没找着。</P> [此贴子已经被作者于2007-3-4 10:09:45编辑过]
|
|
|
5楼#
发布于:2007-03-04 14:28
<P>搞定了,原来直接QI就行了,如下</P>
<P> Dim pFeatLayer As IFeatureLayer<BR> Dim pTable As ITable<BR> Set pFeatLayer = pMap.Layer(0)<BR> Set pTable = pFeatLayer</P> <P>这时就可以直接用Itable的属性和方法了。此问题到此结束,谢谢大家关注<BR> </P> |
|
|