arcEngine classic code(2)

简介:

1 新建shp文件
Public Sub CreatShapeFile(ByVal sFilePath As String, ByVal sFileName As String)     '创建shapefile层文件
On Error GoTo Errhandle:
    Dim pWorkspaceFactory As IWorkspaceFactory
    Dim pFeatureWorkspace As IFeatureWorkspace
    Dim pFields As IFields
    Dim pFieldsEdit As IFieldsEdit
    Dim pField As IField
    Dim pFieldEdit As IFieldEdit
    Dim pGeometryDef As IGeometryDef
    Dim pGeometryDefEdit As IGeometryDefEdit
    Dim pFeatClass As IFeatureClass
    Dim sShapeFieldName As String
    Dim sNewShapeFileName As String

    sNewShapeFileName = Dir(sFilePath & "\" & sFileName & ".shp")
    If (sNewShapeFileName <> "") Then
             MsgBox ("文件已经存在")
        Exit Sub
    End If
    sShapeFieldName = "Shape"                                '先创建一个字段名字
    '创建一个文件夹来存放shapefile文件
    Set pWorkspaceFactory = New ShapefileWorkspaceFactory
    Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sFilePath, 0)
    
    'Set up a simple fields collection
    Set pFields = New esriGeoDatabase.Fields
    Set pFieldsEdit = pFields
    'Make the shape field
    'it will need a geometry definition, with a spatial reference
    Set pField = New esriGeoDatabase.Field
    Set pFieldEdit = pField
    '创建第一个字段
    pFieldEdit.Name = sShapeFieldName
    pFieldEdit.Type = esriFieldTypeGeometry
    Set pGeometryDef = New GeometryDef
    Set pGeometryDefEdit = pGeometryDef
    With pGeometryDefEdit
    .GeometryType = esriGeometryPolygon
    Set .SpatialReference = New UnknownCoordinateSystem
    End With
    Set pFieldEdit.GeometryDef = pGeometryDef
    pFieldsEdit.AddField pField               '添加字段到字段集中
    '再添加一个字段
    Set pField = New esriGeoDatabase.Field
    Set pFieldEdit = pField
    With pFieldEdit
        .Name = "type"
        .Type = esriFieldTypeString
    End With
    pFieldsEdit.AddField pField               '添加字段到字段集中
    '开始创建shapefile层文件
    '(some parameters apply to geodatabase options and can be defaulted as Nothing)
    Set pFeatClass = pFeatureWorkspace.CreateFeatureClass _
    (sFileName, pFields, Nothing, Nothing, _
    esriFTSimple, sShapeFieldName, "")
'    sNewShapeFileName = Dir(sFilePath & "\" & sFileName & ".shp")
'      If (sNewShapeFileName = "") Then
'        MsgBox ("Build Fail")
'    Else
'        MsgBox ("Build Success")
'    End If
Errhandle:
    Set pFeatClass = Nothing
    Set pGeometryDefEdit = Nothing
    Set pGeometryDef = Nothing
    Set pFieldEdit = Nothing
    Set pField = Nothing
    Set pFieldsEdit = Nothing
    Set pFields = Nothing
    Set pFeatureWorkspace = Nothing
    Set pWorkspaceFactory = Nothing


    If Err.Description <> "" Then
    MsgBox Err.Description & ":创建shapefile失败!", vbInformation, "提示信息"
    End If
End Sub




    本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/xiexiaokui/archive/2008/05/11/1192358.html,如需转载请自行联系原作者


相关文章
|
存储 网络安全 数据安全/隐私保护
如何在上架 App 之前设置证书并上传应用
如何在上架 App 之前设置证书并上传应用
|
Web App开发 安全 Windows
解决:对COM 组件的调用返回了错误 HRESULT E_FAIL
  调用SHDOCVW(web浏览器) COM组件的时候,返回了错误 HRESULT E_FAIL。总结如下:     1. 在控制面板--->管理工具--->服务 中,开启Distributed Transaction Coordinator 服务。
7028 0
|
缓存 前端开发 JavaScript
终极 Nginx 配置指南(全网最详细)
本文详细介绍了Nginx配置文件`nginx.conf`的基本结构及其优化方法。首先通过删除注释简化了原始配置,使其更易理解。接着,文章将`nginx.conf`分为全局块、events块和http块三部分进行详细解析,帮助读者更好地掌握其功能与配置。此外,还介绍了如何通过简单修改实现网站上线,并提供了Nginx的优化技巧,包括解决前端History模式下的404问题、配置反向代理、开启gzip压缩、设置维护页面、在同一IP上部署多个网站以及实现动静分离等。最后,附上了Nginx的基础命令,如安装、启动、重启和关闭等操作,方便读者实践应用。
5228 85
终极 Nginx 配置指南(全网最详细)
|
SQL 存储 数据可视化
技术经验分享:ArcGISEngine开发之属性查询
技术经验分享:ArcGISEngine开发之属性查询
212 0
|
开发工具 开发者 git
代码协同模式使用问题之在分支评审通过后,如何合入分支,分支合入后,分支是否需要删除
代码协同模式使用问题之在分支评审通过后,如何合入分支,分支合入后,分支是否需要删除
|
算法 搜索推荐 UED
为什么网站首页排名不稳定?
新站通常面临搜索引擎的考核期,排名波动属正常,一般持续1-3个月。百度等搜索引擎频繁更新算法,导致排名受影响,但正规优化可助快速恢复。网站结构对排名至关重要,清晰架构能提升用户体验和页面权重,有利获取高排名和免费流量。
71 3
|
存储 Java 程序员
老程序员分享:Java虚拟机详解(九)
老程序员分享:Java虚拟机详解(九)
74 0
|
监控 机器人 定位技术
植保机器人(包括无人植保机)在能源效率
植保机器人(包括无人植保机)在能源效率
119 2
基于C#的ArcEngine二次开发35:缓冲区分析
基于C#的ArcEngine二次开发35:缓冲区分析
基于C#的ArcEngine二次开发35:缓冲区分析
|
编译器 Python
泰酷啦|在python编译器上打印出各种三角形和菱形
泰酷啦|在python编译器上打印出各种三角形和菱形
145 0