Exemple #1
0
        public static bool RasterToOtherFormat(IEnumerable <string> inputRasters, string outputFolder, out IEnumerable <string> messages)
        {
            RasterToOtherFormat coppier = new RasterToOtherFormat
            {
                Input_Rasters    = string.Join(";", inputRasters.ToArray()),
                Output_Workspace = outputFolder,
                Raster_Format    = rasterOutFormat
            };

            return(RunTool(coppier, null, out messages));
        }
Exemple #2
0
        /// <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);
            }
        }
Exemple #3
0
        /// <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;
            }
        }