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

 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

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.