『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

ArcObjects:创建shp要素类

ArcObjects:创建shp要素类
创建一个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()

      京ICP备2025132830号-1 京公网安备 号