public static bool Sample(List<string> inRasters,
            string locationData, string outTable,string resamplingType,string outExcel)
        {
            Geoprocessor gp = new Geoprocessor();
            gp.OverwriteOutput = true;

            string istr = inRasters[0];
            for (int j = 1; j < inRasters.Count(); j++)
            {
                istr += ";" + inRasters[j];
            }
            ESRI.ArcGIS.SpatialAnalystTools.Sample sam = new ESRI.ArcGIS.SpatialAnalystTools.Sample();
            sam.in_rasters = istr;//inRasters;
            sam.in_location_data = locationData;
            sam.out_table = outTable;
            sam.resampling_type = resamplingType;

            try
            {
                gp.Execute(sam, null);
            }
            catch (COMException e)
            {
                string str = "";
                for (int i = 0; i < gp.MessageCount; i++)
                {
                    str += gp.GetMessage(i);

                }
                MessageBox.Show(str);
                return false;
            }

            if (!ExcelUtil.CreateExcelByItable(outTable,outExcel))
            {
                MessageBox.Show("生成Excel表格失败!");
                return false;
            }
           
            return true;
        }
posted on 2015-08-10 17:00  agiser  阅读(532)  评论(0编辑  收藏  举报