Converting coordinate system of feature layers and datasets programmatically

المشرف العام

Administrator
طاقم الإدارة
I am trying to convert coordinate system of featurelayer and datasets using ESRI.ArcGIS.DataManagementTools.Project . The tool works fine in ArcCatalog .

I have doubts about the parameters i am giving. here is the code :

private void button5_Click(object sender, EventArgs e) { try {

IWorkspaceFactory pFactory = new FileGDBWorkspaceFactory(); string pPath = folderBrowserDialog1.SelectedPath; string pFileName = System.IO.Path.GetFileName(pPath); IWorkspace workspace = pFactory.OpenFromFile(pPath, 0); ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace; IFeatureLayer layer = new FeatureLayerClass(); layer.FeatureClass = featureWorkspace.OpenFeatureClass(comboBox2.Text); ILayer layer2 = (ILayer)layer; IFeatureDataset fdataset = featureWorkspace.OpenFeatureDataset("test"); ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); // Set the parameters ESRI.ArcGIS.DataManagementTools.Project proj = new ESRI.ArcGIS.DataManagementTools.Project(); proj.in_dataset = layer; proj.out_dataset = OutputFiletxt.Text; proj.out_coor_system = layer2.AreaOfInterest.SpatialReference; RunTool(gp, proj, null); } catch (Exception ex) { throw ex; } } private void RunTool (Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC) { // Set the overwrite output option to true geoprocessor.OverwriteOutput = true;

try { geoprocessor.Execute (process, null); ReturnMessages (geoprocessor); // (error Message = Error HRESULT E_FAIL has been returned from a call to a COM component. ) } catch (Exception err) { Console.WriteLine (err.Message); ReturnMessages (geoprocessor); } } The error is pretty vague and I dont know if there is an other way to trace this problem.



أكثر...
 
أعلى