×
您的位置: 首页 > 编程笔记

ArcObjects:创建shp要素类

AR 时间:2010-12-26  查看:227   收藏
摘要:创建一个shp要素类 下面创建一个shp要素类,其他工作空间类似

Dim pWS As IWorkspace
Dim pWSF As IWorkspaceFactory
pWSF = New ShapefileWorkspaceFactory
pWS = pWSF.OpenFromFile("C:Program FilesESRIMapObjects2SamplesDataMexico", 0)

Dim pFields As IFields
pFields = New Fields

Dim pFieldsEdit As IFieldsEdit
pFieldsEdit = pFields
pFieldsEdit.FieldCount_2 = 3

Dim pFE As IFieldEdit
Dim pF As IField
pF = New Field
pFE = pF
With pFE
.Name_2 = "ObjectID"
.AliasName_2 = "FID"
.Type_2 = esriFieldType.esriFieldTypeOID
End With
pFieldsEdit.Field_2(0) = pF

pF = New Field
pFE = pF
With pFE
.Name_2 = "NAME"
.AliasName_2 = "Name"
.Type_2 = esriFieldType.esriFieldTypeString
End With
pFieldsEdit.Field_2(1) = pF

Dim pGeoDef As IGeometryDef
pGeoDef = New GeometryDef
Dim pGeoDefEdit As IGeometryDefEdit
pGeoDefEdit = pGeoDef
Dim pSR As ISpatialReference

Dim pFeatLyr As IFeatureLayer
pFeatLyr = New FeatureLayer

Dim pMap As IMap
pMap = AxMapControl1.Map

pSR = pMap.SpatialReference

pGeoDefEdit.SpatialReference_2 = pSR
pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint

pF = New Field
pFE = pF
With pFE
.Name_2 = "Shape"
.AliasName_2 = "shape"
.Type_2 = esriFieldType.esriFieldTypeGeometry
.GeometryDef_2 = pGeoDefEdit
End With
pFieldsEdit.Field_2(2) = pF

Dim pFeatWS As IFeatureWorkspace
pFeatWS = pWS
pFeatWS.CreateFeatureClass("china", pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, "Shape", "")
AxMapControl1.Refresh()

 

0% (0)
0% (0)