http://www.gissky.net- GIS空间站

我要投稿 投稿指南 RSS订阅 网站资讯通告:
搜索: 您现在的位置: GIS空间站 >> 技术专栏 >> ArcGIS >> ArcObjects开发 >> 正文

ArcObjects:创建shp要素类

作者:峰哥    文章来源:SINA博客    点击数:    更新时间:2007-10-23
摘要:创建一个shp要素类
下面创建一个shp要素类,其他工作空间类似

Dim pWS As IWorkspace
        Dim pWSF As IWorkspaceFactory
        pWSF = New ShapefileWorkspaceFactory
        pWS = pWSF.OpenFromFile("C:\Program Files\ESRI\MapObjects2\Samples\Data\Mexico", 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()

Tags:要素类  
责任编辑:gissky
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 中国地图