用CShape写一段ArcGis根据excel表格升成线的代码
时间: 2023-03-15 07:40:53 浏览: 121
在ArcGIS中应用EXCEL表格数据
答:ArcGis中用CShape写代码升成线,代码如下:Dim pWorkspaceFactory As IWorkspaceFactory
Dim pFeatWorkspace As IFeatureWorkspace
Dim pFeatClass As IFeatureClass
Dim pTable As ITable
Dim pCursor As ICursor
Dim pRow As IRow' Open the Excel file
Set pWorkspaceFactory = New ExcelWorkspaceFactory
Set pFeatWorkspace = pWorkspaceFactory.OpenFromFile("C:\Table.xlsx", 0)' Open the FeatureClass from the Excel file
Set pFeatClass = pFeatWorkspace.OpenFeatureClass("Table")' Create a Polyline from the Excel table
Set pTable = pFeatClass
Set pCursor = pTable.Search(Nothing, False)
Set pRow = pCursor.NextRowDim pPointColl As IPointCollection
Set pPointColl = New PolylineDo Until pRow Is Nothing
Dim pPoint As IPoint
Set pPoint = New Point
With pPoint
.X = pRow.Value(pRow.Fields.FindField("X"))
.Y = pRow.Value(pRow.Fields.FindField("Y"))
End With
pPointColl.AddPoint pPoint
Set pRow = pCursor.NextRow
LoopDim pGeometry As IGeometry
Set pGeometry = pPointColl' Add the Polyline to the FeatureClass
Dim pFeat As IFeature
Set pFeat = pFeatClass.CreateFeature
pFeat.Shape = pGeometry
pFeat.Store
阅读全文