Exemple #1
0
        private IExtractResult CompareDATFile(string backWaterPath, string binWater)
        {
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("backWaterPath", new FilePrdMap(backWaterPath, 1, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { 1 }));
            filePrdMap.Add("binWater", new FilePrdMap(binWater, 1, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { 1 }));
            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);

            if (vrd == null)
            {
                PrintInfo("数据间无相交部分,无法进行泛滥缩小水体计算!");
                if (filePrdMap != null && filePrdMap.Count > 0)
                {
                    foreach (FilePrdMap value in filePrdMap.Values)
                    {
                        if (value.Prd != null)
                        {
                            value.Prd.Dispose();
                        }
                    }
                }
                return(null);
            }
            try
            {
                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                IPixelFeatureMapper <Int16> result    = new MemPixelFeatureMapper <Int16>("FLOD", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                rpVisitor.VisitPixel(new int[] { filePrdMap["backWaterPath"].StartBand,
                                                 filePrdMap["binWater"].StartBand },
                                     (idx, values) =>
                {
                    if (values[0] == 1 && values[1] == 1)
                    {
                        result.Put(idx, 1);
                    }
                    else if (values[0] == 1 && values[1] == 0)
                    {
                        result.Put(idx, 5);
                    }
                    else if (values[0] == 0 && values[1] == 1)
                    {
                        result.Put(idx, 4);
                    }
                });
                RasterIdentify rid = new RasterIdentify(new string[] { backWaterPath, binWater });
                rid.ProductIdentify       = _subProductDef.ProductDef.Identify;
                rid.SubProductIdentify    = _identify;
                rid.IsOutput2WorkspaceDir = true;
                IInterestedRaster <Int16> iir = new InterestedRaster <Int16>(rid, result.Size, result.CoordEnvelope, result.SpatialRef);
                iir.Put(result);
                iir.Dispose();
                return(new FileExtractResult("扩大缩小水体", iir.FileName));
            }
            finally
            {
                vrd.Dispose();
            }
        }
Exemple #2
0
        private IPixelFeatureMapper <T> MakeCompareRaster <T1, T>(string productIdentify, string fstFileName, string sedFileName, Func <T1, T1, T> function)
        {
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("backWaterPath", new FilePrdMap(fstFileName, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));
            filePrdMap.Add("binWater", new FilePrdMap(sedFileName, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));
            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);

            if (vrd == null)
            {
                throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
            }
            try
            {
                ArgumentProvider         ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <T1> rpVisitor = new RasterPixelsVisitor <T1>(ap);
                IPixelFeatureMapper <T>  result    = new MemPixelFeatureMapper <T>(productIdentify, 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                rpVisitor.VisitPixel(new int[] { filePrdMap["backWaterPath"].StartBand, filePrdMap["binWater"].StartBand },
                                     (idx, values) =>
                {
                    result.Put(idx, function(values[0], values[1]));
                });
                return(result);
            }
            finally
            {
                vrd.Dispose();
            }
        }
Exemple #3
0
        private string MAxValue(string[] fileNames, int bandNo, float zoom)
        {
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            for (int i = 0; i < fileNames.Length; i++)
            {
                FilePrdMap map = new FilePrdMap(fileNames[i], zoom, new VaildPra(float.MinValue, float.MaxValue), new int[] { bandNo });
                if (map.BandCount < 1)
                {
                    PrintInfo("请选择正确的数据进行最大值合成。");
                    return(null);
                }
                filePrdMap.Add("ndviFile" + i.ToString(), map);
            }

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider prd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);

            if (prd == null)
            {
                throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
            }
            IRasterPixelsVisitor <float> visitor = new RasterPixelsVisitor <float>(new ArgumentProvider(prd, null));

            List <int> bands = new List <int>();

            for (int i = 0; i < fileNames.Length; i++)
            {
                bands.Add(filePrdMap["ndviFile" + i.ToString()].StartBand);
            }
            PrintInfo("正在进行最大值合成,请稍后...!");
            IPixelFeatureMapper <float> result = new MemPixelFeatureMapper <float>("0MAX", prd.Width * prd.Height, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);

            visitor.VisitPixel(bands.ToArray(),
                               (idx, values) =>
            {
                result.Put(idx, values.Max() * zoom);
            }
                               );
            RasterIdentify            rid = new RasterIdentify(fileNames);
            IInterestedRaster <float> iir = new InterestedRaster <float>(rid, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);

            iir.Put(result);
            iir.Dispose();
            return(iir.FileName);
        }
Exemple #4
0
        private IExtractResult CalcOPTDByOneFile(IVirtualRasterDataProvider vrd, IRasterDataProvider optdPrd, int optdCH, double OptdZoom, int lwpCH, double lwpZoom)
        {
            ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
            RasterPixelsVisitor <Int16> rpVisitor = new RasterPixelsVisitor <Int16>(ap);
            IPixelFeatureMapper <Int16> curERAD   = new MemPixelFeatureMapper <Int16>("ERAD", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);

            rpVisitor.VisitPixel(new int[] { optdCH, optdPrd.BandCount + lwpCH },
                                 (index, values) =>
            {
                curERAD.Put(index, (Int16)(3 / 2 * ((values[1] / lwpZoom) / 1 * (values[0] / OptdZoom))));
            });
            return(curERAD);
        }
Exemple #5
0
        public static Dictionary <float, List <float> > NDVIHistograms(TVDIUCArgs ucArgs)
        {
            string error = string.Empty;

            if (!CheckHistograms(ucArgs, ref error))
            {
                return(null);
            }
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("NDVIFile", new FilePrdMap(ucArgs.NDVIFile, ucArgs.TVDIParas.NdviFile.Zoom, new VaildPra(ucArgs.TVDIParas.NdviFile.Min, ucArgs.TVDIParas.NdviFile.Max), new int[] { ucArgs.TVDIParas.NdviFile.Band }));
            filePrdMap.Add("LSTFile", new FilePrdMap(ucArgs.ECLstFile, ucArgs.TVDIParas.LstFile.Zoom, new VaildPra(ucArgs.TVDIParas.LstFile.Min, ucArgs.TVDIParas.LstFile.Max), new int[] { 1 }));

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd     = null;

            try
            {
                vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
                if (vrd == null)
                {
                    throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
                }
                Dictionary <float, List <float> > result = new Dictionary <float, List <float> >();
                ArgumentProvider            ap           = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor    = new RasterPixelsVisitor <float>(ap);
                TVDIParaClass tvdiP = ucArgs.TVDIParas;
                IPixelFeatureMapper <float> _result = new MemPixelFeatureMapper <float>("0DWE", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                float ndvizoom = tvdiP.NdviFile.Zoom;
                float lstZoom  = tvdiP.LstFile.Zoom;
                rpVisitor.VisitPixel(new int[] { filePrdMap["NDVIFile"].StartBand,
                                                 filePrdMap["LSTFile"].StartBand },
                                     (index, values) =>
                {
                    if (values[1] >= tvdiP.LstFile.Min / lstZoom && values[1] <= tvdiP.LstFile.Max / lstZoom &&
                        values[0] >= tvdiP.NdviFile.Min / ndvizoom && values[0] <= tvdiP.NdviFile.Max / ndvizoom)
                    {
                        if (!result.ContainsKey(values[0]))
                        {
                            result.Add(values[0], new List <float>());
                        }
                        result[values[0]].Add(values[1]);
                    }
                });
                return(result.Count == 0 ? null : result);
            }
            finally
            {
                vrd.Dispose();
            }
        }
Exemple #6
0
        private IExtractResult ERADAlgorithm()
        {
            int    optdCH   = (int)_argumentProvider.GetArg("OPTDBandNo");
            double OptdZoom = (float)_argumentProvider.GetArg("OPTDZoom");
            int    lwpCH    = (int)_argumentProvider.GetArg("LWPBandNo");
            double LwpZoom  = (float)_argumentProvider.GetArg("LWPZoom");

            if (_argumentProvider.GetArg("mainfiles") == null || _argumentProvider.GetArg("LWPFile") == null)
            {
                return(null);
            }
            string optdFile = _argumentProvider.GetArg("mainfiles").ToString();
            string lwpFile  = _argumentProvider.GetArg("LWPFile").ToString();

            if (optdCH == -1 || lwpCH == -1 || !File.Exists(optdFile) || !File.Exists(lwpFile))
            {
                //errorStr = "雾滴尺度产品生产所用通道未设置完全,请检查!";
                return(null);
            }

            IRasterDataProvider        optdPrd = null;
            IRasterDataProvider        lwpPrd  = null;
            IVirtualRasterDataProvider vrd     = null;

            try
            {
                optdPrd = GeoDataDriver.Open(optdFile) as IRasterDataProvider;
                lwpPrd  = GeoDataDriver.Open(lwpFile) as IRasterDataProvider;
                vrd     = new VirtualRasterDataProvider(new IRasterDataProvider[] { optdPrd, lwpPrd });
                return(CalcOPTDByOneFile(vrd, optdPrd, optdCH, OptdZoom, lwpCH, LwpZoom));
            }
            finally
            {
                optdPrd.Dispose();
                lwpPrd.Dispose();
                vrd.Dispose();
            }
        }
Exemple #7
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "0MAX")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }

            string[] fileNames = GetStringArray("SelectedPrimaryFiles");
            if (fileNames == null || fileNames.Count() == 0)
            {
                PrintInfo("请选择参与最大值合成的数据!");
                return(null);
            }
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            for (int i = 0; i < fileNames.Length; i++)
            {
                FilePrdMap map = new FilePrdMap(fileNames[i], 1, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { 1 });
                if (map.BandCount < 1)
                {
                    PrintInfo("请选择正确的数据进行最大值合成。");
                    return(null);
                }
                filePrdMap.Add("ndviFile" + i.ToString(), map);
            }

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider prd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);


            if (prd == null)
            {
                throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
            }
            IRasterPixelsVisitor <float> visitor = new RasterPixelsVisitor <float>(new ArgumentProvider(prd, null));

            List <int> bands = new List <int>();

            for (int i = 0; i < fileNames.Length; i++)
            {
                bands.Add(filePrdMap["ndviFile" + i.ToString()].StartBand);
            }
            Size size = new Size(prd.Width, prd.Height);
            IPixelFeatureMapper <Int16> result = new MemPixelFeatureMapper <Int16>("0MAX", prd.Width * prd.Height, size, prd.CoordEnvelope, prd.SpatialRef);

            visitor.VisitPixel(bands.ToArray(),
                               (idx, values) =>
            {
                result.Put(idx, (Int16)values.Max());
            }
                               );
            result.SetDispaly(false);
            return(result);
        }
Exemple #8
0
        private IExtractResult OPTDAlgorithm()
        {
            int    visibleCH             = (int)_argumentProvider.GetArg("Visible");
            double OptdZoom              = (float)_argumentProvider.GetArg("OptdZoom");
            double visibleZoom           = (double)_argumentProvider.GetArg("Visible_Zoom");
            float  extinctionCoefficient = (float)_argumentProvider.GetArg("ExtinctionCoefficient");

            if (_argumentProvider.GetArg("CSRFile") == null || _argumentProvider.GetArg("DBLVFile") == null || _argumentProvider.GetArg("CurrentRasterFile") == null)
            {
                return(null);
            }
            string csrFile           = _argumentProvider.GetArg("CSRFile").ToString();
            string dvlbFile          = _argumentProvider.GetArg("DBLVFile").ToString();
            string CurrentRasterFile = _argumentProvider.GetArg("CurrentRasterFile").ToString();

            using (IRasterDataProvider rasterProvider = RasterDataDriver.Open(CurrentRasterFile) as IRasterDataProvider)
            {
                if (rasterProvider != null)
                {
                    IBandNameRaster bandNameRaster = rasterProvider as IBandNameRaster;
                    visibleCH = TryGetBandNo(bandNameRaster, "Visible");
                }
            }

            string errorStr = null;

            if (visibleCH == -1 || !File.Exists(csrFile) || !File.Exists(CurrentRasterFile) || !File.Exists(dvlbFile))
            {
                errorStr = "光学厚度生产所用通道未设置完全,请检查!";
                return(null);
            }

            IVirtualRasterDataProvider      vrd        = null;
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("CurrentRasterFile", new FilePrdMap(CurrentRasterFile, 1, new VaildPra(UInt16.MinValue, UInt16.MaxValue), new int[] { visibleCH }));
            filePrdMap.Add("csrFile", new FilePrdMap(csrFile, 1, new VaildPra(UInt16.MinValue, UInt16.MaxValue), new int[] { 1 }));
            filePrdMap.Add("dvlbFile", new FilePrdMap(dvlbFile, 1, new VaildPra(UInt16.MinValue, UInt16.MaxValue), new int[] { 1 }));

            ITryCreateVirtualPrd tryVPrd = new TryCreateVirtualPrdByMultiFile();

            vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
            if (vrd == null)
            {
                if (filePrdMap != null && filePrdMap.Count() > 0)
                {
                    foreach (FilePrdMap value in filePrdMap.Values)
                    {
                        if (value.Prd != null)
                        {
                            value.Prd.Dispose();
                        }
                    }
                }
                return(null);
            }
            try
            {
                return(CalcOPTDByOneFile(filePrdMap, vrd, extinctionCoefficient, visibleCH, visibleZoom, OptdZoom));
            }
            finally
            {
                if (filePrdMap != null && filePrdMap.Count() > 0)
                {
                    foreach (FilePrdMap value in filePrdMap.Values)
                    {
                        if (value.Prd != null)
                        {
                            value.Prd.Dispose();
                        }
                    }
                }
                if (vrd != null)
                {
                    vrd.Dispose();
                }
            }
        }
Exemple #9
0
 private IExtractResult CalcOPTDByOneFile(Dictionary <string, FilePrdMap> filePrdMap, IVirtualRasterDataProvider vrd, float extinctionCoefficient, int visibleCH, double visibleZoom, double OptdZoom)
 {
     try
     {
         ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
         RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
         IPixelFeatureMapper <Int16> curOPTD   = new MemPixelFeatureMapper <Int16>("OPTD", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
         float upRef = 0f;
         rpVisitor.VisitPixel(new int[] { filePrdMap["CurrentRasterFile"].StartBand,
                                          filePrdMap["csrFile"].StartBand,
                                          filePrdMap["dvlbFile"].StartBand },
                              (index, values) =>
         {
             if (values[2] == 1f)
             {
                 upRef = values[0] - Convert.ToSingle(values[1] * Math.Pow((1 - (values[0] / visibleZoom)), 2));
                 curOPTD.Put(index, (Int16)(upRef * (1 / extinctionCoefficient) / ((visibleZoom - upRef) * 3) * OptdZoom));
             }
             else
             {
                 curOPTD.Put(index, 0);
             }
         });
         return(curOPTD);
     }
     finally
     {
         vrd.Dispose();
     }
 }
Exemple #10
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "0VCI")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }
            if (_argumentProvider.GetArg("mainfiles") == null)
            {
                PrintInfo("请选择NDVI数据。");
                return(null);
            }
            string ndviFile = _argumentProvider.GetArg("mainfiles").ToString();

            if (!File.Exists(ndviFile))
            {
                PrintInfo("选择的数据\"" + ndviFile + "\"不存在。");
                return(null);
            }

            if (_argumentProvider.GetArg("NdviCH") == null)
            {
                PrintInfo("参数\"NdviCH\"为空。");
                return(null);
            }
            int ndviCH = (int)(_argumentProvider.GetArg("NdviCH"));

            if (_argumentProvider.GetArg("NdviMaxCH") == null)
            {
                PrintInfo("参数\"NdviMaxCH\"为空。");
                return(null);
            }
            int ndviMaxCH = (int)(_argumentProvider.GetArg("NdviMaxCH"));

            if (_argumentProvider.GetArg("NdviMinCH") == null)
            {
                PrintInfo("参数\"NdviMinCH\"为空。");
                return(null);
            }
            int ndviMinCH = (int)(_argumentProvider.GetArg("NdviMinCH"));

            if (ndviCH < 1 || ndviMaxCH < 1 || ndviMinCH < 1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            if (_argumentProvider.GetArg("resultZoom") == null)
            {
                PrintInfo("参数\"resultZoom\"为空。");
                return(null);
            }
            UInt16 resultZoom = Convert.ToUInt16(_argumentProvider.GetArg("resultZoom"));

            string backFile = null;

            if (_argumentProvider.GetArg("BackFile") == null)
            {
                string defaultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemData\\ndvi_0901.ldf");
                if (!File.Exists(defaultPath))
                {
                    return(null);
                }
                backFile = defaultPath;
            }
            else
            {
                backFile = _argumentProvider.GetArg("BackFile").ToString();
            }
            //add at 2012.9.22,屏蔽背景库数据也选择了同样的ndvi文件所出现的错误
            if (backFile == ndviFile)
            {
                PrintInfo("请选择正确的背景库数据!");
                return(null);
            }

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("mainfiles", new FilePrdMap(ndviFile, resultZoom, new VaildPra(float.MinValue, float.MaxValue), new int[] { ndviCH }));
            filePrdMap.Add("BackFile", new FilePrdMap(backFile, resultZoom, new VaildPra(float.MinValue, float.MaxValue), new int[] { ndviMaxCH, ndviMinCH }));

            //为防止用户选择的波段超出数据波段的界限
            if (filePrdMap["mainfiles"].BandCount < ndviCH || filePrdMap["BackFile"].BandCount < ndviMinCH || filePrdMap["BackFile"].BandCount < ndviMaxCH)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider prd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);

            if (prd == null)
            {
                throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
            }
            IRasterPixelsVisitor <Int16> visitor = new RasterPixelsVisitor <Int16>(new ArgumentProvider(prd, null));

            IPixelFeatureMapper <Int16> result = new MemPixelFeatureMapper <Int16>("0VCI", prd.Width * prd.Height, new System.Drawing.Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);

            visitor.VisitPixel(new int[] { filePrdMap["mainfiles"].StartBand,
                                           filePrdMap["BackFile"].StartBand,
                                           filePrdMap["BackFile"].StartBand + 1 },
                               (idx, values) =>
            {
                result.Put(idx, ((values[1] - values[2]) == 0 ? (Int16)0 : (Int16)((float)(values[0] - values[2]) / (values[1] - values[2]) * resultZoom)));
            }
                               );
            return(result);
        }
Exemple #11
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "ANMI")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }
            if (_argumentProvider.GetArg("NDVIFile") == null)
            {
                PrintInfo("请选择植被指数数据。");
                return(null);
            }
            string ndvi = _argumentProvider.GetArg("NDVIFile").ToString();

            if (!File.Exists(ndvi))
            {
                PrintInfo("所选择的数据:\"" + ndvi + "\"不存在。");
                return(null);
            }
            if (_argumentProvider.GetArg("NdviCH") == null)
            {
                PrintInfo("参数\"NdviCH\"为空。");
                return(null);
            }
            int ndviCh = (int)_argumentProvider.GetArg("NdviCH");

            if (_argumentProvider.GetArg("NDVIAvgFile") == null)
            {
                PrintInfo("请选择植被指数年均值数据。");
                return(null);
            }
            string avg = _argumentProvider.GetArg("NDVIAvgFile").ToString();

            if (!File.Exists(avg))
            {
                PrintInfo("所选择的数据:\"" + avg + "\"不存在。");
                return(null);
            }
            if (_argumentProvider.GetArg("NdviAvgCH") == null)
            {
                PrintInfo("参数\"NdviAvgCH\"为空。");
                return(null);
            }
            int avgCH = (int)_argumentProvider.GetArg("NdviAvgCH");

            if (ndviCh < 1 || avgCH < 1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            //Create virtualProvider
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("NDVIFile", new FilePrdMap(ndvi, 1000, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { ndviCh }));
            filePrdMap.Add("NDVIAvgFile", new FilePrdMap(avg, 1000, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { avgCH }));

            //为防止用户选择的波段超出数据波段的界限
            if (filePrdMap["NDVIFile"].BandCount < ndviCh || filePrdMap["NDVIAvgFile"].BandCount < avgCH)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider prd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);

            if (prd == null)
            {
                throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
            }

            IRasterPixelsVisitor <Int16> visitor = new RasterPixelsVisitor <Int16>(new ArgumentProvider(prd, null));
            IPixelFeatureMapper <Int16>  result  = new MemPixelFeatureMapper <Int16>("ANMI", prd.Width * prd.Height, new System.Drawing.Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);

            visitor.VisitPixel(new int[] { filePrdMap["NDVIFile"].StartBand,
                                           filePrdMap["NDVIAvgFile"].StartBand },
                               (idx, values) =>
            {
                result.Put(idx, (Int16)(values[0] - values[1]));
            }
                               );
            return(result);
        }
 private IPixelIndexMapper GenerateHistoryResultByAOI(IPixelIndexMapper pixelMapper, int[] drawedAOI)
 {
     if (drawedAOI == null || drawedAOI.Length < 1)
     {
         return(null);
     }
     if (lstFiles.Items.Count < 1)
     {
         return(null);
     }
     foreach (string file in lstFiles.Items)
     {
         if (!File.Exists(file))
         {
             return(null);
         }
     }
     using (IRasterDataProvider prd = GeoDataDriver.Open(_currentRasterFile) as IRasterDataProvider)
     {
         List <int> aoiList = new List <int>();
         aoiList.AddRange(drawedAOI);
         IPixelIndexMapper result = PixelIndexMapperFactory.CreatePixelIndexMapper("FLD", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);
         if (pixelMapper != null && pixelMapper.Indexes.Count() > 0)
         {
             foreach (int i in pixelMapper.Indexes)
             {
                 if (aoiList.Contains(i))
                 {
                     result.Put(i);
                 }
             }
         }
         //
         IInterestedRaster <Int16> iir = null;
         try
         {
             RasterIdentify id = new RasterIdentify();
             id.ThemeIdentify      = "CMA";
             id.ProductIdentify    = "FLD";
             id.SubProductIdentify = "DBLV";
             iir = new InterestedRaster <Int16>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone());
             int[] idxs = result.Indexes.ToArray();
             iir.Put(idxs, 1);
         }
         finally
         {
             iir.Dispose();
         }
         Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();
         filePrdMap.Add("currentDBLV", new FilePrdMap(iir.FileName, 1, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { 1 }));
         int index = 0;
         foreach (string file in lstFiles.Items)
         {
             filePrdMap.Add("dblv" + index, new FilePrdMap(file, 1, new VaildPra(Int16.MinValue, Int16.MaxValue), new int[] { 1 }));
             index++;
         }
         ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
         IVirtualRasterDataProvider vrd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
         if (vrd == null)
         {
             if (filePrdMap != null && filePrdMap.Count > 0)
             {
                 foreach (FilePrdMap value in filePrdMap.Values)
                 {
                     if (value.Prd != null)
                     {
                         value.Prd.Dispose();
                     }
                 }
             }
             return(null);
         }
         try
         {
             ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
             RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
             int   historyCount = lstFiles.Items.Count;
             int[] bandNos      = new int[historyCount + 1];
             for (int i = 0; i < bandNos.Length; i++)
             {
                 bandNos[i] = i + 1;
             }
             int[] difArray = new int[historyCount];
             rpVisitor.VisitPixel(new Rectangle(0, 0, prd.Width, prd.Height), drawedAOI, bandNos,
                                  (idx, values) =>
             {
                 for (int i = 0; i < historyCount; i++)
                 {
                     if (values[0] != values[i + 1])
                     {
                         difArray[i]++;
                     }
                 }
             });
             int min = difArray[0], minIndex = 0;
             for (int i = 1; i < difArray.Length; i++)
             {
                 if (min > difArray[i])
                 {
                     min      = difArray[i];
                     minIndex = i;
                 }
             }
             rpVisitor.VisitPixel(bandNos,
                                  (idx, values) =>
             {
                 if (values[minIndex + 1] == 1)
                 {
                     if (!aoiList.Contains(idx))
                     {
                         result.Put(idx);
                     }
                 }
             });
             return(result);
         }
         finally
         {
             vrd.Dispose();
             if (File.Exists(iir.FileName))
             {
                 File.Delete(iir.FileName);
             }
         }
     }
 }
        private IExtractResult CalcMix(string dblvFile, string ldfFile, double bandZoom, int bandNo, double resultZoom, int[] dblvAOI, float waterNir, float LandNir, double zoom)
        {
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("dblvFile", new FilePrdMap(dblvFile, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));
            filePrdMap.Add("ldfFile", new FilePrdMap(ldfFile, bandZoom, new VaildPra(float.MinValue, float.MaxValue), new int[] { bandNo }));
            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
            int minWnd = 3, maxWnd = 3;

            if (vrd == null)
            {
                if (filePrdMap != null && filePrdMap.Count > 0)
                {
                    foreach (FilePrdMap value in filePrdMap.Values)
                    {
                        if (value.Prd != null)
                        {
                            value.Prd.Dispose();
                        }
                    }
                }
                return(null);
            }
            try
            {
                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                Size size = new Size(vrd.Width, vrd.Height);
                MemPixelFeatureMapper <Int16> result = new MemPixelFeatureMapper <Int16>("0MIX", 1000, size, vrd.CoordEnvelope, vrd.SpatialRef);
                int       dblvBand   = filePrdMap["dblvFile"].StartBand;
                int       ldfBand    = filePrdMap["ldfFile"].StartBand;
                int[]     wndBandNos = new int[] { dblvBand, ldfBand };
                Rectangle aoiRect    = AOIHelper.ComputeAOIRect(dblvAOI, size);
                bool      isEdge     = false;
                using (IRasterPixelsVisitor <float> visitor = new RasterPixelsVisitor <float>(ap))
                {
                    visitor.VisitPixelWnd(aoiRect, dblvAOI, wndBandNos, wndBandNos, minWnd, maxWnd,
                                          (pixelIdx, crtWndSize, bandValues, wndValues) =>
                    {
                        return(false);
                    },
                                          (pixelIdx, crtWndSize, bandValues, wndValues) =>
                    {
                        isEdge = IsEdgeMethod(bandValues, wndValues, 0);
                        if (isEdge)
                        {
                            result.Put(pixelIdx, GetResult(bandValues, wndValues, waterNir, LandNir, zoom));
                        }
                    });
                }
                return(result);
            }
            finally
            {
                if (vrd != null)
                {
                    vrd.Dispose();
                }
                if (filePrdMap != null && filePrdMap.Count > 0)
                {
                    foreach (FilePrdMap value in filePrdMap.Values)
                    {
                        if (value.Prd != null)
                        {
                            value.Prd.Dispose();
                        }
                    }
                }
            }
        }
        private void GetDBLVAOIIndex(string dblvFile, string cloudFile, List <int> dblvAOI)
        {
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("dblvFile", new FilePrdMap(dblvFile, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));
            filePrdMap.Add("cloudFile", new FilePrdMap(cloudFile, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));
            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
            int minWnd = 3, maxWnd = 3;

            if (vrd == null)
            {
                if (filePrdMap != null && filePrdMap.Count > 0)
                {
                    foreach (FilePrdMap value in filePrdMap.Values)
                    {
                        if (value.Prd != null)
                        {
                            value.Prd.Dispose();
                        }
                    }
                }
                return;
            }
            try
            {
                List <int> temp = new List <int>();
                temp.AddRange(dblvAOI);
                dblvAOI.Clear();
                ArgumentProvider ap   = new ArgumentProvider(vrd, null);
                Size             size = new Size(vrd.Width, vrd.Height);
                int       dblvBand    = filePrdMap["dblvFile"].StartBand;
                int       cloudBand   = filePrdMap["cloudFile"].StartBand;
                int[]     tempAOI     = temp.ToArray();
                Rectangle aoiRect     = AOIHelper.ComputeAOIRect(tempAOI, size);
                int[]     wndBandNos  = new int[] { dblvBand, cloudBand };
                bool      isCloudEgde = false;
                using (IRasterPixelsVisitor <float> visitor = new RasterPixelsVisitor <float>(ap))
                {
                    visitor.VisitPixelWnd(aoiRect, tempAOI, wndBandNos, wndBandNos, minWnd, maxWnd,
                                          (pixelIdx, crtWndSize, bandValues, wndValues) =>
                    {
                        return(false);
                    },
                                          (pixelIdx, crtWndSize, bandValues, wndValues) =>
                    {
                        isCloudEgde = IsCloudEdgeMethod(bandValues, wndValues, 1);
                        if (isCloudEgde)
                        {
                            temp.Remove(pixelIdx);
                        }
                    });
                }
                dblvAOI.AddRange(temp);
                temp = null;
            }
            finally
            {
                if (vrd != null)
                {
                    vrd.Dispose();
                }
            }
        }
Exemple #15
0
        private IExtractResult DemAlgorithm()
        {
            int    DNTBandCH   = (int)_curArguments.GetArg("DNTBand");
            double DNTZoom     = (float)_curArguments.GetArg("DNTZoom");
            float  DNTVaildMin = (float)_curArguments.GetArg("DNTVaildMin");
            float  DNTVaildMax = (float)_curArguments.GetArg("DNTVaildMax");

            Int16 DemMin     = (Int16)_curArguments.GetArg("DemMin");
            float DemCorrect = (float)_curArguments.GetArg("DemCorrect");

            double SWIZoom = (float)_curArguments.GetArg("SWIZoom");
            DRTExpCoefficientCollection ExpCoefficient = _curArguments.GetArg("ExpCoefficient") as DRTExpCoefficientCollection;
            string errorStr = null;

            if (DNTBandCH == -1 || _curArguments.GetArg("DNTFile") == null || _curArguments.GetArg("DemFile") == null || ExpCoefficient == null)
            {
                errorStr = "SWI生产所用文件或通道未设置完全,请检查!";
                return(null);
            }
            string DNTFile = _curArguments.GetArg("DNTFile").ToString();
            string DemFile = _curArguments.GetArg("DemFile").ToString();

            if (string.IsNullOrEmpty(ExpCoefficient.EgdesFilename) || !File.Exists(ExpCoefficient.EgdesFilename))
            {
                string fileanme = AppDomain.CurrentDomain.BaseDirectory + @"\SystemData\RasterTemplate\\China_Province.dat";
                if (File.Exists(fileanme))
                {
                    ExpCoefficient.EgdesFilename = fileanme;
                }
                else
                {
                    errorStr = "SWI生产所用的经验系数边界文件不存在,请检查!";
                    return(null);
                }
            }
            ;
            string EdgesFile = ExpCoefficient.EgdesFilename;

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("DNTFile", new FilePrdMap(DNTFile, DNTZoom, new VaildPra(DNTVaildMin, DNTVaildMax), new int[] { DNTBandCH }));
            filePrdMap.Add("DemFile", new FilePrdMap(DemFile, 1, new VaildPra(DemMin, float.MaxValue), new int[] { 1 }));
            filePrdMap.Add("EdgesFile", new FilePrdMap(EdgesFile, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            DRTExpCoefficientItem      item    = null;
            IVirtualRasterDataProvider vrd     = null;

            try
            {
                vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
                if (vrd == null)
                {
                    throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
                }
                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                IPixelFeatureMapper <Int16> result    = new MemPixelFeatureMapper <Int16>("0SWI", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                double swiTemp = 0f;
                rpVisitor.VisitPixel(new int[] { filePrdMap["DNTFile"].StartBand,
                                                 filePrdMap["DemFile"].StartBand,
                                                 filePrdMap["EdgesFile"].StartBand },
                                     (index, values) =>
                {
                    if (values[0] < filePrdMap["DNTFile"].VaildValue.Min || values[0] > filePrdMap["DNTFile"].VaildValue.Max)
                    {
                        result.Put(index, 0);
                    }
                    else
                    {
                        item = ExpCoefficient.GetExpItemByNum((int)values[2]);
                        if (item == null)
                        {
                            result.Put(index, 0);
                        }
                        else
                        {
                            //计算SWI
                            swiTemp = item.APara * values[0] + item.BPara + item.CPara;
                            if (values[1] > filePrdMap["DemFile"].VaildValue.Min)
                            {
                                swiTemp += DemCorrect;
                            }
                            result.Put(index, (Int16)(swiTemp * SWIZoom));
                        }
                    }
                });
                return(result);
            }
            finally
            {
                if (vrd != null)
                {
                    vrd.Dispose();
                }
            }
        }
Exemple #16
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "CHAZ")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }
            if (_argumentProvider.GetArg("mainfiles") == null)
            {
                PrintInfo("请选择植被指数(被减数)数据。");
                return(null);
            }
            string bjianshu = _argumentProvider.GetArg("mainfiles").ToString();

            if (!File.Exists(bjianshu))
            {
                PrintInfo("所选择的数据:\"" + bjianshu + "\"不存在。");
                return(null);
            }
            if (_argumentProvider.GetArg("jianshu") == null)
            {
                PrintInfo("请选择植被指数(减数)数据。");
                return(null);
            }
            string jianshu = _argumentProvider.GetArg("jianshu").ToString();

            if (!File.Exists(jianshu))
            {
                PrintInfo("所选择的数据:\"" + jianshu + "\"不存在。");
                return(null);
            }
            if (_argumentProvider.GetArg("NdviCH1") == null)
            {
                PrintInfo("参数\"NdviCH1\"为空。");
                return(null);
            }
            if (_argumentProvider.GetArg("NdviCH2") == null)
            {
                PrintInfo("参数\"NdviCH2\"为空。");
                return(null);
            }

            int ch1 = (int)_argumentProvider.GetArg("NdviCH1");
            int ch2 = (int)_argumentProvider.GetArg("NdviCH2");

            if (ch1 < 0 || ch2 < 0)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            //Create virtualProvider
            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("beijianshu", new FilePrdMap(bjianshu, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { ch1 }));
            filePrdMap.Add("jianshu", new FilePrdMap(jianshu, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { ch2 }));

            //为防止用户选择的波段超出数据波段的界限
            if (filePrdMap["beijianshu"].BandCount < 1 || filePrdMap["jianshu"].BandCount < 1)
            {
                PrintInfo("请选择正确的栅格数据进行差值计算。");
                return(null);
            }
            if (filePrdMap["beijianshu"].BandCount < ch1 || filePrdMap["jianshu"].BandCount < ch2)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider prd     = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);

            if (prd == null)
            {
                throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
            }
            IRasterPixelsVisitor <float> visitor = new RasterPixelsVisitor <float>(new ArgumentProvider(prd, null));
            IPixelFeatureMapper <Int16>  result  = new MemPixelFeatureMapper <Int16>("CHAZ", prd.Width * prd.Height, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);

            visitor.VisitPixel(new int[] { filePrdMap["beijianshu"].StartBand, filePrdMap["jianshu"].StartBand },
                               (idx, values) =>
            {
                result.Put(idx, (Int16)(values[0] - values[1]));
            }
                               );
            return(result);
        }
Exemple #17
0
        private IExtractResult VTIAlgorithm()
        {
            int NDVIBandCH        = (int)_curArguments.GetArg("NDVIBand");
            int NDVIBackBandMinCH = (int)_curArguments.GetArg("NDVIBackBandMin");
            int NDVIBackBandMaxCH = (int)_curArguments.GetArg("NDVIBackBandMax");

            int LSTBandCH        = (int)_curArguments.GetArg("LSTBand");
            int LSTBackBandMinCH = (int)_curArguments.GetArg("LSTBackBandMin");
            int LSTBackBandMaxCH = (int)_curArguments.GetArg("LSTBackBandMax");

            double NDVIZoom     = (float)_curArguments.GetArg("NDVIZoom");
            double NDVIBackZoom = (float)_curArguments.GetArg("NDVIBackZoom");

            double LSTZoom     = (float)_curArguments.GetArg("LSTZoom");
            double LSTBackZoom = (float)_curArguments.GetArg("LSTBackZoom");

            float ndviVaildMin = (float)_curArguments.GetArg("ndviVaildMin");
            float ndviVaildMax = (float)_curArguments.GetArg("ndviVaildMax");

            float lstVaildMin = (float)_curArguments.GetArg("lstVaildMin");
            float lstVaildMax = (float)_curArguments.GetArg("lstVaildMax");

            double VTIZoom  = (float)_curArguments.GetArg("VTIZoom");
            string errorStr = null;

            if (NDVIBandCH == -1 || NDVIBackBandMinCH == -1 || NDVIBackBandMaxCH == -1 || LSTBandCH == -1 || LSTBackBandMinCH == -1 || LSTBackBandMaxCH == -1 ||
                _curArguments.GetArg("NDVIFile") == null || _curArguments.GetArg("NDVIBackFile") == null ||
                _curArguments.GetArg("LSTFile") == null || _curArguments.GetArg("LSTBackFile") == null)
            {
                errorStr = "VTI生产所用文件或通道未设置完全,请检查!";
                return(null);
            }
            string[] ndviFileNames = GetStringArray("NDVIFile");
            string[] lstFileNames  = GetStringArray("LSTFile");


            string NDVIFile = ndviFileNames == null || ndviFileNames.Length == 1 ? _curArguments.GetArg("NDVIFile").ToString() : MAxValue(ndviFileNames, NDVIBandCH, (float)NDVIZoom);

            if (ndviFileNames != null && ndviFileNames.Length != 1)
            {
                NDVIBandCH = 1;
            }
            string NDVIBackFile = _curArguments.GetArg("NDVIBackFile").ToString();
            string LSTFile      = lstFileNames == null || lstFileNames.Length == 1 ? _curArguments.GetArg("LSTFile").ToString() : MAxValue(lstFileNames, LSTBandCH, (float)LSTZoom);

            if (lstFileNames != null && lstFileNames.Length != 1)
            {
                LSTBandCH = 1;
            }
            string LSTBackFile = _curArguments.GetArg("LSTBackFile").ToString();

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("NDVIFile", new FilePrdMap(NDVIFile, NDVIZoom, new VaildPra(ndviVaildMin, ndviVaildMax), new int[] { NDVIBandCH }));
            filePrdMap.Add("NDVIBackFile", new FilePrdMap(NDVIBackFile, NDVIBackZoom, new VaildPra(ndviVaildMin, ndviVaildMax), new int[] { NDVIBackBandMinCH, NDVIBackBandMaxCH }));
            filePrdMap.Add("LSTFile", new FilePrdMap(LSTFile, LSTZoom, new VaildPra(lstVaildMin, lstVaildMax), new int[] { LSTBandCH }));
            filePrdMap.Add("LSTBackFile", new FilePrdMap(LSTBackFile, LSTBackZoom, new VaildPra(lstVaildMin, lstVaildMax), new int[] { LSTBackBandMinCH, LSTBackBandMaxCH }));

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd     = null;

            try
            {
                vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
                if (vrd == null)
                {
                    throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
                }
                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                IPixelFeatureMapper <Int16> result    = new MemPixelFeatureMapper <Int16>("0VTI", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                float vci = 0f;
                float tci = 0f;
                rpVisitor.VisitPixel(new int[] { filePrdMap["NDVIFile"].StartBand,
                                                 filePrdMap["NDVIBackFile"].StartBand,
                                                 filePrdMap["NDVIBackFile"].StartBand + 1,
                                                 filePrdMap["LSTFile"].StartBand,
                                                 filePrdMap["LSTBackFile"].StartBand,
                                                 filePrdMap["LSTBackFile"].StartBand + 1 },
                                     (index, values) =>
                {
                    if (values[0] < filePrdMap["NDVIFile"].VaildValue.Min || values[0] > filePrdMap["NDVIFile"].VaildValue.Max ||
                        values[1] < filePrdMap["NDVIBackFile"].VaildValue.Min || values[1] > filePrdMap["NDVIBackFile"].VaildValue.Max ||
                        values[2] < filePrdMap["NDVIBackFile"].VaildValue.Min || values[2] > filePrdMap["NDVIBackFile"].VaildValue.Max ||
                        values[3] < filePrdMap["LSTFile"].VaildValue.Min || values[3] > filePrdMap["LSTFile"].VaildValue.Max ||
                        values[4] < filePrdMap["LSTBackFile"].VaildValue.Min || values[4] > filePrdMap["LSTBackFile"].VaildValue.Max ||
                        values[5] < filePrdMap["LSTBackFile"].VaildValue.Min || values[5] > filePrdMap["LSTBackFile"].VaildValue.Max)
                    {
                        result.Put(index, 0);
                    }
                    else
                    {
                        //计算VCI
                        vci = (values[0] - values[1]) / (values[2] - values[1]);
                        //计算TCI
                        tci = (values[3] - values[4]) / (values[5] - values[4]);
                        result.Put(index, (Int16)((0.5 * vci + 0.5 * tci) * VTIZoom));
                    }
                });
                return(result);
            }
            finally
            {
                if (vrd != null)
                {
                    vrd.Dispose();
                }
            }
        }
        public static bool DoElevationCorrections(TVDIUCArgs ucArgs, ref string error)
        {
            if (string.IsNullOrEmpty(ucArgs.LSTFile) || string.IsNullOrEmpty(ucArgs.DEMFile) || ucArgs.TVDIParas == null || ucArgs.TVDIParas.LstFile == null)
            {
                error = "陆表高温高程订正所需数据或参数设置不全.";
                return(false);
            }

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("LSTFile", new FilePrdMap(ucArgs.LSTFile, ucArgs.TVDIParas.LstFile.Zoom, new VaildPra(ucArgs.TVDIParas.LstFile.Min, ucArgs.TVDIParas.LstFile.Max), new int[] { ucArgs.TVDIParas.LstFile.Band }));
            filePrdMap.Add("DemFile", new FilePrdMap(ucArgs.DEMFile, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd     = null;

            IInterestedRaster <float> iir = null;

            try
            {
                vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
                if (vrd == null)
                {
                    throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
                }

                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                IPixelFeatureMapper <float> _result   = new MemPixelFeatureMapper <float>("0LEC", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                ArgumentItem ai = ucArgs.TVDIParas.LstFile;
                rpVisitor.VisitPixel(new int[] { filePrdMap["LSTFile"].StartBand,
                                                 filePrdMap["DemFile"].StartBand },
                                     (index, values) =>
                {
                    if (values[1] == -9999)
                    {
                        _result.Put(index, 9999);    //海洋
                    }
                    else if (values[1] == -9000)
                    {
                        _result.Put(index, 9000);    //非中国区域陆地
                    }
                    else if (values[1] >= 6000)
                    {
                        _result.Put(index, 0);     //6000之内的LST数据
                    }
                    else if (values[0] == ucArgs.TVDIParas.LstFile.Cloudy)
                    {
                        _result.Put(index, 9998);     //云区
                    }
                    else if (values[0] == 12)
                    {
                        _result.Put(index, 9997);    //无数据区域
                    }
                    else if (values[0] == 0)
                    {
                        _result.Put(index, 0);
                    }
                    else if (values[1] == 0)
                    {
                        _result.Put(index, 0);
                    }
                    else
                    {
                        _result.Put(index, (float)(Math.Round((values[0] - 273f + 0.006f * values[1]) * ai.Zoom, 0)));
                    }
                });
                iir = new InterestedRaster <float>(CreateRID(ucArgs.LSTFile), new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                iir.Put(_result);
                ucArgs.ECLstFile = iir.FileName;
                return(true);
            }
            finally
            {
                if (iir != null)
                {
                    iir.Dispose();
                }
                vrd.Dispose();
            }
        }