private void ImportRaster() { Geoprocessor gp = new Geoprocessor(); //定义处理对象 gp.OverwriteOutput = true; //覆盖输出 RasterToGeodatabase pRasterToGeodatabase = new RasterToGeodatabase(); try { UIWaiting("正在导入" + this.textBox1.Text + "层"); Application.DoEvents(); FileInfo fileInfo = new FileInfo(this.textBox1.Text.ToString()); string fpath = fileInfo.DirectoryName; string fname = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.')); pRasterToGeodatabase.Input_Rasters = this.textBox1.Text; pRasterToGeodatabase.Output_Geodatabase = m_FGDB; gp.Execute(pRasterToGeodatabase, null); IRasterWorkspaceEx rasterWS = m_workSpace as IRasterWorkspaceEx; IRasterDataset rasterDS = rasterWS.OpenRasterDataset(fname); IDataset ds = rasterDS as IDataset; ds.Rename(this.m_place + "_" + this.m_satelite + "_" + this.m_time); m_gdata.InsertMataData(this.m_place + "_" + this.m_satelite + "_" + this.m_time, m_satelite, this.m_time, "2", this.m_place); Application.DoEvents(); MessageBox.Show("入库成功!", "提示"); frm.Close(); this.Close(); UIWaiting(""); } catch (Exception error) { MessageBox.Show(error.Message); return; } }
/// <summary> /// /// </summary> /// <param name="strInput"></param> /// <param name="outPut"></param> /// <param name="isToFile"></param> /// <param name="strFormat">当isToFile为Ture时,可设置此值,默认值为TIFF,可选值:BMP、JPEG、PNG、GIF、TIFF、IMAGINE、GRID</param> /// <returns></returns> public static bool CopyRaster(string strInput, string outPut, bool isToFile, string strFormat) { try{ IGPProcess gpTool = null; if (isToFile) { RasterToOtherFormat gpToOther = new RasterToOtherFormat(); gpToOther.Input_Rasters = strInput; gpToOther.Output_Workspace = outPut; gpToOther.Raster_Format = strFormat; gpTool = gpToOther; } else { RasterToGeodatabase gpToGDB = new RasterToGeodatabase(); gpToGDB.Input_Rasters = strInput; gpToGDB.Output_Geodatabase = outPut; gpTool = gpToGDB; } Geoprocessor geoProcessor = new Geoprocessor(); geoProcessor.OverwriteOutput = true; IGeoProcessorResult gpResult = geoProcessor.Execute(gpTool, null) as IGeoProcessorResult; //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(geoProcessor); return(gpResult.Status == esriJobStatus.esriJobSucceeded); } catch (Exception exp) { ErrorMessage = exp.Message; return(false); } }
/// <summary> /// /// </summary> /// <param name="strInput"></param> /// <param name="outPut"></param> /// <param name="isToFile"></param> /// <param name="strFormat">当isToFile为Ture时,可设置此值,默认值为TIFF,可选值:BMP、JPEG、PNG、GIF、TIFF、IMAGINE、GRID</param> /// <returns></returns> public static bool CopyRaster(string strInput, string outPut,bool isToFile,string strFormat) { try{ IGPProcess gpTool = null; if (isToFile) { RasterToOtherFormat gpToOther = new RasterToOtherFormat(); gpToOther.Input_Rasters = strInput; gpToOther.Output_Workspace = outPut; gpToOther.Raster_Format = strFormat; gpTool = gpToOther; } else { RasterToGeodatabase gpToGDB = new RasterToGeodatabase(); gpToGDB.Input_Rasters = strInput; gpToGDB.Output_Geodatabase = outPut; gpTool = gpToGDB; } Geoprocessor geoProcessor = new Geoprocessor(); geoProcessor.OverwriteOutput = true; IGeoProcessorResult gpResult = geoProcessor.Execute(gpTool, null) as IGeoProcessorResult; //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(geoProcessor); return gpResult.Status == esriJobStatus.esriJobSucceeded; } catch(Exception exp) { ErrorMessage = exp.Message; return false; } }
private void ImportRaster() { Geoprocessor gp = new Geoprocessor();//定义处理对象 gp.OverwriteOutput = true;//覆盖输出 RasterToGeodatabase pRasterToGeodatabase = new RasterToGeodatabase(); try { UIWaiting("正在导入" + this.textBox1.Text + "层"); Application.DoEvents(); FileInfo fileInfo = new FileInfo(this.textBox1.Text.ToString()); string fpath = fileInfo.DirectoryName; string fname = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.')); pRasterToGeodatabase.Input_Rasters = this.textBox1.Text; pRasterToGeodatabase.Output_Geodatabase = m_FGDB; gp.Execute(pRasterToGeodatabase, null); IRasterWorkspaceEx rasterWS = m_workSpace as IRasterWorkspaceEx; IRasterDataset rasterDS = rasterWS.OpenRasterDataset(fname); IDataset ds = rasterDS as IDataset; ds.Rename(this.m_place+"_"+this.m_satelite+"_"+this.m_time); m_gdata.InsertMataData(this.m_place + "_" + this.m_satelite + "_" + this.m_time, m_satelite, this.m_time, "2",this.m_place); Application.DoEvents(); MessageBox.Show("入库成功!","提示"); frm.Close(); this.Close(); UIWaiting(""); } catch (Exception error) { MessageBox.Show(error.Message); return; } }