YouTube | Facebook | X(Twitter) | RSS

フィーチャクラスのエクスポート・コンバート

2016/9/1 (木)

void ExportData()
{
    IDataset pDataset = <テーブル・フィーチャクラス>;
 
    //入力 DatasetName
    IDatasetName pInputDatasetName =  pDataset.FullName;
 
    //出力 WorkspaceName
    IWorkspaceName pOutputWorkspaceName  = new WorkspaceNameClass();
    pOutputWorkspaceName.PathName = @"D:\Workspace";
    //ワークスペースの種類に応じて WorkspaceFactoryProgID を変更
    //pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory";
    pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
    //pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesOleDB.OLEDBWorkspaceFactory";
    //pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory";
    //pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";
    //pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesOleDB.TextFileWorkspaceFactory";
 
 
    //出力DatasetName
    IDatasetName pOutputFeatureClassName = new FeatureClassNameClass();
    pOutputFeatureClassName.Name = "Output";  //出力フィーチャクラス名
    pOutputFeatureClassName.WorkspaceName = pOutputWorkspaceName;
 
    //ExportOperation を使用したエクスポート
    IExportOperation pExportOperation  = new ExportOperationClass();
    pExportOperation.ExportFeatureClass(pInputDatasetName, null, null, null, (IFeatureClassName)pOutputFeatureClassName, (int)ArcMap.Application.hWnd);
 
    //FeatureDataConverter を使用したエクスポート
    IFeatureDataConverter pFeatureDataConverter  = new FeatureDataConverterClass();
    pFeatureDataConverter.ConvertFeatureClass((IFeatureClassName)pInputDatasetName, null, null, (IFeatureClassName)pOutputFeatureClassName, null, null, "", 1000, (int)ArcMap.Application.hWnd);
}
Sub ExportData()
 
    Dim pDataset As IDataset = <テーブル・フィーチャクラス>
 
    '入力 DatasetName
    Dim pInputDatasetName As IDatasetName = pDataset.FullName
 
    '出力 WorkspaceName
    Dim pOutputWorkspaceName As IWorkspaceName = New WorkspaceNameClass()
    pOutputWorkspaceName.PathName = "D:\Workspace"
    'ワークスペースの種類に応じて WorkspaceFactoryProgID を変更
    'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory"
    pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory"
    'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesOleDB.OLEDBWorkspaceFactory"
    'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory"
    'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"
    'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesOleDB.TextFileWorkspaceFactory"
 
 
    '出力DatasetName
    Dim pOutputFeatureClassName As IDatasetName = New FeatureClassNameClass()
    pOutputFeatureClassName.Name = "Output"  '出力フィーチャクラス名
    pOutputFeatureClassName.WorkspaceName = pOutputWorkspaceName
 
    'ExportOperation を使用したエクスポート
    Dim pExportOperation As IExportOperation = New ExportOperationClass()
    pExportOperation.ExportFeatureClass(pInputDatasetName, Nothing, Nothing, Nothing, pOutputFeatureClassName, My.ArcMap.Application.hWnd)
 
    'FeatureDataConverter を使用したエクスポート
    Dim pFeatureDataConverter As IFeatureDataConverter = New FeatureDataConverterClass()
    pFeatureDataConverter.ConvertFeatureClass(pInputDatasetName, Nothing, Nothing, pOutputFeatureClassName, Nothing, Nothing, "", 1000, My.ArcMap.Application.hWnd)
 
End Sub
'VBA
'入力DatasetName
Dim pInputDatasetName As IDatasetName
Set pInputDatasetName = pDataset.FullName
 
'出力WorkspaceName
Dim pOutputWorkspaceName As IWorkspaceName
Set pOutputWorkspaceName = New WorkspaceName
pOutputWorkspaceName.PathName = "D:\Workspace"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ArcInfoWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.CadWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesOleDB.OLEDBWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.PCCoverageWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesRaster.RasterWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory"
pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesOleDB.TextFileWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.TinWorkspaceFactory"
'pOutputWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.VpfWorkspaceFactory"
 
'出力DatasetName
Dim pOutputFeatureClassName As IDatasetName
Set pOutputFeatureClassName = New FeatureClassName
pOutputFeatureClassName.Name = "Output"  '出力フィーチャクラス名
Set pOutputFeatureClassName.WorkspaceName = pOutputWorkspaceName
 
'ExportOperation
Dim pExportOperation As IExportOperation
Set pExportOperation = New ExportOperation
pExportOperation.ExportFeatureClass pInputDatasetName, Nothing, Nothing, Nothing, pOutputFeatureClassName, Application.hWnd
 
'FeatureDataConverter
Dim pFeatureDataConverter As IFeatureDataConverter
Set pFeatureDataConverter = New FeatureDataConverter
pFeatureDataConverter.ConvertFeatureClass pInputDatasetName, Nothing, Nothing, pOutputFeatureClassName, Nothing, Nothing, "", 1000, Application.hWnd
  • この記事を書いた人

羽田 康祐

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

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