在程序里完成,提高效率的方法,在程序面上完成这个任务。,不用把100万的数据加载进来。
CreateFeatureClass Method (esriGeoDatabase)
Example
Creates a new standalone feature class under the workspace.
Syntax
Set variable = object.CreateFeatureClass (Name, Fields, CLSID, EXTCLSID, FeatureType, ShapeFieldName, ConfigKeyword )
The CreateFeatureClass method syntax has the following object qualifier and arguments:
Part DescriptionConfigKeyword Required. A string expression that represents the ConfigKeyword.
How to use:
拷贝代码到你的 VB 或者 VBA 程序里.
在你的程序里Call下面的函数.
Public Sub CreateShapefile()
Const strFolder As String = "D:"Data"
Const strName As String = "MyShapeFile" ' Dont include .shp extension
Const strShapeFieldName As String = "Shape"
' Open the folder to contain the shapefile as a workspace
Dim pFWS As IFeatureWorkspace
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Set pFWS = pWorkspaceFactory.OpenFromFile(strFolder, 0)
' Set up a simple fields collection
Dim pFields As IFields
Dim pFieldsEdit As IFieldsEdit
Set pFields = New esriCore.Fields
Set pFieldsEdit = pFields
Dim pField As IField
Dim pFieldEdit As IFieldEdit
' Make the shape field
' it will need a geometry definition, with a spatial reference
Set pField = New esriCore.Field
Set pFieldEdit = pField
pFieldEdit.Name = strShapeFieldName
pFieldEdit.Type = esriFieldTypeGeometry
Dim pGeomDef As IGeometryDef
Dim pGeomDefEdit As IGeometryDefEdit
Set pGeomDef = New GeometryDef
Set pGeomDefEdit = pGeomDef
With pGeomDefEdit
.GeometryType = esriGeometryPolygon
Set .SpatialReference = New UnknownCoordinateSystem
End With
Set pFieldEdit.GeometryDef = pGeomDef
pFieldsEdit.AddField pField
' Add another miscellaneous text field
Set pField = New esriCore.Field
Set pFieldEdit = pField
With pFieldEdit
.Length = 30
.Name = "MiscText"
.Type = esriFieldTypeString
End With
pFieldsEdit.AddField pField
' Create the shapefile
' (some parameters apply to geodatabase options and can be defaulted as Nothing)
Dim pFeatClass As IFeatureClass
Set pFeatClass = pFWS.CreateFeatureClass(strName, pFields, Nothing, _
Nothing, esriFTSimple, strShapeFieldName, "")
End Sub
在ArcEngine中创建内存图层
arcEngine9.2中新增了一个新的特征,允许创建内存工作空间。当你需要一个这样的图层时,这个图层的属性数据或者几何数据需要频繁的更新,而又不希望因此而带来效率上的问题,你就可以考虑使用内存图层。
内存图层的创建分为五步:
1、设置属性字段
2、设置空间参考和几何字段
3、创建内存工作空间
4、在内存工作空间中创建特征类
5、创建特征图层,并将上一步创建的特征类设置为这个特征的图层的特征类
请看以下完整的示例代码
///