ImageVerifierCode 换一换
你正在下载:

AOSample.doc

[预览]
格式:DOC , 页数:18 ,大小:125.50KB ,
资源ID:7780649      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/7780649.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(AOSample.doc)为本站上传会员【pc****0】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

AOSample.doc

1、在ArcMap中,进行属性查询的时候,Arcmap中提供了选中字段的属性的Unique Value。这样就可以从列表中选择了。以前也遇到类似问题,一直不知道怎么做,好在当时使用的ArcSDE Oracle数据,使用了一个SQL语句解决了。不过要是Coverage就没有办法了。其实AO中提供了这样的功能了,可通过IDataStatistics来实现,做了一个函数,参数为图层和字段,返回该图层该字段的所有Unique Value 1.'下面程序段是用来列出ArcMap中,指定图层和字段中,所有Unique Value Public Function listUniqueValue(pLa

2、yer As IFeatureLayer, pFieldName As String) As String()  Dim pCursor As ICursor  Set pCursor = pLayer.Search(Nothing, False)  Dim pDataStat As IDataStatistics  Dim pValue As Variant  Set pDataStat = New DataStatistics  pDataStat.Field = pFieldName  Set pDataStat.Cursor = pCursor  Dim pEnumVa

3、r As IEnumVariantSimple  Set pEnumVar = pDataStat.UniqueValues  pValue = pEnumVar.Next  Dim i As Long  'Dim count As Long  'count = pDataStat.UniqueValueCount  i = 0  Dim value(200) As String '数组的长度按说应该使用pDataStat.UniqueValueCount来控制,但是编译只能使用               '常数,不能使用变量  Do Until IsEmpty(pValu

4、e)   value(i) = pValue   i = i + 1   pValue = pEnumVar.Next  Loop  listUniqueValue = value() End Function 2.打开图层属性表 (ArcMap VBA) '下面程序段是用来列出ArcMap中,指定图层和字段中,所有Unique Value Public Sub OpenFeatureLayerTable() Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pLayer As IFeatureLayer Di

5、m pTable As ITableWindow Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap Set pLayer = pMap.Layer(0) 'Instantiate the Table window Set pTable = New TableWindow 'Associate the table and a feature layer Set pTable.FeatureLayer = pLayer Set pTable.Application = Application 'Open the table

6、 pTable.Show True End Sub 3.AO中加载SDE中的Raster数据 (ArcMap VBA/VB AO) Public Function GetRasterFromSDE(sServer As String, sInstance As String, _ sUser As String, sPassword As String, sSDERaster As String, Optional version As String = "SDE.DEFAULT") As IRasterDataset   '加载栅格函数 ' sServer,sInst

7、ance,sDB,sUser,sPasswd: ArcSDE connection info ' sSDERaster: the ArcSDE raster dataset name Dim pSDEWs As IWorkspaceName Dim pSDEPropertySet As IPropertySet Dim pSDERasterDataset As IRasterDataset Dim pDsName As IDatasetName Dim pName As IName ' Dim sQualifiedName As String ' Get connection

8、propertyset Set pSDEPropertySet = New PropertySet With pSDEPropertySet  .SetProperty "Server", sServer  .SetProperty "Instance", sInstance  ' .SetProperty "Database", sDB  .SetProperty "User", sUser  .SetProperty "Password", sPassword  .SetProperty "Version", version End With ' Get worksp

9、acename Set pSDEWs = New WorkspaceName pSDEWs.ConnectionProperties = pSDEPropertySet pSDEWs.WorkspaceFactoryProgID = "esricore.sdeworkspacefactory" ' Get raster dataset name Set pDsName = New RasterDatasetName pDsName.Name = sSDERaster Set pDsName.WorkspaceName = pSDEWs Set pName = pDsName

10、' Open ArcSDE raster dataset Set pSDERasterDataset = pName.Open ' Cleanup Set GetRasterFromSDE = pSDERasterDataset Set pSDEWs = Nothing Set pSDERasterDataset = Nothing Set pSDEPropertySet = Nothing Set pName = Nothing Set pDsName = Nothing End Function 4.AO中直接加载ArcSDE矢量数据 Public Function

11、 addSDEData(Server As String, Instance As String, User As String, _  Password As String, featureClass As String, Optional version As String = "SDE.DEFAULT")  On Error GoTo EH  Dim pWorkspaceFactory As IWorkspaceFactory  Dim pWorkspace As IFeatureWorkspace  Dim pPropSet As IPropertySet  Dim pC

12、lass As IFeatureClass  Dim pLayer As IFeatureLayer  Dim pMxDoc As IMxDocument  Set pWorkspaceFactory = New SdeWorkspaceFactory  Set pPropSet = New PropertySet  With pPropSet '设置ArcSDE连接属性   .SetProperty "SERVER", Server   .SetProperty "INSTANCE", Instance   .SetProperty "USER", User   .SetP

13、roperty "PASSWORD", Password   .SetProperty "VERSION", version '可选,缺省为SDE.DEFAULT版本  End With  Set pWorkspace = pWorkspaceFactory.Open(pPropSet, 0)  Set pClass = pWorkspace.OpenFeatureClass(featureClass)  Set pLayer = New FeatureLayer  Set pLayer.featureClass = pClass  pLayer.Name = pClass.Al

14、iasName    Set pMxDoc = ThisDocument  pMxDoc.AddLayer pLayer  pMxDoc.ActiveView.PartialRefresh esriViewGeography, pLayer, Noting  Exit Function EH:  MsgBox Err.Description, vbInformation, "加载数据错误" End Function 5.对选中要素进行属性统计 Public Sub SumSelectedFeatures() Dim pMxDoc As IMxDocument Di

15、m pmap As IMap Dim player As IFeatureLayer Dim pFcc As IFeatureClass Dim pFields As IFields Dim pNumFields As IFields Dim numAreaField As Double Dim pField As IField Set pMxDoc = ThisDocument Set pmap = pMxDoc.FocusMap Set player = pmap.Layer(0) Set pFcc = player.FeatureClass Set pFields

16、 pFcc.Fields 'Get a field to Sum Set pNumFields = pFields numAreaField = pFields.FindField("pop1997") ' <--Enter a field here 'Check for a valid field index number If numAreaField < 0 Then MsgBox "Please enter a Valid field name", vbCritical, "Field Doesn't Exist" Exit Sub End If Set pFiel

17、d = pFields.Field(numAreaField) '***Other useful field stuff*** '.FindField("AREA") 'MsgBox numAreaField 'MsgBox pField.Name 'MsgBox pFields.FieldCount 'MsgBox player.Name 'Get the selected records Dim pFeatureSelection As IFeatureSelection Set pFeatureSelection = player Dim pSelected As I

18、SelectionSet Set pSelected = pFeatureSelection.SelectionSet Dim pCursor As ICursor pSelected.Search Nothing, False, pCursor Dim pfeature As IFeature Dim counter As Integer counter = 0 Dim sumAREA As Double sumAREA = 0 Set pfeature = pCursor.NextRow Do Until pfeature Is Nothing counter = c

19、ounter + 1 sumAREA = sumAREA + pfeature.Value(numAreaField) Set pfeature = pCursor.NextRow Loop MsgBox "Total " & pField.Name & " is: " & sumAREA 'MsgBox counter & " Selected records" End Sub 6.在ArcMap LayOut中增加文字 Private pMxApp As IMxApplication Private pMxDoc As IMxDocument Private pDi

20、sp As IScreenDisplay Private pEnv As IEnvelope Private pPoint As IPoint Private pColor As IRgbColor Private pLayout As IPageLayout Private pMapSurround As IMapSurround Private pNSurround As INorthArrow Private pGContainer As IGraphicsContainer Private pEnumLayer As IEnumLayer Private pFLaye

21、r As ILayer Private pBLayer As ILayer Public Sub AddTextToLayout() 'Button to place text on the layout ' 'Reference App, Doc, Disp, Layout, and GraphicContainer Set pMxApp = Application Set pMxDoc = Document Set pDisp = pMxApp.Display Set pLayout = pMxDoc.ActiveView Set pGContainer = pLay

22、out 'Create a TextElement Dim pTxtElement As ITextElement Set pTxtElement = New TextElement 'Create a TextSymbol and a font Dim pTxtSym As ITextSymbol Set pTxtSym = New TextSymbol Dim pFont As IFontDisp Set pFont = New StdType.StdFont 'Set some properties of the font pFont.Name = "Courier"

23、 pFont.Bold = True pFont.Italic = True pFont.Size = 30 'Set the TextSymbol's FONT property with the font pTxtSym.Font = pFont 'Set the TextElement's SYMBOL property with the TextSymbol 'Set the TextElement's TEXT property with the desired text pTxtElement.Symbol = pTxtSym pTxtElement.Text =

24、 "This is a test" 'Create an Envelope to define the TextElement's GEOMETRY 'Create a Point to define the Envelope's LL and UR (extent) Set pEnv = New Envelope Set pPoint = New Point pPoint.x = 2 'first define LL coords pPoint.y = 8 '<--these are page units pEnv.LowerLeft = pPoint pPoint.x =

25、7 'now define UR coords pPoint.y = 10 pEnv.UpperRight = pPoint 'Create a pointer to the IElement interface, QI Dim pElement As IElement Set pElement = pTxtElement 'Set the Element's GEOMETRY property with the Envelope pElement.Geometry = pEnv 'Prepare display for drawing (Activate), AddEleme

26、nt to the 'GraphicsContainer, then Draw pElement.Activate pDisp '<-without this, BAD things happen! pGContainer.AddElement pElement, 1 pMxDoc.ActiveView.Refresh End Sub 7.VB+AO增加shapefile数据 Private Sub Form_Load() Dim pWorkspaceFactory As IWorkspaceFactory Dim pWorkspace As IFeatureWorks

27、pace Dim pFClass As IFeatureClass Dim pLayer As IFeatureLayer Set pWorkspaceFactory = New ShapefileWorkspaceFactory '获取目录 Set pWorkspace = pWorkspaceFactory.OpenFromFile("D:\data\", 0) '获取shapefile名 Set pFClass = pWorkspace.OpenFeatureClass("result") Set pLayer = New FeatureLayer Set pLayer

28、FeatureClass = pFClass MapControl1.AddLayer pLayer MapControl1.Refresh End Sub 8.VBA增加Raster数据 Public Sub AddRasterLayer() Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pLayer As IRasterLayer Dim pWF As IWorkspaceFactory Dim pW As IWorkspace Dim pFW As IRasterWorkspace Dim

29、pDataset As IDataset Dim pRDataset As IRasterDataset Set pWF = New RasterWorkspaceFactory 'Enter path to workspace that contains your grid Set pW = pWF.OpenFromFile("C:\data") 'QI Set pFW = pW 'Enter Name of Grid folder Set pRDataset = pFW.OpenRasterDataset("LakeDepth") 'Use the grid to cre

30、ate a raster layer Dim pRLayer As IRasterLayer Set pRLayer = New RasterLayer pRLayer.CreateFromDataset pRDataset 'Add the raster layer to a map Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap pMxDocument.AddLayer pRLayer 'Set the layer name 'Set the display extent End Sub

31、 9.Merge Layer (VB+AO) '兔八哥以前写的,现在也放这吧 Public Function Merge(pathLayer1 As String, pathLayer2 As String, pathMergeResult As String, _ nameLayer1 As String, nameLayer2 As String, nameMergeResult As String) ' 分别读取图层一,图层二到FeatureClass和Table中 Dim pWorkspaceFactory As IWorkspaceFactory Dim pWo

32、rkspace1 As IFeatureWorkspace Dim pWorkspace2 As IFeatureWorkspace Dim pFirstFeatClass As IFeatureClass Dim pSecondFeatClass As IFeatureClass Dim pFirstTable As ITable Dim pSecondTable As ITable Dim pFeatLayer1 As IFeatureLayer Set pFeatLayer1 = New FeatureLayer Dim pFeatLayer2 As IFeatureL

33、ayer Set pFeatLayer2 = New FeatureLayer Set pWorkspaceFactory = New ShapefileWorkspaceFactory Set pWorkspace1 = pWorkspaceFactory.OpenFromFile(pathLayer1, 0) Set pWorkspace2 = pWorkspaceFactory.OpenFromFile(pathLayer2, 0) Set pFirstFeatClass = pWorkspace1.OpenFeatureClass(nameLayer1) Set pSeco

34、ndFeatClass = pWorkspace2.OpenFeatureClass(nameLayer2) Set pFeatLayer1.FeatureClass = pFirstFeatClass Set pFirstTable = pFeatLayer1 Set pFeatLayer2.FeatureClass = pSecondFeatClass Set pSecondTable = pFeatLayer2 ' 检查错误 If pFirstTable Is Nothing Then  MsgBox "Table QI failed"  Exit Function E

35、nd If If pSecondTable Is Nothing Then  MsgBox "Table QI failed"  Exit Function End If ' 定义输出要素类名称和shape类型 Dim pFeatClassName As IFeatureClassName Set pFeatClassName = New FeatureClassName With pFeatClassName .FeatureType = esriFTSimple .ShapeFieldName = "Shape" .ShapeType = pFirstFeatClas

36、s.ShapeType End With ' 定义输出shapefile位置与名称 Dim pNewWSName As IWorkspaceName Set pNewWSName = New WorkspaceName With pNewWSName .WorkspaceFactoryProgID = "esriCore.ShapefileWorkspaceFactory" .PathName = pathMergeResult End With Dim pDatasetName As IDatasetName Set pDatasetName = pFeatClassNa

37、me pDatasetName.Name = nameMergeResult Set pDatasetName.WorkspaceName = pNewWSName ' 定义Merge参数 Dim inputArray As IArray Set inputArray = New esriCore.Array inputArray.Add pFirstTable inputArray.Add pSecondTable ' 进行Merge操作 Dim pBGP As IBasicGeoprocessor Set pBGP = New BasicGeoprocessor Di

38、m pOutputFeatClass As IFeatureClass Set pOutputFeatClass = pBGP.Merge(inputArray, pFirstTable, pFeatClassName) End Function 10.GraphicsLayer中增加一个点 Public Sub AddPointToGraphicsLayer() Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pMxApp As IMxApplication Set pMxApp = Applicat

39、ion Dim pMap As IMap Set pMap = pMxDoc.FocusMap 'Instantiate the composite graphics layer Dim pCGLayer As ICompositeGraphicsLayer Set pCGLayer = New CompositeGraphicsLayer 'QI for ILayer to set the layer's name Dim pLayer As ILayer Set pLayer = pCGLayer pLayer.Name = "TestPoint" 'Add the l

40、ayer to the map pMap.AddLayer pCGLayer 'Set some x and y values or read them from somewhere Dim x As Double Dim y As Double x = 200 y = 200 'Make a point Dim pPnt As IPoint Set pPnt = New Point pPnt.x = x pPnt.y = y 'Set color and symbol for the point, Blue Dim pColor As IRgbColor Set

41、pColor = New RgbColor pColor.Blue = 255 pColor.Green = 0 pColor.Red = 0 Dim pSimpleMarkerSymbol As ISimpleMarkerSymbol Set pSimpleMarkerSymbol = New SimpleMarkerSymbol With pSimpleMarkerSymbol .Style = esriSMSCircle .Size = 4 .Color = pColor End With 'Create a marker element Dim pMarkerE

42、lement As IMarkerElement Set pMarkerElement = New MarkerElement pMarkerElement.Symbol = pSimpleMarkerSymbol Dim pElement As IElement Set pElement = pMarkerElement pElement.Geometry = pPnt 'Get the graphics layer and screen display Dim pGrLayer As IGraphicsLayer Set pGrLayer = pCGLayer Dim p

43、ScreenDisplay As IScreenDisplay Set pScreenDisplay = pMxApp.Display 'Add the marker element ot the layer graphics container Dim pGraphicCont As IGraphicsContainer Set pGraphicCont = pGrLayer pGraphicCont.AddElement pMarkerElement, 0 With pScreenDisplay .ActiveCache = 0 .StartDrawing pScreenD

44、isplay.hDC, 0 .SetSymbol pSimpleMarkerSymbol pElement.Draw pScreenDisplay, Nothing .FinishDrawing End With 'Refresh/redraw the display with the new point pMxDoc.ActiveView.Refresh End Sub 11. 对ArcMap显示区域大小进行缩放 '本例用来对ArcMap显示区域进行放达2倍,修改2为你需要的放大比例 Private Sub UIButtonControl1_Click()   

45、Dim pMxApp As IMxApplication   Dim pMxDoc As IMxDocument   Dim pDisp As IScreenDisplay   Dim pPoint As IPoint   Dim pCenterPoint As IPoint   '获得当前Display   Set pMxApp = Application   Set pDisp = pMxApp.Display   Set pMxDoc = Document   '获取当前显示区域   Dim pCurrentEnv As IEnvelope   Dim pEnv

46、As IEnvelope   Set pCurrentEnv = pMxDoc.ActiveView.Extent.Envelope   Set pEnv = pMxDoc.ActiveView.Extent.Envelope   '设置显示范围为当前的1/2   pEnv.Height = pCurrentEnv.Height / 2   pEnv.Width = pCurrentEnv.Width / 2   '设置新的显示区域的中心为原来显示区域中心   Set pPoint = New Point   Set pCenterPoint = New Point   pC

47、enterPoint.X = pCurrentEnv.LowerLeft.X + pCurrentEnv.Width / 2   pCenterPoint.Y = pCurrentEnv.LowerLeft.Y + pCurrentEnv.Height / 2   pEnv.CenterAt pCenterPoint   '设置视图显示区域   pMxDoc.ActiveView.Extent = pEnv   pMxDoc.ActiveView.Refresh End Sub 12. 复制一个FeatureClass '复制一个FeatureClass Public

48、Function hCopyFC(ByVal myinstr As String, ByVal myoutstr As String) As Boolean  Dim hOUTshwsname As IWorkspaceName  Dim hOutshDSName As IDatasetName  Dim hInWorkspaceName As IWorkspaceName  Dim hDatasetName As IDatasetName  Dim htoshape As IFeatureDataConverter  Dim htname As IFeatureClassNam

49、e  Dim houttname As IFeatureClassName  Set hInWorkspaceName = New WorkspaceName  hInWorkspaceName.PathName = strdir + "\template\template.mdb" '数据模板  hInWorkspaceName.WorkspaceFactoryProgID = "esriCore.AccessWorkspaceFactory.1"  Set htname = New FeatureClassName  Set hDatasetName = htname  Se

50、t hDatasetName.WorkspaceName = hInWorkspaceName  hDatasetName.Name = myinstr  Set hOUTshwsname = New WorkspaceName  hOUTshwsname.PathName = strpathname '当前数据路径  hOUTshwsname.WorkspaceFactoryProgID = "esriCore.AccessWorkspaceFactory.1"  Set houttname = New FeatureClassName  Set hOutshDSName = h

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服