YouTube | Facebook | X(Twitter) | RSS

FeatureDataConverter の使用方法

2016/9/1 (木)

Private Sub ConvertFeatureClassOperation()
    'レイヤからフィーチャクラスを取得
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pMxDocument.FocusMap.Layer(0)
     
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
     
    Dim pInDataset As IDataset
    Set pInDataset = pFeatureClass
     
    Dim pInWorkspace As IWorkspace
    Set pInWorkspace = pInDataset.Workspace
     
    Dim pWorkspaceEdit As IWorkspaceEdit
    Set pWorkspaceEdit = pInWorkspace
     
     
    '入力FeatureClassName(WorkspaceNameも保持)
    Dim pInDatasetName As IDatasetName
    Set pInDatasetName = pInDataset.FullName
     
    '出力FeatureWorkspaceName設定
    Dim pOutWorkspaceName As IWorkspaceName
    Set pOutWorkspaceName = New WorkspaceName
    pOutWorkspaceName.WorkspaceFactoryProgID = "esriDataSourceFile.ShapefileWorkspaceFactory"
    pOutWorkspaceName.PathName = "D:\Workspace"
     
    '出力FeatureClassName
    Dim pOutFeatureClassName As IFeatureClassName
    Dim pOutFeatureClassDatasetName As IDatasetName
     
    Set pOutFeatureClassName = New FeatureClassName
    Set pOutFeatureClassDatasetName = pOutFeatureClassName
     
    pOutFeatureClassName.FeatureType = esriFTSimple
    pOutFeatureClassName.ShapeFieldName = pFeatureClass.ShapeFieldName
    pOutFeatureClassName.ShapeType = esriGeometryAny
     
    pOutFeatureClassDatasetName.Name = pFeatureClass.AliasName          '出力フィーチャクラス名
    Set pOutFeatureClassDatasetName.WorkspaceName = pOutWorkspaceName   'Workspaceの指定
     
    pWorkspaceEdit.StartEditOperation
    pWorkspaceEdit.StartEditing True
     
    Dim pFeatureDataConverter  As IFeatureDataConverter2
    Set pFeatureDataConverter = New FeatureDataConverter
    pFeatureDataConverter.ConvertFeatureClass pInDatasetName, Nothing, Nothing, Nothing, pOutFeatureClassName, Nothing, Nothing, "", 100, Application.hWnd
     
    pWorkspaceEdit.StopEditing True
    pWorkspaceEdit.StopEditOperation
     
    MsgBox "[" & pOutWorkspaceName.PathName & "]に[" & pOutFeatureClassDatasetName.Name & "]を作成しました。"
     
End Sub
  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,