1 IWorkspaceFactory pWorkspaceFactory = new TinWorkspaceFactoryClass(); 2 IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(@"D:\Xge.UDX.ExchangeProjection\DATA\", 0); 3 ITinWorkspace pTinWorkspace = pWorkspace as ITinWorkspace; 4 ITin pTin = pTinWorkspace.OpenTin("tinfromudx"); 5 6 Geoprocessor GP1 = new Geoprocessor(); 7 GP1.OverwriteOutput = true; 8 ESRI.ArcGIS.Analyst3DTools.TinRaster tin2raster = new TinRaster(); 9 tin2raster.in_tin = pTin;//输入的TIN 10 tin2raster.out_raster = @"D:\Xge.UDX.ExchangeProjection\DATA\DEMTest";//输出的DEM 11 tin2raster.sample_distance = "OBSERVATIONS 250";//设置cells大小 12 GP1.Execute(tin2raster, null); 13 14 Geoprocessor GP2 = new Geoprocessor(); 15 GP2.OverwriteOutput = true; 16 ESRI.ArcGIS.ConversionTools.RasterToASCII raster2asc = new ESRI.ArcGIS.ConversionTools.RasterToASCII(); 17 raster2asc.in_raster = @"D:\Xge.UDX.ExchangeProjection\DATA\DEMTest"; 18 raster2asc.out_ascii_file = @"D:\Xge.UDX.ExchangeProjection\DATA\DEMTest.asc"; 19 GP2.Execute(raster2asc, null); 20 MessageBox.Show("转换完成");
错误很邪!总是出现“对 COM 组件的调用返回了错误 HRESULT E_FAIL”,我的解决办法是:用ArcMap中的toolbox“过一次”,就能在GP通过。也不知道为什么。反正我的解决了。
这个网站上有这个错误的比较多的解决办法,链接发这:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=98654