Пример #1
0
        private IRasterLayer SetViewShedRenderer(IRaster pInRaster, string sField, string sPath,double[,] dValue)
        {
            try
            {
                if (dValue == null)
                    return null;
                if (sField.Trim() == "")
                    return null;
                string path="";
                string fileName="";
                int iPath=sPath.LastIndexOf('\\');
                path=sPath.Substring(0,iPath);
                fileName=sPath.Substring(iPath+1,sPath.Length-iPath-1);

                IRasterDescriptor pRD = new RasterDescriptorClass();
                pRD.Create(pInRaster, null, sField);
                IReclassOp pReclassOp = new RasterReclassOpClass();

                IGeoDataset pGeodataset = pInRaster as IGeoDataset;
                IRasterAnalysisEnvironment pEnv = pReclassOp as IRasterAnalysisEnvironment;
                IWorkspaceFactory pWSF = new RasterWorkspaceFactoryClass();
                IWorkspace pWS = pWSF.OpenFromFile(path, 0);
                //pEnv.OutWorkspace = pWS;
                //object objSnap = null;
                //object objExtent = pGeodataset.Extent;
                //pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref objExtent, ref objSnap);
                //pEnv.OutSpatialReference = pGeodataset.SpatialReference;

                IRasterBandCollection pRsBandCol = pGeodataset as IRasterBandCollection;
                IRasterBand pRasterBand = pRsBandCol.Item(0);
                pRasterBand.ComputeStatsAndHist();
                IRasterStatistics pRasterStatistic = pRasterBand.Statistics;
                double dMaxValue = pRasterStatistic.Maximum;
                double dMinValue = pRasterStatistic.Minimum;

                INumberRemap pNumRemap = new NumberRemapClass();
                for (int i = 0; i < (dValue.Length/3); i++)
                {
                    pNumRemap.MapRange(dValue[i, 0], dValue[i, 1], (Int32)dValue[i, 2]);
                }
                IRemap pRemap = pNumRemap as IRemap;

                IGeoDataset pGeoDs = new RasterDatasetClass();
                pGeoDs=pReclassOp.ReclassByRemap(pGeodataset, pRemap, false);
                IRasterBandCollection pRasBandCol = (IRasterBandCollection)pGeoDs;
                pRasBandCol.SaveAs(fileName, pWS, "GRID");//"IMAGINE Image"
                IRaster pOutRaster =pGeoDs as IRaster;
                IRasterLayer pRLayer = new RasterLayerClass();

                pRLayer.CreateFromRaster(pOutRaster);
                pRLayer.Name = fileName;
                return pRLayer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return null;
            }
        }
Пример #2
0
        //Ϊդ��ͼ�����ݽ���ͨ�ӷ�����ɫ
        public static IRasterLayer SetViewShedRenderer(IRaster pInRaster, string sField, string sPath)
        {
            IRasterDescriptor pRD = new RasterDescriptorClass();
            pRD.Create(pInRaster, new QueryFilterClass(), sField);
            IReclassOp pReclassOp = new RasterReclassOpClass();
            IGeoDataset pGeodataset = pInRaster as IGeoDataset;
            IRasterAnalysisEnvironment pEnv = pReclassOp as IRasterAnalysisEnvironment;
            IWorkspaceFactory pWSF = new RasterWorkspaceFactoryClass();
            IWorkspace pWS = pWSF.OpenFromFile(sPath, 0);
            pEnv.OutWorkspace = pWS;
            object objSnap = null;
            object objExtent = pGeodataset.Extent;
            pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref objExtent, ref objSnap);
            pEnv.OutSpatialReference = pGeodataset.SpatialReference;
            IRasterLayer pRLayer = new RasterLayerClass();
            IRasterBandCollection pRsBandCol = pGeodataset as IRasterBandCollection;
            IRasterBand pRasterBand = pRsBandCol.Item(0);
            pRasterBand.ComputeStatsAndHist();
            IRasterStatistics pRasterStatistic = pRasterBand.Statistics;
            double dMaxValue = pRasterStatistic.Maximum;
            double dMinValue = pRasterStatistic.Minimum;

            INumberRemap pNumRemap = new NumberRemapClass();
            pNumRemap.MapRange(dMinValue, 0, 0);
            pNumRemap.MapRange(0, dMaxValue, 1);
            IRemap pRemap = pNumRemap as IRemap;

            IRaster pOutRaster = pReclassOp.ReclassByRemap(pGeodataset, pRemap, false) as IRaster;
            pRLayer.CreateFromRaster(pOutRaster);

            return pRLayer;
        }
Пример #3
0
        //դ���ط���
        private IRasterLayer calMValve(IRaster pInRaster, string sField)
        {
            try
            {
                if (sField.Trim() == "")
                    return null;
                IRasterDescriptor pRD = new RasterDescriptorClass();
                pRD.Create(pInRaster, null, sField);
                IReclassOp pReclassOp = new RasterReclassOpClass();

                IGeoDataset pGeodataset = pInRaster as IGeoDataset;
                IRasterAnalysisEnvironment pEnv = pReclassOp as IRasterAnalysisEnvironment;

                IRasterBandCollection pRsBandCol = pGeodataset as IRasterBandCollection;
                IRasterBand pRasterBand = pRsBandCol.Item(0);
                pRasterBand.ComputeStatsAndHist();
                IRasterStatistics pRasterStatistic = pRasterBand.Statistics;
                double dMaxValue = pRasterStatistic.Maximum;
                double dMinValue = pRasterStatistic.Minimum;

                INumberRemap pNumRemap = new NumberRemapClass();
                //m���������� ���¶�Ϊ 0-7.5; 7.5-12.5; 12.5-17.5; 17.5--22.5; >22.5;
                //mֵ�ֱ�Ϊ�� 0.1;0.15;0.2;0.25,0.3
                //��ֵ������100��
                pNumRemap.MapRange(dMinValue, 7.5, 10);
                pNumRemap.MapRange(7.5, 12.5, 15);
                pNumRemap.MapRange(12.5, 17.5, 20);
                pNumRemap.MapRange(17.5, 22.5, 25);
                pNumRemap.MapRange(22.5, dMaxValue, 30);
                IRemap pRemap = pNumRemap as IRemap;

                IGeoDataset pGeoDs = new RasterDatasetClass();
                pGeoDs = pReclassOp.ReclassByRemap(pGeodataset, pRemap, false);
                IRaster pOutRaster = pGeoDs as IRaster;
                IRasterLayer pRLayer = new RasterLayerClass();
                pRLayer.CreateFromRaster(pOutRaster);
                return pRLayer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return null;
            }
        }
Пример #4
0
        private IRasterLayer SetViewShedRenderer(IRaster pInRaster, string sField, string sPath, double[,] dValue)
        {
            try
            {
                if (dValue == null)
                {
                    return(null);
                }
                if (sField.Trim() == "")
                {
                    return(null);
                }
                string path     = "";
                string fileName = "";
                int    iPath    = sPath.LastIndexOf('\\');
                path     = sPath.Substring(0, iPath);
                fileName = sPath.Substring(iPath + 1, sPath.Length - iPath - 1);

                IRasterDescriptor pRD = new RasterDescriptorClass();
                pRD.Create(pInRaster, null, sField);
                IReclassOp pReclassOp = new RasterReclassOpClass();

                IGeoDataset pGeodataset         = pInRaster as IGeoDataset;
                IRasterAnalysisEnvironment pEnv = pReclassOp as IRasterAnalysisEnvironment;
                IWorkspaceFactory          pWSF = new RasterWorkspaceFactoryClass();
                IWorkspace pWS = pWSF.OpenFromFile(path, 0);
                //pEnv.OutWorkspace = pWS;
                //object objSnap = null;
                //object objExtent = pGeodataset.Extent;
                //pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref objExtent, ref objSnap);
                //pEnv.OutSpatialReference = pGeodataset.SpatialReference;

                IRasterBandCollection pRsBandCol  = pGeodataset as IRasterBandCollection;
                IRasterBand           pRasterBand = pRsBandCol.Item(0);
                pRasterBand.ComputeStatsAndHist();
                IRasterStatistics pRasterStatistic = pRasterBand.Statistics;
                double            dMaxValue        = pRasterStatistic.Maximum;
                double            dMinValue        = pRasterStatistic.Minimum;

                INumberRemap pNumRemap = new NumberRemapClass();
                for (int i = 0; i < (dValue.Length / 3); i++)
                {
                    pNumRemap.MapRange(dValue[i, 0], dValue[i, 1], (Int32)dValue[i, 2]);
                }
                IRemap pRemap = pNumRemap as IRemap;

                IGeoDataset pGeoDs = new RasterDatasetClass();
                pGeoDs = pReclassOp.ReclassByRemap(pGeodataset, pRemap, false);
                IRasterBandCollection pRasBandCol = (IRasterBandCollection)pGeoDs;
                pRasBandCol.SaveAs(fileName, pWS, "GRID");//"IMAGINE Image"
                IRaster      pOutRaster = pGeoDs as IRaster;
                IRasterLayer pRLayer    = new RasterLayerClass();

                pRLayer.CreateFromRaster(pOutRaster);
                pRLayer.Name = fileName;
                return(pRLayer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return(null);
            }
        }
Пример #5
0
        //拉伸到灰度图像
        private bool stretchToGrayImage(IRaster pSrcRaster, string szOutputFilename, double dbMinThreshold = 0.02, double dbMaxThreshold = 0.98)
        {
            try
            {
                if (pSrcRaster == null || szOutputFilename == null)
                {
                    return(false);
                }

                //深拷贝
                IClone       pSrcClone    = pSrcRaster as IClone;
                IClone       pDstClone    = pSrcClone.Clone();
                IRaster      pDstRaster   = pDstClone as IRaster;
                IRaster2     pDstRaster2  = pDstRaster as IRaster2;
                IRasterProps pRasterProps = pDstRaster as IRasterProps;

                //原始统计信息
                bool        bFlag       = false;
                IRasterBand pRasterBand = (pDstRaster as IRasterBandCollection).Item(0);
                pRasterBand.HasStatistics(out bFlag);
                if (!bFlag)
                {
                    pRasterBand.ComputeStatsAndHist();
                }

                //得到原始栅格影像的最大最小值和步长
                double dbSrcMaxValue     = pRasterBand.Statistics.Maximum;
                double dbSrcMinValue     = pRasterBand.Statistics.Minimum;
                double dbSrcStep         = (dbSrcMaxValue - dbSrcMinValue) / 256;
                double dbStretchMaxValue = pRasterBand.Statistics.Maximum;
                double dbStretchMinValue = pRasterBand.Statistics.Minimum;

                #region 灰度映射,利用重分类来做

                //第一次重分类
                IReclassOp   reclassOp   = new RasterReclassOpClass();
                INumberRemap numberRemap = new NumberRemapClass();
                for (int i = 0; i < 256; i++)
                {
                    numberRemap.MapRange(dbSrcMinValue + i * dbSrcStep, dbStretchMinValue + (i + 1) * dbSrcStep, i);
                }
                IRaster      pRasterTemp      = reclassOp.ReclassByRemap((IGeoDataset)(pDstRaster2.RasterDataset), (IRemap)numberRemap, true) as IRaster;
                IRaster2     pRasterTemp2     = pRasterTemp as IRaster2;
                IRasterProps pRasterTempProps = pRasterTemp as IRasterProps;

                //得到属性表
                IRasterDatasetEdit3 pRasterDatasetEdit3 = pRasterTemp2.RasterDataset as IRasterDatasetEdit3;
                pRasterDatasetEdit3.ComputeStatisticsHistogram(1, 1, null, true);
                IRasterBand       rasterBand       = (pRasterTempProps as IRasterBandCollection).Item(0);
                IRasterHistogram  rasterHistogram  = rasterBand.Histogram;
                IRasterStatistics rasterStatistics = rasterBand.Statistics;

                double[] pHistogramCount = (double[])rasterHistogram.Counts;

                int nCurrentCount = 0;
                int nIndex        = 0;
                int nPixelCount   = 0;//pRasterProps.Width * pRasterProps.Height;
                //double dSum = 0.0;
                for (int i = 0; i < 256; i++)
                {
                    nPixelCount += (int)pHistogramCount[i];
                }
                //得到拉伸的最大最小值
                while (Convert.ToDouble(nCurrentCount) / nPixelCount < dbMinThreshold)
                {
                    nCurrentCount += Convert.ToInt32(pHistogramCount[nIndex++]);
                }
                dbStretchMinValue = nIndex * dbSrcStep + dbSrcMinValue;

                while (Convert.ToDouble(nCurrentCount) / nPixelCount < dbMaxThreshold)
                {
                    nCurrentCount += Convert.ToInt32(pHistogramCount[nIndex++]);
                }
                dbStretchMaxValue = nIndex * dbSrcStep + dbSrcMinValue;

                dbSrcStep = (dbStretchMaxValue - dbStretchMinValue) / 256;
                #endregion

                #region 拉伸
                INumberRemap numberRemapForStretch = new NumberRemapClass();

                numberRemapForStretch.MapRange(dbSrcMinValue, dbStretchMinValue + dbSrcStep, 0);
                for (int i = 1; i < 255; i++)
                {
                    numberRemapForStretch.MapRange(dbStretchMinValue + i * dbSrcStep, dbStretchMinValue + (i + 1) * dbSrcStep, i);
                }
                numberRemapForStretch.MapRange(dbStretchMinValue + 255 * dbSrcStep, dbSrcMaxValue, 255);

                IRaster      pRasterStretch      = reclassOp.ReclassByRemap((IGeoDataset)((pDstRaster as IRaster2).RasterDataset), (IRemap)numberRemapForStretch, true) as IRaster;
                IRasterProps pRasterStretchProps = pRasterStretch as IRasterProps;

                #region 注释代码
                ////拉伸
                //IPixelBlock3 pixelBlock3 = null;
                //IRasterCursor rasterCursor = (pDstRaster as IRaster2).CreateCursorEx(null);//null时为128*128

                //do
                //{
                //    pixelBlock3 = rasterCursor.PixelBlock as IPixelBlock3;
                //    int nWidth = pixelBlock3.Width;
                //    int nHeight = pixelBlock3.Height;

                //    System.Array pixels = (System.Array)pixelBlock3.get_PixelData(0);
                //    for (int m = 0; m < nWidth; m++)
                //    {
                //        for (int n = 0; n < nHeight; n++)
                //        {
                //            double dbSrcValue = Convert.ToDouble(pixels.GetValue(m, n));
                //            if (double.IsNaN(dbSrcValue) || dbSrcValue == dbNoDataValue)
                //                continue;

                //            if (dbSrcValue >= dbStretchMaxValue)
                //                pixels.SetValue(255, m, n);
                //            else if (dbSrcValue <= dbStretchMinValue)
                //                pixels.SetValue(0, m, n);
                //            else
                //            {
                //                byte dbDstValue = Convert.ToByte((dbSrcValue - dbStretchMinValue) / (dbStretchMaxValue - dbStretchMinValue) * 255);
                //                pixels.SetValue(dbDstValue, m, n);
                //            }
                //        }
                //    }
                //    pixelBlock3.set_PixelData(0, (System.Array)pixels);

                //    //修改数据
                //    pRasterEdit.Write(rasterCursor.TopLeft, pixelBlock3 as IPixelBlock);
                //    pRasterEdit.Refresh();
                //} while (rasterCursor.Next() == true);
                #endregion

                #endregion

                #region 存储数据
                IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactoryClass();
                IWorkspace        inmemWor          = pWorkspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(szOutputFilename), 0);
                pRasterStretchProps.PixelType = rstPixelType.PT_UCHAR;
                ISaveAs2 pSaveAs = pRasterStretchProps as ISaveAs2;
                if (pSaveAs == null)
                {
                    return(false);
                }

                IRasterStorageDef pRSDef   = new RasterStorageDefClass();
                IRasterDataset    pDataset = pSaveAs.SaveAsRasterDataset(System.IO.Path.GetFileName(szOutputFilename), inmemWor, "TIFF", pRSDef);
                (pDataset as IRasterDataset3).Refresh();
                //IRasterEdit pRasterEdit = pDstRaster as IRasterEdit;

                IRasterEdit pRasterTempEdit = pRasterTemp as IRasterEdit;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterTempEdit);
                IRasterEdit pRasterStretchEdit = pRasterStretch as IRasterEdit;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterStretchEdit);
                #endregion

                return(true);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// 风险因素等级划分
        /// </summary>
        /// <param name="RasterWorkspace"></param>
        /// <param name="roadEvalName"></param>
        /// <returns></returns>
        public static bool RaskCaulte(string RasterWorkspace, string roadEvalName)
        {
            IWorkspaceFactory rWorkspaceFactory = new RasterWorkspaceFactory();
            IWorkspace        SWorkspace        = rWorkspaceFactory.OpenFromFile(RasterWorkspace, 0);
            IRasterWorkspace  rasterWorkspace   = SWorkspace as IRasterWorkspace;
            //栅格计算器 计算风险级数  先不要签你的三方协议 然后存储  表达式必须隔开
            IMapAlgebraOp  mapAlgebra     = new RasterMapAlgebraOpClass();
            IRasterDataset roadEvalRaster = rasterWorkspace.OpenRasterDataset(roadEvalName);
            IGeoDataset    geo1           = roadEvalRaster as IGeoDataset;

            mapAlgebra.BindRaster(geo1, "EvalRaster");
            IGeoDataset raskDataset = mapAlgebra.Execute("[EvalRaster]");//然后存储  表达式必须间隔开
            //将生成的风险栅格重分类
            //<0.2	一级:可能性小
            //0.2-0.4	二级:可
            //能性较小
            //0.4-0.6	三级:可能性较大
            //0.6-0.8	四级:可能性大
            //>0.8	五级:可能性很大
            // 输入:raskDataset
            //   输出:geoDataset_result
            IRasterBandCollection pRsBandCol  = raskDataset as IRasterBandCollection;
            IRasterBand           pRasterBand = pRsBandCol.Item(0);

            pRasterBand.ComputeStatsAndHist();
            IRasterStatistics pRasterStatistic = pRasterBand.Statistics;
            double            dMaxValue        = pRasterStatistic.Maximum;
            double            dMinValue        = pRasterStatistic.Minimum;
            IReclassOp        pReclassOp       = new RasterReclassOpClass();
            INumberRemap      pNumRemap        = new NumberRemapClass();
            //等级参数
            List <double> raskRanges = new List <double>();

            for (int n = 0; n < 5; n++)
            {
                raskRanges.Add(dMinValue + (dMaxValue - dMinValue) * n / 4);
            }
            for (int m = 0; m < 4; m++)
            {
                pNumRemap.MapRange(raskRanges[m], raskRanges[m + 1], m + 1);
            }
            IRemap       pRemap      = pNumRemap as IRemap;
            IRaster      pOutRaster  = pReclassOp.ReclassByRemap(raskDataset, pRemap, false) as IRaster;
            IRasterLayer rasterLayer = new RasterLayerClass();

            rasterLayer.CreateFromRaster(pOutRaster);
            if (rasterLayer != null)
            {
                rasterLayer.Name = roadEvalName;
                for (int i = 0; i < MainFrom.m_mapControl.LayerCount; i++)
                {
                    ILayer ComLayer = MainFrom.m_mapControl.get_Layer(i);
                    if (rasterLayer.Name == ComLayer.Name)
                    {
                        MainFrom.m_mapControl.Map.DeleteLayer(ComLayer);
                    }
                }
                Common.funColorForRaster_Classify(rasterLayer, 4);
                IEnvelope envelope = rasterLayer.AreaOfInterest;
                MainFrom.m_mapControl.ActiveView.Extent = envelope;//缩放至图层
            }
            return(true);
        }
        /// <summary>
        /// 生成风险等级栅格
        /// </summary>
        /// <param name="roadEvalName"></param>
        /// <param name="rains"></param>
        /// <param name="saveWorkspace"></param>
        /// <returns></returns>
        public bool RoadRaskCaulte(string roadEvalName, double rains, string saveWorkspace)
        {
            #region 备份
            //  IWorkspaceFactory rWorkspaceFactory = new RasterWorkspaceFactory();
            //  IWorkspace SWorkspace = rWorkspaceFactory.OpenFromFile(saveWorkspace, 0);
            //  IRasterWorkspace rasterWorkspace = SWorkspace as IRasterWorkspace;
            //  //栅格计算器 计算风险级数  先不要签你的三方协议 然后存储  表达式必须隔开
            //  IMapAlgebraOp mapAlgebra = new RasterMapAlgebraOpClass();
            //  IRasterDataset roadEvalRaster = OpenRasterDataSet(rasterWorkspace, roadEvalName);

            //  IGeoDataset geo1 = roadEvalRaster as IGeoDataset;

            //  mapAlgebra.BindRaster(geo1, "EvalRaster");
            //  IGeoDataset raskDataset = mapAlgebra.Execute("[EvalRaster] * 10 / 25");//然后存储  表达式必须间隔开
            //  //将生成的风险栅格重分类
            //  //<0.2	一级:可能性小
            //  //0.2-0.4	二级:可
            //  //能性较小
            //  //0.4-0.6	三级:可能性较大
            //  //0.6-0.8	四级:可能性大
            //  //>0.8	五级:可能性很大
            //  // 输入:raskDataset
            ////   输出:geoDataset_result
            //  IRasterBandCollection pRsBandCol = raskDataset as IRasterBandCollection;
            //  IRasterBand pRasterBand = pRsBandCol.Item(0);
            //  pRasterBand.ComputeStatsAndHist();
            //  IRasterStatistics pRasterStatistic = pRasterBand.Statistics;
            //  double dMaxValue = pRasterStatistic.Maximum;
            //  double dMinValue = pRasterStatistic.Minimum;
            //  IReclassOp pReclassOp = new RasterReclassOpClass();
            //  INumberRemap pNumRemap = new NumberRemapClass();
            //  //pNumRemap.MapRange(dMinValue, 0.2, 1);
            //  //pNumRemap.MapRange(0.2, 0.4, 2);
            //  //pNumRemap.MapRange(0.4, 0.6, 3);
            //  //pNumRemap.MapRange(0.6, dMaxValue, 4);
            //  //pNumRemap.MapRangeToNoData(-1000, 0);
            //  //pNumRemap.MapRange(0.8, 1000, 5);

            //  pNumRemap.MapRange(dMinValue,0.2, 0);
            //  pNumRemap.MapRange(0.2, 0.4, 1);
            //  pNumRemap.MapRange(0.4, 0.6, 2);
            //  pNumRemap.MapRange(0.6, 0.8, 3);
            //  pNumRemap.MapRange(0.8, dMaxValue, 4);
            //  IRemap pRemap = pNumRemap as IRemap;
            //  //IGeoDataset geoDataset_result = pReclassOp.ReclassByRemap(raskDataset, pRemap, true);
            //  IRaster pOutRaster = pReclassOp.ReclassByRemap(raskDataset, pRemap, false) as IRaster;
            //  IRasterLayer rasterLayer = new RasterLayerClass();
            //  rasterLayer.CreateFromRaster(pOutRaster);
            //  if (rasterLayer != null)
            //  {
            //      //string fullPath = Common.RoadshapePath+"道路.shp";
            //      rasterLayer.Name = "公路风险";
            //      Boolean IsEqual = false;
            //      //int Position = fullPath.LastIndexOf("\\");
            //      ////文件目录
            //      //string FilePath = fullPath.Substring(0, Position);
            //      //string ShpName = fullPath.Substring(Position + 1);
            //      //IWorkspaceFactory pWF;
            //      //pWF = new ShapefileWorkspaceFactory();
            //      //IFeatureWorkspace pFWS;
            //      //pFWS = (IFeatureWorkspace)pWF.OpenFromFile(FilePath, 0);
            //      //IFeatureClass pFClass;
            //      //pFClass = pFWS.OpenFeatureClass(ShpName);
            //      //IFeatureLayer pFLayer = new FeatureLayer();
            //      //pFLayer.FeatureClass = pFClass;

            //      for (int i = 0; i < MainFrom.m_mapControl.LayerCount;i++ )
            //      {
            //          ILayer ComLayer=MainFrom.m_mapControl.get_Layer(i);
            //          if (rasterLayer.Name == ComLayer.Name)
            //          {
            //              IsEqual = true;
            //          }
            //      }
            //      if (!IsEqual)
            //      {
            //          //MainFrom.m_mapControl.AddLayer((ILayer)pFLayer);
            //          MainFrom.m_mapControl.AddLayer(rasterLayer);
            //          IEnvelope envelope = rasterLayer.AreaOfInterest;
            //          MainFrom.m_mapControl.ActiveView.Extent = envelope;//缩放至图层
            //      }
            //  }
            //  return true;
            #endregion
            IWorkspaceFactory rWorkspaceFactory = new RasterWorkspaceFactory();
            IWorkspace        SWorkspace        = rWorkspaceFactory.OpenFromFile(saveWorkspace, 0);
            IRasterWorkspace  rasterWorkspace   = SWorkspace as IRasterWorkspace;
            //栅格计算器 计算风险级数  先不要签你的三方协议 然后存储  表达式必须隔开
            IMapAlgebraOp  mapAlgebra     = new RasterMapAlgebraOpClass();
            IRasterDataset roadEvalRaster = OpenRasterDataSet(rasterWorkspace, roadEvalName);
            IGeoDataset    geo1           = roadEvalRaster as IGeoDataset;
            mapAlgebra.BindRaster(geo1, "EvalRaster");
            IGeoDataset raskDataset = mapAlgebra.Execute("[EvalRaster] * " + rains + " / 25");//然后存储  表达式必须间隔开
            //将生成的风险栅格重分类
            //<0.2	一级:可能性小
            //0.2-0.4	二级:可
            //能性较小
            //0.4-0.6	三级:可能性较大
            //0.6-0.8	四级:可能性大
            //>0.8	五级:可能性很大
            // 输入:raskDataset
            //   输出:geoDataset_result
            IRasterBandCollection pRsBandCol  = raskDataset as IRasterBandCollection;
            IRasterBand           pRasterBand = pRsBandCol.Item(0);
            pRasterBand.ComputeStatsAndHist();
            IRasterStatistics            pRasterStatistic = pRasterBand.Statistics;
            double                       dMaxValue        = pRasterStatistic.Maximum;
            double                       dMinValue        = pRasterStatistic.Minimum;
            IReclassOp                   pReclassOp       = new RasterReclassOpClass();
            INumberRemap                 pNumRemap        = new NumberRemapClass();
            IDictionary <int, RoadRange> roadRanges       = this.roadRiskConfig.GetRoadRiskLevelFromConfig();
            foreach (var v in roadRanges)
            {
                pNumRemap.MapRange(v.Value.MinValue, v.Value.MaxValue, v.Key);
            }
            IRemap pRemap = pNumRemap as IRemap;
            //IGeoDataset geoDataset_result = pReclassOp.ReclassByRemap(raskDataset, pRemap, true);
            IRaster      pOutRaster  = pReclassOp.ReclassByRemap(raskDataset, pRemap, false) as IRaster;
            IRasterLayer rasterLayer = new RasterLayerClass();
            rasterLayer.CreateFromRaster(pOutRaster);
            if (rasterLayer != null)
            {
                rasterLayer.Name = "公路风险";
                for (int i = 0; i < MainFrom.m_mapControl.LayerCount; i++)
                {
                    ILayer ComLayer = MainFrom.m_mapControl.get_Layer(i);
                    if (rasterLayer.Name == ComLayer.Name)
                    {
                        MainFrom.m_mapControl.Map.DeleteLayer(ComLayer);
                    }
                }
                Common.funColorForRaster_Classify(rasterLayer, roadRanges.Count);
                IEnvelope envelope = rasterLayer.AreaOfInterest;
                MainFrom.m_mapControl.ActiveView.Extent = envelope;//缩放至图层
            }
            return(true);
        }