private IExtractResult CalcRVIAlgorithm2(string inputFile, int[] bandNos, float zoom, double[] bandZoom, float[] cloudyArgs, Int16 defCloudy, bool isFitterCloud, string aoiTemplate, Action <int, string> progressTracker)
        {
            bool isAppCloud;

            if (!bool.TryParse(_argumentProvider.GetArg("isAppCloud").ToString(), out isAppCloud))
            {
                PrintInfo("合并交互云参数设置不正确!");
                return(null);
            }
            RasterProcessModel <short, short> rfr = null;
            List <RasterMaper> fileIns            = new List <RasterMaper>();

            RasterMaper[]       fileOuts = null;
            IRasterDataProvider clmPrd   = null;

            try
            {
                //输入数据(LDF)
                IRasterDataProvider inRaster = RasterDataDriver.Open(inputFile) as IRasterDataProvider;
                if (inRaster == null)
                {
                    PrintInfo("读取栅格文件失败:" + inRaster);
                    return(null);
                }
                //输出数据(RVI)
                string            outFileName = GetFileName(new string[] { inRaster.fileName }, _subProductDef.ProductDef.Identify, _identify, ".dat", null);
                IRasterDataDriver dd          = RasterDataDriver.GetDriverByName("MEM") as IRasterDataDriver;
                string            mapInfo     = inRaster.CoordEnvelope.ToMapInfoString(new Size(inRaster.Width, inRaster.Height));
                string[]          opts        = new string[] {
                    "INTERLEAVE=BSQ",
                    "VERSION=MEM",
                    "WITHHDR=TRUE",
                    "SPATIALREF=" + inRaster.SpatialRef.ToProj4String(),
                    mapInfo
                };
                RasterDataProvider outRaster = dd.Create(outFileName, inRaster.Width, inRaster.Height, 1, enumDataType.Int16, opts) as RasterDataProvider;
                string             clmFile   = GetClmFile(inputFile);
                int cloudCH = GetCloudCHNO();
                //栅格数据映射
                fileIns.Add(new RasterMaper(inRaster, bandNos));
                if (isAppCloud)
                {
                    if (!string.IsNullOrEmpty(clmFile) && File.Exists(clmFile))
                    {
                        clmPrd = GeoDataDriver.Open(clmFile) as IRasterDataProvider;
                        if (clmPrd.BandCount < cloudCH)
                        {
                            PrintInfo("请选择正确的云数据通道进行计算.");
                            isAppCloud = false;
                        }
                        else
                        {
                            fileIns.Add(new RasterMaper(clmPrd, new int[] { cloudCH }));
                        }
                    }
                    else
                    {
                        isAppCloud = false;
                    }
                }

                RasterMaper fileOut = new RasterMaper(outRaster, new int[] { 1 });
                fileOuts = new RasterMaper[] { fileOut };

                rfr = new RasterProcessModel <short, short>(progressTracker);
                rfr.SetRaster(fileIns.ToArray(), fileOuts);
                rfr.SetTemplateAOI(aoiTemplate);
                rfr.RegisterCalcModel(new RasterCalcHandler <short, short>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData != null)
                    {
                        if (rvInVistor == null)
                        {
                            return;
                        }
                        short[] inBand0  = rvInVistor[0].RasterBandsData[0]; //第1个输入文件的第1个波段的各像素值
                        short[] inBand1  = rvInVistor[0].RasterBandsData[1]; //第1个输入文件的第2个波段的各像素值
                        short[] inBand12 = rvInVistor[1].RasterBandsData[0]; //第2个输入文件的第1个波段的各像素值
                        if (string.IsNullOrWhiteSpace(aoiTemplate))
                        {
                            for (int index = 0; index < inBand0.Length; index++)
                            {
                                if ((isAppCloud && inBand12[index] != 0) || (isFitterCloud && inBand0[index] / bandZoom[0] >= cloudyArgs[0] && inBand1[index] / inBand0[index] < cloudyArgs[1] && inBand1[index] / inBand0[index] >= cloudyArgs[2]))
                                {
                                    rvOutVistor[0].RasterBandsData[0][index] = defCloudy;
                                    continue;
                                }
                                //第1个输出文件的第1个波段存储RVI值
                                rvOutVistor[0].RasterBandsData[0][index] = (short)(inBand0[index] == 0 ? 0 : (((float)inBand1[index] / bandZoom[1]) / ((float)inBand0[index] / bandZoom[0]) * zoom));
                            }
                        }
                        else if (aoi != null && aoi.Length != 0)
                        {
                            int index;
                            for (int i = 0; i < aoi.Length; i++)
                            {
                                index = aoi[i];
                                if ((isAppCloud && inBand12[index] != 0) || (isFitterCloud && inBand0[index] / bandZoom[0] >= cloudyArgs[0] && inBand1[index] / inBand0[index] < cloudyArgs[1] && inBand1[index] / inBand0[index] >= cloudyArgs[2]))
                                {
                                    rvOutVistor[0].RasterBandsData[0][index] = defCloudy;
                                    continue;
                                }
                                //第1个输出文件的第1个波段存储RVI值
                                rvOutVistor[0].RasterBandsData[0][index] = (short)(inBand0[index] == 0 ? 0 : (((float)inBand1[index] / bandZoom[1]) / ((float)inBand0[index] / bandZoom[0]) * zoom));
                            }
                        }
                    }
                }));
                //执行
                rfr.Excute();
                FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                res.SetDispaly(false);
                return(res);
            }
            finally
            {
                if (fileIns != null)
                {
                    for (int i = 0; i < fileIns.Count; i++)
                    {
                        fileIns[i].Raster.Dispose();
                    }
                }
                if (fileOuts != null)
                {
                    for (int i = 0; i < fileOuts.Length; i++)
                    {
                        fileOuts[i].Raster.Dispose();
                    }
                }
                if (clmPrd != null)
                {
                    clmPrd.Dispose();
                }
            }
        }
Example #2
0
        /// <summary>
        /// 地理数据拼接:地理坐标,投影坐标
        /// 拼接输出ldf
        /// 支持按高度角数据拼接,高度角数据为后缀为".SolarZenith.ldf"的附加文件,值为扩大了100倍的short类型的高度角值。
        /// 本拼接程序会判断是否有高度角数据:“.SolarZenith.ldf”,如果有,则拼接时候会依据高度角的大小关系执行是否覆盖操作,如果没有,则按照有无数据执行拼接。
        /// </summary>
        /// <param name="rasterFiles"></param>
        /// <param name="outRasterFile"></param>
        /// <param name="geoHeader"></param>
        /// <param name="bandMaps"></param>
        /// <param name="progress"></param>
        public void Mosaic(string[] rasterFiles, string outRasterFile, GeoInfo geoHeader, string[] bandMaps, Action <int, string> progress)
        {
            int[] bandMap = null;
            if (!GetBandMap(bandMaps, out bandMap))
            {
                if (progress != null)
                {
                    progress(0, "输入参数错误,参数[要拼接的波段]不正确");
                }
                return;
            }
            if (bandMap == null || bandMap.Length == 0)
            {
                if (progress != null)
                {
                    progress(0, "输入参数错误,[要拼接的波段]为空或不正确");
                }
                return;
            }
            int bandCount = bandMap.Length;
            ISpatialReference spatialRef = TryFindSpatialRef(rasterFiles);

            using (IRasterDataProvider outraster = CreateMosaicRaster(outRasterFile, geoHeader, bandCount, spatialRef))
            {
                string filename                       = null;
                IRasterDataProvider raster            = null;
                string solarZenithFilename            = null;
                IRasterDataProvider solarZenithRaster = null;

                RasterMaper         outSolarZenithMap   = null;// new RasterMaper(solarZenithRaster, new int[] { 1 });
                string              outSolarZenithFile  = Path.ChangeExtension(outRasterFile, ".SolarZenith.ldf");
                IRasterDataProvider outSolarZenithRster = null;
                try
                {
                    for (int f = 0; f < rasterFiles.Length; f++)
                    {
                        filename            = rasterFiles[f];
                        solarZenithFilename = Path.ChangeExtension(filename, ".SolarZenith.ldf");
                        if (progress != null)
                        {
                            progress((int)((f + 1) * 100f / rasterFiles.Length), string.Format("{0}/{1}", f + 1, rasterFiles.Length));
                        }
                        try
                        {
                            raster = GeoDataDriver.Open(filename) as IRasterDataProvider;
                            if (raster == null)
                            {
                                continue;
                            }
                            //if (raster is ILdfDataProvider)
                            //{
                            //    Ldf1Header header = (raster as ILdfDataProvider).Header as Ldf1Header;
                            //    if (!header.IsDay)
                            //    {
                            //        Console.WriteLine("跳过晚上数据" + Path.GetFileName(filename));
                            //        continue;
                            //    }
                            //}
                            if (File.Exists(outSolarZenithFile))
                            {
                                outSolarZenithRster = GeoDataDriver.Open(outSolarZenithFile, enumDataProviderAccess.Update, null) as IRasterDataProvider;
                                outSolarZenithMap   = new RasterMaper(outSolarZenithRster, new int[] { 1 });
                            }

                            RasterMaper rmSz = null;
                            if (File.Exists(solarZenithFilename))
                            {
                                solarZenithRaster = GeoDataDriver.Open(solarZenithFilename) as IRasterDataProvider;
                                rmSz = new RasterMaper(solarZenithRaster, new int[] { 1 });
                            }
                            RasterMaper rmin  = new RasterMaper(raster, bandMap);
                            RasterMaper rmout = new RasterMaper(outraster, bandMap);
                            RasterProcessModel <short, short> rp = new RasterProcessModel <short, short>();
                            RasterMaper[] rmIns, rmOuts;
                            if (rmSz != null)
                            {
                                rmIns = new RasterMaper[] { rmin, rmSz }
                            }
                            ;
                            else
                            {
                                rmIns = new RasterMaper[] { rmin }
                            };
                            if (outSolarZenithMap != null)
                            {
                                rmOuts = new RasterMaper[] { rmout, outSolarZenithMap }
                            }
                            ;
                            else
                            {
                                rmOuts = new RasterMaper[] { rmout }
                            };
                            rp.SetRaster(rmIns, rmOuts);
                            rp.RegisterCalcModel(new RasterCalcHandlerFun <short, short>((rasterVistor, target, map) =>
                            {
                                if (rasterVistor[0] == null || rasterVistor[0].RasterBandsData.Length == 0)
                                {
                                    return(false);
                                }
                                if (target[0] == null || target[0].RasterBandsData[0].Length == 0)
                                {
                                    return(false);
                                }
                                if (rasterVistor[0].RasterBandsData[0] == null)
                                {
                                    return(false);
                                }
                                //目标角度数据存在,源角度数据不存在,不做拼接
                                if (target.Length != 1 && rasterVistor.Length == 1)
                                {
                                    return(false);
                                }
                                bool isUpdate = false;
                                //不使用天顶角数据,补数据
                                if (target.Length == 1 || rasterVistor.Length == 1)
                                {
                                    for (int i = 0; i < target[0].RasterBandsData[0].Length; i++)
                                    {
                                        if (rasterVistor[0].RasterBandsData[0][i] == 0)//空值
                                        {
                                            continue;
                                        }
                                        if (target[0].RasterBandsData[0][i] == 0)
                                        {
                                            isUpdate = true;
                                            for (int b = 0; b < bandCount; b++)
                                            {
                                                target[0].RasterBandsData[b][i] = rasterVistor[0].RasterBandsData[b][i];
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < target[0].RasterBandsData[0].Length; i++)
                                    {
                                        if (rasterVistor[0].RasterBandsData[0][i] == 0)//空值
                                        {
                                            continue;
                                        }

                                        /*
                                         * 太阳高度表示昼夜状态
                                         * 在晨昏线上的各地太阳高度为0 °,表示正经历昼夜更替;
                                         * 在昼半球上的各地太阳高度大于0°,表示白昼;
                                         * 在夜半球上的各地太阳高度小于0°,表示黑夜。
                                         * 日出、日落时,太阳高度为0
                                         * 即:
                                         * 0°附近在日落或日出
                                         * -90°和0°之间在晚上
                                         * 上午太阳高度逐渐增大,最大时为太阳上中天,即是正午,午后太阳高度又逐渐缩小。
                                         */
                                        //(高度角 = 90 - 天顶角)

                                        //高度角有效范围:
                                        //这里读取的是SolarZenith太阳天顶,有效范围0-180。
                                        //天顶角0-90为白天,小值为接近中午
                                        if (rasterVistor.Length == 1 || rasterVistor[1] == null || rasterVistor[1].RasterBandsData[0] == null ||
                                            target.Length == 1 || target[1] == null)
                                        {
                                            if (target[0].RasterBandsData[0][i] == 0)//如果没有角度数据,则采取补数据的方式(即不覆盖已有数据)
                                            {
                                                isUpdate = true;
                                                for (int b = 0; b < bandCount; b++)//拼接所有通道数据
                                                {
                                                    target[0].RasterBandsData[b][i] = rasterVistor[0].RasterBandsData[b][i];
                                                }
                                            }
                                        }
                                        else if (rasterVistor[1].RasterBandsData[0][i] > 9000 || rasterVistor[1].RasterBandsData[0][i] < 0)//原高度角为夜晚或者不合理
                                        {
                                            continue;
                                        }
                                        else if (target[1].RasterBandsData[0][i] == 0)
                                        {
                                            isUpdate = true;
                                            for (int b = 0; b < bandCount; b++)
                                            {
                                                target[0].RasterBandsData[b][i] = rasterVistor[0].RasterBandsData[b][i];
                                            }
                                            //更新目标高度角数据
                                            target[1].RasterBandsData[0][i] = rasterVistor[1].RasterBandsData[0][i];
                                        }
                                        else if (rasterVistor[1].RasterBandsData[0][i] < target[1].RasterBandsData[0][i])//取高度角小的
                                        {
                                            isUpdate = true;
                                            for (int b = 0; b < bandCount; b++)
                                            {
                                                target[0].RasterBandsData[b][i] = rasterVistor[0].RasterBandsData[b][i];
                                            }
                                            //更新目标高度角数据
                                            target[1].RasterBandsData[0][i] = rasterVistor[1].RasterBandsData[0][i];
                                        }
                                    }
                                }
                                if (isUpdate)
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                                                                                         ));
                            int rowCount = rp.CalcRowCount();
                            rp.Excute(0, rowCount);
                        }
                        finally
                        {
                            if (raster != null)
                            {
                                raster.Dispose();
                                raster = null;
                            }
                            if (outSolarZenithRster != null)
                            {
                                outSolarZenithRster.Dispose();
                                outSolarZenithRster = null;
                            }
                        }
                    }
                }
                finally
                {
                    if (outSolarZenithRster != null)
                    {
                        outSolarZenithRster.Dispose();
                        outSolarZenithRster = null;
                    }
                }
            }
        }
Example #3
0
        private IExtractResult TCIAlgorithm(Action <int, string> progressTracker)
        {
            int   LSTBandCH        = (int)_argumentProvider.GetArg("LSTBand");
            int   LSTBackBandMinCH = (int)_argumentProvider.GetArg("LSTBackBandMin");
            int   LSTBackBandMaxCH = (int)_argumentProvider.GetArg("LSTBackBandMax");
            float LSTZoom          = (float)_argumentProvider.GetArg("LSTZoom");
            float LSTBackZoom      = (float)_argumentProvider.GetArg("LSTBackZoom");
            float lstVaildMin      = (float)_argumentProvider.GetArg("lstVaildMin");
            float lstVaildMax      = (float)_argumentProvider.GetArg("lstVaildMax");

            double VTIZoom     = (float)_argumentProvider.GetArg("VTIZoom");
            bool   outVCITCI   = true;
            string tciIdentify = (string)_argumentProvider.GetArg("tciIdentify");

            if (string.IsNullOrWhiteSpace(tciIdentify))
            {
                tciIdentify = "0TCIA";
            }

            if (LSTBandCH == -1 || LSTBackBandMinCH == -1 || LSTBackBandMaxCH == -1 || _argumentProvider.GetArg("LSTFile") == null || _argumentProvider.GetArg("LSTBackFile") == null)
            {
                PrintInfo("VTI生产所用文件或通道未设置完全,请检查!");
                return(null);
            }
            //假如是一个元素的数组 此处下一行代码将报错
            string[] lstFileNames = GetStringArray("LSTFile");
            if (lstFileNames == null || lstFileNames.Length == 0)
            {
                return(null);
            }
            string LSTFile = lstFileNames.Length == 1 ? lstFileNames[0] : MAxValue(progressTracker, lstFileNames, LSTBandCH, (float)LSTZoom);

            //此处原代码if判断与上面三目运算重复
            if (!File.Exists(LSTFile))
            {
                PrintInfo("LST数据不存在");
                return(null);
            }
            if (lstFileNames != null && lstFileNames.Length != 1)
            {
                LSTBandCH = 1;
            }
            string LSTBackFile = _argumentProvider.GetArg("LSTBackFile").ToString();

            //输入文件准备
            List <RasterMaper> rasterInputMaps = new List <RasterMaper>();

            IRasterDataProvider ndviMaxPrd = null;
            IRasterDataProvider ndviPrd    = null;
            IRasterDataProvider lstMaxPrd  = null;
            IRasterDataProvider lstPrd     = null;

            try
            {
                lstMaxPrd = RasterDataDriver.Open(LSTFile) as IRasterDataProvider;
                if (lstMaxPrd.BandCount < LSTBandCH)
                {
                    PrintInfo("请选择正确的数据进行时序植被温度干旱指数计算。");
                    return(null);
                }
                RasterMaper lstRM = new RasterMaper(lstMaxPrd, new int[] { LSTBandCH });
                rasterInputMaps.Add(lstRM);

                lstPrd = RasterDataDriver.Open(LSTBackFile) as IRasterDataProvider;
                if (lstPrd.BandCount < LSTBackBandMaxCH || lstPrd.BandCount < LSTBackBandMinCH)
                {
                    PrintInfo("请选择正确的数据进行时序植被温度干旱指数计算。");
                    return(null);
                }
                RasterMaper lstRm = new RasterMaper(lstPrd, new int[] { LSTBackBandMinCH, LSTBackBandMaxCH });
                rasterInputMaps.Add(lstRm);

                //输出文件准备(作为输入栅格并集处理)
                //string[] inFileArray = GetInFileList(ndviFileNames,lstFileNames);
                string[] inFileArray = lstFileNames;
                string   outTci      = null;
                if (outVCITCI)
                {
                    outTci = GetFileName(inFileArray, _subProductDef.ProductDef.Identify, tciIdentify, ".dat", null);
                }

                IRasterDataProvider outTciRaster = null;
                try
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rasterInputMaps.ToArray();
                    RasterMaper[] fileOuts = null;
                    if (outVCITCI)
                    {
                        outTciRaster = CreateOutRaster(outTci, rasterInputMaps.ToArray());
                        fileOuts     = new RasterMaper[] { new RasterMaper(outTciRaster, new int[] { 1 }) };
                    }


                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    float   tci    = 0f;
                    float[] values = null;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        //判断输入的lst及背景库文件01波段数据是否为空
                        if (rvInVistor[0].RasterBandsData[0] == null || rvInVistor[1].RasterBandsData[0] == null ||
                            rvInVistor[1].RasterBandsData[1] == null)
                        {
                            return;
                        }
                        int dataLength     = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;//tci
                        Int16[] sumData    = new Int16[dataLength];
                        ushort[] countData = new ushort[dataLength];
                        for (int index = 0; index < dataLength; index++)
                        {
                            values = new float[3];

                            values[0] = (float)rvInVistor[0].RasterBandsData[0][index] / LSTZoom;
                            values[1] = (float)rvInVistor[1].RasterBandsData[0][index] / LSTBackZoom;
                            values[2] = (float)rvInVistor[1].RasterBandsData[1][index] / LSTBackZoom;
                            //lst以及背景库数据值如果不在有效范围内
                            if (values[0] < lstVaildMin || values[0] > lstVaildMax ||
                                values[1] < lstVaildMin || values[1] > lstVaildMax ||
                                values[2] < lstVaildMin || values[2] > lstVaildMax)
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = 0;
                            }
                            else
                            {
                                //计算TCI
                                tci = (values[0] - values[1]) / (values[2] - values[1]);

                                if (outVCITCI)
                                {
                                    //这个就是输出TCI结果可以简化代码
                                    rvOutVistor[0].RasterBandsData[0][index] = (Int16)(tci * VTIZoom);
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                }
                finally
                {
                    if (outTciRaster != null)
                    {
                        outTciRaster.Dispose();
                    }
                }
                //这里保持跟其他自动产品一样 在外面进行输出路径文件移动
                FileExtractResult resTci = new FileExtractResult(tciIdentify, outTci, true);
                resTci.SetDispaly(false);
                return(resTci);
            }
            finally
            {
                if (ndviMaxPrd != null)
                {
                    ndviMaxPrd.Dispose();
                }
                if (ndviPrd != null)
                {
                    ndviPrd.Dispose();
                }
                if (lstMaxPrd != null)
                {
                    lstMaxPrd.Dispose();
                }
            }
        }
        //生成NDVI背景库算法
        private IExtractResult BackNDVIFileAlg(Action <int, string> progressTracker)
        {
            //此处已从theme中读取配置文件
            ///参数提取
            int NDVIBandCH = (int)_argumentProvider.GetArg("NDVIBand");
            //NDVI有效值范围
            Int16 ndviVaildMin = Convert.ToInt16(_argumentProvider.GetArg("VaildRegionMin"));//-------如果有效值是范围是放大之前的范围(确定)这样是否能取到?
            Int16 ndviVaildMax = Convert.ToInt16(_argumentProvider.GetArg("VaildRegionMax"));
            //NDVI数据放大倍数
            double NDVIZoom = Convert.ToDouble(_argumentProvider.GetArg("NDVIZoom"));
            //NDVI生成的背景库放大倍数
            double NDVIBackZoom = Convert.ToDouble(_argumentProvider.GetArg("OutNDVIBackZoom"));

            //NDVI输入文件
            string[]     ndviFileNames = GetStringArray("NDVIFile");
            Int16[]      cloudyValues  = GetUnValueValues("CloudyValue");
            Int16[]      waterValues   = GetUnValueValues("WaterValue");
            List <Int16> specialValues = new List <short>();

            specialValues.AddRange(cloudyValues);
            specialValues.AddRange(waterValues);
            Int16 defCloudy = Convert.ToInt16(_argumentProvider.GetArg("defCloudy"));

            //NDVI输出文件--根据输入文件信息输出
            string             outndvibackfile = GetFileName(ndviFileNames, _subProductDef.ProductDef.Identify, _identify, ".ldf", null); //默认位置输出
            List <RasterMaper> rasterInputMaps = new List <RasterMaper>();                                                                //从配置文件中读取需要待合成数据

            foreach (string itemfile in ndviFileNames)
            {
                IRasterDataProvider inraster = RasterDataDriver.Open(itemfile) as IRasterDataProvider;
                rasterInputMaps.Add(new RasterMaper(inraster, new int[] { NDVIBandCH }));
            }
            IRasterDataProvider outNDVIbackRaster = null;

            try
            {
                outNDVIbackRaster = CreateOutLDFRaster(outndvibackfile, rasterInputMaps.ToArray(), 7);//固定七个波段
                //栅格数据映射
                RasterMaper[] fileIns = rasterInputMaps.ToArray();
                RasterMaper[] fileOuts;

                fileOuts = new RasterMaper[] { new RasterMaper(outNDVIbackRaster, new int[] { 1, 2, 3, 4, 5, 6, 7 }) };//输出为固定7个波段数据
                //创建处理模型
                RasterProcessModel <Int16, Int16> rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                rfr.SetRaster(fileIns, fileOuts);
                rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                {
                    int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;//输出格点
                    for (int index = 0; index < dataLength; index++)
                    {
                        try
                        {
                            List <Int16> listtemp = new List <Int16>();
                            List <Int16> listavg  = new List <short>();
                            //初始化各波段原始数据
                            Int16 maxNDVI      = Int16.MinValue;
                            Int16 minNDVI      = Int16.MinValue;
                            Int16 secmaxNDVI   = Int16.MinValue;
                            Int16 secminNDVI   = Int16.MinValue;
                            Int16 maxvableNDVI = Int16.MinValue;
                            Int16 minvableNDVI = Int16.MinValue;
                            double averageNDVI = Int16.MinValue;
                            for (int fileindex = 0; fileindex < rvInVistor.Length; fileindex++)
                            {
                                listtemp.Add(rvInVistor[fileindex].RasterBandsData[0][index]);
                                listavg.Add(rvInVistor[fileindex].RasterBandsData[0][index]);
                            }
                            //调整排序
                            listtemp.Sort();                             //按照从小到大升序排列
                            listtemp = listtemp.Distinct().ToList();     //去重
                            if (listtemp.Count == 1 && listtemp[0] == 0) //0
                            {
                                maxNDVI      = 0;
                                minNDVI      = 0;
                                secmaxNDVI   = 0;
                                secminNDVI   = 0;
                                maxvableNDVI = 0;
                                minvableNDVI = 0;
                                averageNDVI  = 0;
                            }
                            // 云水判识
                            int cloudcount = listtemp.Count(num => cloudyValues.Contains(num)); //获取该集合中标识云的元素个数
                            int watercount = listtemp.Count(num => waterValues.Contains(num));  //获取该集合中标识水的元素个数

                            if (cloudcount == listtemp.Count)                                   //全是云值
                            {
                                maxNDVI      = defCloudy;
                                minNDVI      = defCloudy;
                                secmaxNDVI   = defCloudy;
                                secminNDVI   = defCloudy;
                                maxvableNDVI = defCloudy;
                                minvableNDVI = defCloudy;
                                averageNDVI  = defCloudy;
                            }
                            else if (watercount == listtemp.Count)//全是水值
                            {
                                if (waterValues.Length > 0)
                                {
                                }
                                maxNDVI      = waterValues[0];
                                minNDVI      = waterValues[0];
                                secmaxNDVI   = waterValues[0];
                                secminNDVI   = waterValues[0];
                                maxvableNDVI = waterValues[0];
                                minvableNDVI = waterValues[0];
                                averageNDVI  = waterValues[0];
                            }
                            else if (cloudcount + watercount == listtemp.Count) //云+水 初始化默认值不用修改
                            {
                                //填充云
                                maxNDVI      = defCloudy;
                                minNDVI      = defCloudy;
                                secmaxNDVI   = defCloudy;
                                secminNDVI   = defCloudy;
                                maxvableNDVI = defCloudy;
                                minvableNDVI = defCloudy;
                                averageNDVI  = defCloudy;
                            }
                            else //正常条件数据下
                            {
                                //排除掉云水值

                                listtemp   = listtemp.Where(num => !specialValues.Contains(num)).ToList();
                                maxNDVI    = listtemp[listtemp.Count - 1];                                                     // 最大值
                                minNDVI    = listtemp[0];                                                                      //最小值
                                secmaxNDVI = listtemp.Count > 1 ? listtemp[listtemp.Count - 2] : listtemp[listtemp.Count - 1]; //次大值
                                secminNDVI = listtemp.Count > 1 ? listtemp[1] : listtemp[0];                                   //次小值
                                //去除云值水值 限定有效区间 取平均值
                                averageNDVI = listavg.Where(num => !specialValues.Contains(num))
                                              .Where(num => (num >= ndviVaildMin * NDVIZoom && num <= ndviVaildMax * NDVIZoom))
                                              .Average(num => (int)num);      //平均值

                                //排除掉有效区间之外的数据
                                listtemp     = listtemp.Where(num => (num >= ndviVaildMin * NDVIZoom && num <= ndviVaildMax * NDVIZoom)).ToList(); //实际值比较
                                maxvableNDVI = listtemp.Count > 0 ? listtemp[listtemp.Count - 1] : Int16.MinValue;                                 //理论最大值
                                minvableNDVI = listtemp.Count > 0 ? listtemp[0] : Int16.MinValue;                                                  //理论最小值
                            }
                            //给输出Raster填值,此处为固定七个波段
                            //最大值波段
                            rvOutVistor[0].RasterBandsData[0][index] = (Int16)(maxNDVI * NDVIBackZoom / NDVIZoom);
                            //最小值波段
                            rvOutVistor[0].RasterBandsData[1][index] = (Int16)(minNDVI * NDVIBackZoom / NDVIZoom);
                            //次大值波段
                            rvOutVistor[0].RasterBandsData[2][index] = (Int16)(secmaxNDVI * NDVIBackZoom / NDVIZoom);
                            //次小值波段
                            rvOutVistor[0].RasterBandsData[3][index] = (Int16)(secminNDVI * NDVIBackZoom / NDVIZoom);
                            //理论最大值波段
                            rvOutVistor[0].RasterBandsData[4][index] = (Int16)(maxvableNDVI * NDVIBackZoom / NDVIZoom);
                            //理论最小值波段
                            rvOutVistor[0].RasterBandsData[5][index] = (Int16)(minvableNDVI * NDVIBackZoom / NDVIZoom);
                            //平均值波段
                            rvOutVistor[0].RasterBandsData[6][index] = (Int16)(averageNDVI * NDVIBackZoom / NDVIZoom);
                        }
                        catch (Exception ex)
                        {
                            string err    = ex.StackTrace;
                            string errmsg = err;
                        }
                    }
                }));
                rfr.Excute();
                //输出到界面
                FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outndvibackfile, true);
                res.SetDispaly(false);
                return(res);
            }
            catch (Exception ex)
            {
                PrintInfo("NDVI背景库生产出错" + ex.StackTrace);
                return(null);
            }
            finally
            {
                if (outNDVIbackRaster != null)
                {
                    outNDVIbackRaster.Dispose();
                }
            }
        }
Example #5
0
        //计算雪水当量体积
        private IFileExtractResult ComputeSnowSWEVOL(string swefilename)
        {
            List <RasterMaper>  rms               = null;
            IRasterDataProvider outRaster         = null;
            RasterProcessModel <float, float> rfr = null;

            try
            {
                rms = new List <RasterMaper>();
                IRasterDataProvider inRaster1 = GeoDataDriver.Open(swefilename) as IRasterDataProvider;
                //计算文件中每个像元的面积
                int   width  = inRaster1.Width;
                float maxLat = (float)inRaster1.CoordEnvelope.MaxY;
                float res    = inRaster1.ResolutionX;
                int   row    = inRaster1.Height;

                RasterMaper fileIn1 = new RasterMaper(inRaster1, new int[] { 1 });
                rms.Add(fileIn1);

                string sweVolFileName = GetFileName(new string[] { swefilename }, _subProductDef.ProductDef.Identify, "SVOL", ".dat", null);
                outRaster = CreateOutRaster(sweVolFileName, enumDataType.Float, rms.ToArray(), inRaster1.ResolutionX);
                RasterMaper   fileOut  = new RasterMaper(outRaster, new int[] { 1 });
                RasterMaper[] fileIns  = rms.ToArray();
                RasterMaper[] fileOuts = new RasterMaper[] { fileOut };
                rfr = new RasterProcessModel <float, float>();
                rfr.SetRaster(fileIns, fileOuts);
                rfr.RegisterCalcModel(new RasterCalcHandler <float, float>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData[0] != null)
                    {
                        int dataLength    = rvInVistor[0].SizeY * rvInVistor[0].SizeX;
                        float[] swetmpVol = new float[dataLength];
                        for (int i = 0; i < dataLength; i++)
                        {
                            row        = (int)(i / rvInVistor[0].SizeX) + 1;
                            float area = ComputePixelArea(row, maxLat, res);
                            //面积由平方公里转换为平方米,雪水当量mm转换为m
                            //swetmpVol[i] = rvInVistor[0].RasterBandsData[0][i] * area * 1000000.0f * 0.001f;
                            if (rvInVistor[0].RasterBandsData[0][i] == -999.0f || rvInVistor[0].RasterBandsData[0][i] == 0.003f)
                            {
                                swetmpVol[i] = 0.0f;
                            }
                            else
                            {
                                swetmpVol[i] = rvInVistor[0].RasterBandsData[0][i] * area * 1000.0f;
                            }
                            rvOutVistor[0].RasterBandsData[0][i] = swetmpVol[i];
                        }
                    }
                }));
                rfr.Excute();
                IFileExtractResult res1 = new FileExtractResult(_subProductDef.Identify, sweVolFileName, true);
                res1.SetDispaly(false);
                return(res1);
            }
            finally
            {
                if (outRaster != null)
                {
                    outRaster.Dispose();
                }
                if (rms != null && rms.Count > 0)
                {
                    foreach (RasterMaper rm in rms)
                    {
                        if (rm.Raster != null)
                        {
                            rm.Raster.Dispose();
                        }
                    }
                }
            }
        }
Example #6
0
        private string MAxValue(Action <int, string> progressTracker, string[] fileNames, int bandNo, float zoom)
        {
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }

            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    IRasterDataProvider inRaster = RasterDataDriver.Open(fileNames[i]) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNo)
                    {
                        PrintInfo("请选择正确的数据进行最大值合成。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { bandNo });
                    rms.Add(rm);
                }
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri = new RasterIdentify(fileNames);
                ri.GenerateDateTime = DateTime.Now;
                string outFileName            = MifEnvironment.GetFullFileName(ri.ToWksFileName(".dat"));
                IRasterDataProvider outRaster = null;
                try
                {
                    outRaster = CreateOutRaster(outFileName, rms.ToArray());
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength  = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] maxData = new Int16[dataLength];
                        foreach (RasterVirtualVistor <Int16> rv in rvInVistor)
                        {
                            if (rv.RasterBandsData == null)
                            {
                                continue;
                            }
                            Int16[] dt = rv.RasterBandsData[0];
                            if (dt != null)
                            {
                                for (int index = 0; index < dataLength; index++)
                                {
                                    if (dt[index] > maxData[index])
                                    {
                                        maxData[index] = dt[index];
                                        rvOutVistor[0].RasterBandsData[0][index] = maxData[index];
                                    }
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    return(outFileName);
                }
                finally
                {
                    outRaster.Dispose();
                    outRaster = null;
                }
            }
            finally
            {
                if (rms.Count != 0)
                {
                    foreach (RasterMaper rm in rms)
                    {
                        if (rm.Raster != null)
                        {
                            rm.Raster.Dispose();
                        }
                    }
                }
            }
        }
Example #7
0
        public bool IsSetRange(ISmartSession session, string[] latlon, out double[] geoRange)
        {
            geoRange = new double[4];
            if (latlon == null || latlon.Length != 4)
            {
                return(false);
            }

            double num;

            for (int i = 0; i < latlon.Length; i++)
            {
                if (double.TryParse(latlon[i], out num))
                {
                    geoRange[i] = num;
                }
                else
                {
                    return(false);
                }
            }
            if (!_isMCSI)
            {
                string[] fnames = _argumentProvider.GetArg("SelectedPrimaryFiles") as string[];
                if (fnames == null || fnames.Length == 0)
                {
                    return(false);
                }
                IRasterDataProvider dataPrd = null;
                try
                {
                    dataPrd = GeoDataDriver.Open(fnames[0]) as IRasterDataProvider;
                    if (dataPrd.CoordEnvelope.MinX <= geoRange[0] && dataPrd.CoordEnvelope.MaxX >= geoRange[1] &&
                        dataPrd.CoordEnvelope.MinY <= geoRange[2] && dataPrd.CoordEnvelope.MaxY >= geoRange[3])
                    {
                        return(true);
                    }
                    return(false);
                }
                catch
                {
                    return(false);
                }
                finally
                {
                    if (dataPrd != null)
                    {
                        dataPrd.Dispose();
                    }
                }
            }
            else
            {
                if (session == null)
                {
                    return(false);
                }
                ICanvasViewer viewer = session.SmartWindowManager.ActiveCanvasViewer;
                if (viewer == null)
                {
                    return(false);
                }
                ICanvas canvas = viewer.Canvas;
                if (canvas == null)
                {
                    return(false);
                }
                IRasterDrawing drawing = canvas.PrimaryDrawObject as IRasterDrawing;
                if (drawing == null)
                {
                    return(false);
                }
                if (drawing.DataProvider == null)
                {
                    return(false);
                }
                IRasterDataProvider prd = drawing.DataProviderCopy;
                if (prd.CoordEnvelope.MinX <= geoRange[0] && prd.CoordEnvelope.MaxX >= geoRange[1] &&
                    prd.CoordEnvelope.MinY <= geoRange[2] && prd.CoordEnvelope.MaxY >= geoRange[3])
                {
                    return(true);
                }
                return(false);
            }
        }
Example #8
0
        private IExtractResult VTIAlgorithm(Action <int, string> progressTracker)
        {
            int NDVIBandCH        = (int)_argumentProvider.GetArg("NDVIBand");
            int NDVIBackBandMinCH = (int)_argumentProvider.GetArg("NDVIBackBandMin");
            int NDVIBackBandMaxCH = (int)_argumentProvider.GetArg("NDVIBackBandMax");

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

            float NDVIZoom     = (float)_argumentProvider.GetArg("NDVIZoom");
            float NDVIBackZoom = (float)_argumentProvider.GetArg("NDVIBackZoom");

            float LSTZoom     = (float)_argumentProvider.GetArg("LSTZoom");
            float LSTBackZoom = (float)_argumentProvider.GetArg("LSTBackZoom");

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

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

            double VTIZoom     = (float)_argumentProvider.GetArg("VTIZoom");
            bool   outVCITCI   = (bool)_argumentProvider.GetArg("outVCITCI");
            string vciIdentify = (string)_argumentProvider.GetArg("vciIdentify");
            string tciIdentify = (string)_argumentProvider.GetArg("tciIdentify");

            if (string.IsNullOrWhiteSpace(vciIdentify))
            {
                vciIdentify = "0VCI";
            }
            if (string.IsNullOrWhiteSpace(tciIdentify))
            {
                tciIdentify = "0TCI";
            }

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

            if (ndviFileNames == null || ndviFileNames.Length == 0)
            {
                NDVIFile = _argumentProvider.GetArg("NDVIFile").ToString();
            }
            else if (ndviFileNames.Length == 1)
            {
                NDVIFile = ndviFileNames[0];
            }
            else
            {
                NDVIFile = MAxValue(progressTracker, ndviFileNames, NDVIBandCH, (float)NDVIZoom);
            }
            if (!File.Exists(NDVIFile))
            {
                PrintInfo("NDVI数据不存在");
                return(null);
            }
            if (ndviFileNames != null && ndviFileNames.Length != 1)
            {
                NDVIBandCH = 1;
            }
            string NDVIBackFile = _argumentProvider.GetArg("NDVIBackFile").ToString();
            string LSTFile      = lstFileNames == null || lstFileNames.Length == 1 ? _argumentProvider.GetArg("LSTFile").ToString() : MAxValue(progressTracker, lstFileNames, LSTBandCH, (float)LSTZoom);

            //if (lstFileNames == null || lstFileNames.Length == 0)
            //{
            //    LSTFile = _argumentProvider.GetArg("LSTFile").ToString();
            //}
            //else if (lstFileNames.Length == 1)
            //{
            //    LSTFile = lstFileNames[0];
            //}
            //else
            //{
            //    LSTFile = MAxValue(progressTracker, lstFileNames, LSTBandCH, (float)LSTZoom);
            //}
            if (!File.Exists(LSTFile))
            {
                PrintInfo("LST数据不存在");
                return(null);
            }
            if (lstFileNames != null && lstFileNames.Length != 1)
            {
                LSTBandCH = 1;
            }
            string LSTBackFile = _argumentProvider.GetArg("LSTBackFile").ToString();

            //输入文件准备
            List <RasterMaper> rasterInputMaps = new List <RasterMaper>();

            IRasterDataProvider ndviMaxPrd = null;
            IRasterDataProvider ndviPrd    = null;
            IRasterDataProvider lstMaxPrd  = null;

            try
            {
                ndviMaxPrd = RasterDataDriver.Open(NDVIFile) as IRasterDataProvider;
                if (ndviMaxPrd.BandCount < NDVIBandCH)
                {
                    PrintInfo("请选择正确的数据进行时序植被温度干旱指数计算。");
                    return(null);
                }
                RasterMaper rm = new RasterMaper(ndviMaxPrd, new int[] { NDVIBandCH });
                rasterInputMaps.Add(rm);

                ndviPrd = RasterDataDriver.Open(NDVIBackFile) as IRasterDataProvider;
                if (ndviPrd.BandCount < NDVIBackBandMaxCH || ndviPrd.BandCount < NDVIBackBandMinCH)
                {
                    PrintInfo("请选择正确的数据进行时序植被温度干旱指数计算。");
                    return(null);
                }
                RasterMaper rmNdvi = new RasterMaper(ndviPrd, new int[] { NDVIBackBandMinCH, NDVIBackBandMaxCH });
                rasterInputMaps.Add(rmNdvi);

                lstMaxPrd = RasterDataDriver.Open(LSTFile) as IRasterDataProvider;
                if (lstMaxPrd.BandCount < LSTBandCH)
                {
                    PrintInfo("请选择正确的数据进行时序植被温度干旱指数计算。");
                    return(null);
                }
                RasterMaper lstRM = new RasterMaper(lstMaxPrd, new int[] { LSTBandCH });
                rasterInputMaps.Add(lstRM);

                IRasterDataProvider lstPrd = RasterDataDriver.Open(LSTBackFile) as IRasterDataProvider;
                if (lstPrd.BandCount < LSTBackBandMaxCH || lstPrd.BandCount < LSTBackBandMinCH)
                {
                    PrintInfo("请选择正确的数据进行时序植被温度干旱指数计算。");
                    return(null);
                }
                RasterMaper lstRm = new RasterMaper(lstPrd, new int[] { LSTBackBandMinCH, LSTBackBandMaxCH });
                rasterInputMaps.Add(lstRm);

                //输出文件准备(作为输入栅格并集处理)
                string[] inFileArray = GetInFileList(ndviFileNames, lstFileNames);
                string   outFileName = GetFileName(inFileArray, _subProductDef.ProductDef.Identify, _identify, ".dat", null);
                string   outVci = null, outTci = null;
                if (outVCITCI)
                {
                    outVci = GetFileName(inFileArray, _subProductDef.ProductDef.Identify, vciIdentify, ".dat", null);
                    outTci = GetFileName(inFileArray, _subProductDef.ProductDef.Identify, tciIdentify, ".dat", null);
                }
                IRasterDataProvider outRaster    = null;
                IRasterDataProvider outVciRaster = null;
                IRasterDataProvider outTciRaster = null;
                try
                {
                    outRaster = CreateOutRaster(outFileName, rasterInputMaps.ToArray());
                    //栅格数据映射
                    RasterMaper[] fileIns = rasterInputMaps.ToArray();
                    RasterMaper[] fileOuts;
                    if (outVCITCI)
                    {
                        outVciRaster = CreateOutRaster(outVci, rasterInputMaps.ToArray());
                        outTciRaster = CreateOutRaster(outTci, rasterInputMaps.ToArray());
                        fileOuts     = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }), new RasterMaper(outVciRaster, new int[] { 1 }), new RasterMaper(outTciRaster, new int[] { 1 }) };
                    }
                    else
                    {
                        fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) }
                    };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    float   vci    = 0f;
                    float   tci    = 0f;
                    float[] values = null;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        if (rvInVistor[0].RasterBandsData[0] == null || rvInVistor[1].RasterBandsData[0] == null ||
                            rvInVistor[1].RasterBandsData[1] == null || rvInVistor[2].RasterBandsData[0] == null ||
                            rvInVistor[3].RasterBandsData[0] == null || rvInVistor[3].RasterBandsData[1] == null)
                        {
                            return;
                        }
                        int dataLength     = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] sumData    = new Int16[dataLength];
                        ushort[] countData = new ushort[dataLength];
                        for (int index = 0; index < dataLength; index++)
                        {
                            values    = new float[6];
                            values[0] = (float)rvInVistor[0].RasterBandsData[0][index] / NDVIZoom;
                            values[1] = (float)rvInVistor[1].RasterBandsData[0][index] / NDVIBackZoom;
                            values[2] = (float)rvInVistor[1].RasterBandsData[1][index] / NDVIBackZoom;
                            values[3] = (float)rvInVistor[2].RasterBandsData[0][index] / LSTZoom;
                            values[4] = (float)rvInVistor[3].RasterBandsData[0][index] / LSTBackZoom;
                            values[5] = (float)rvInVistor[3].RasterBandsData[1][index] / LSTBackZoom;
                            if (values[0] < ndviVaildMin || values[0] > ndviVaildMax ||
                                values[1] < ndviVaildMin || values[1] > ndviVaildMax ||
                                values[2] < ndviVaildMin || values[2] > ndviVaildMax ||
                                values[3] < lstVaildMin || values[3] > lstVaildMax ||
                                values[4] < lstVaildMin || values[4] > lstVaildMax ||
                                values[5] < lstVaildMin || values[5] > lstVaildMax)
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = 0;
                            }
                            else
                            {
                                //计算VCI
                                vci = (values[0] - values[1]) / (values[2] - values[1]);
                                //计算TCI
                                tci = (values[3] - values[4]) / (values[5] - values[4]);
                                rvOutVistor[0].RasterBandsData[0][index] = (Int16)((0.5 * vci + 0.5 * tci) * VTIZoom);
                                if (outVCITCI)
                                {
                                    rvOutVistor[1].RasterBandsData[0][index] = (Int16)(vci * VTIZoom);
                                    rvOutVistor[2].RasterBandsData[0][index] = (Int16)(tci * VTIZoom);
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                }
                finally
                {
                    if (outRaster != null)
                    {
                        outRaster.Dispose();
                    }
                    if (outVciRaster != null)
                    {
                        outVciRaster.Dispose();
                    }
                    if (outTciRaster != null)
                    {
                        outTciRaster.Dispose();
                    }
                }
                if (outVCITCI)
                {
                    ExtractResultArray resultArray = new ExtractResultArray(_subProductDef.Identify);
                    FileExtractResult  res         = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    resultArray.Add(res);
                    FileExtractResult resVci = new FileExtractResult(vciIdentify, outVci, true);
                    resVci.SetDispaly(false);
                    resultArray.Add(resVci);
                    FileExtractResult resTci = new FileExtractResult(tciIdentify, outTci, true);
                    resTci.SetDispaly(false);
                    resultArray.Add(resTci);
                    return(resultArray);
                }
                else
                {
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    return(res);
                }
            }
            finally
            {
                if (ndviMaxPrd != null)
                {
                    ndviMaxPrd.Dispose();
                }
                if (ndviPrd != null)
                {
                    ndviPrd.Dispose();
                }
                if (lstMaxPrd != null)
                {
                    lstMaxPrd.Dispose();
                }
            }
        }
Example #9
0
        public void ProcessVectorToRaster(string shpFileName, string shpPrimaryField, enumDataType dataType, double resolution, string rasterFileName)
        {
            //创建目标文件
            if (string.IsNullOrEmpty(rasterFileName))
            {
                return;
            }
            if (string.IsNullOrEmpty(shpFileName) || !File.Exists(shpFileName) ||
                Path.GetExtension(shpFileName).ToUpper() != ".SHP")
            {
                return;
            }
            using (IVectorFeatureDataReader dr = VectorDataReaderFactory.GetUniversalDataReader(shpFileName)
                                                 as IVectorFeatureDataReader)
            {
                if (dr == null)
                {
                    return;
                }
                Envelope env = dr.Envelope;
                if (env == null)
                {
                    return;
                }
                CoordEnvelope       envelope = new CoordEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY);
                int                 height   = (int)Math.Ceiling((envelope.MaxY - envelope.MinY) / resolution);
                int                 width    = (int)Math.Ceiling((envelope.MaxX - envelope.MinX) / resolution);
                IRasterDataProvider dataPrd  = null;
                try
                {
                    string extension = Path.GetExtension(rasterFileName).ToUpper();
                    switch (extension)
                    {
                    case ".LDF":
                    {
                        IRasterDataDriver driver  = GeoDataDriver.GetDriverByName("LDF") as IRasterDataDriver;
                        string            mapInfo = envelope.ToMapInfoString(new Size(width, height));
                        dataPrd = driver.Create(rasterFileName, width, height, 1, dataType, mapInfo);
                        break;
                    }

                    case ".DAT":
                    {
                        IRasterDataDriver driver  = GeoDataDriver.GetDriverByName("MEM") as IRasterDataDriver;
                        string            mapInfo = envelope.ToMapInfoString(new Size(width, height));
                        dataPrd = driver.Create(rasterFileName, width, height, 1, dataType, mapInfo);
                        break;
                    }

                    default:
                        return;
                    }
                    Feature[] features = dr.FetchFeatures();
                    if (features == null || features.Length < 1)
                    {
                        return;
                    }
                    ProcessVectorToRaster(features, shpPrimaryField, dataPrd);
                }
                finally
                {
                    if (dataPrd != null)
                    {
                        dataPrd.Dispose();
                    }
                }
            }
        }
Example #10
0
        private IPixelFeatureMapper <float> CreatPixelCoverRate(IPixelFeatureMapper <float> ndviResult)
        {
            if (ndviResult == null)
            {
                return(null);
            }
            //生成NDVI结果文件
            IRasterDataProvider       ndviDataProvider = null;
            IInterestedRaster <float> iir = null;

            try
            {
                RasterIdentify id = new RasterIdentify();
                id.ThemeIdentify      = "CMA";
                id.ProductIdentify    = "BAG";
                id.SubProductIdentify = "BPCD";
                id.Sensor             = _argumentProvider.DataProvider.DataIdentify.Sensor;
                id.Satellite          = _argumentProvider.DataProvider.DataIdentify.Satellite;
                id.OrbitDateTime      = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
                id.GenerateDateTime   = DateTime.Now;
                iir = new InterestedRaster <float>(id, new Size(_argumentProvider.DataProvider.Width, _argumentProvider.DataProvider.Height), _argumentProvider.DataProvider.CoordEnvelope.Clone());
                iir.Put(ndviResult);
                ndviDataProvider = iir.HostDataProvider;
                double dst;


                dst = MaxNDVI - MinNDVI;
                //判断是否使用端元值计算
                NDVISettingItem[] settings = _argumentProvider.GetArg("NDVISetting") as NDVISettingItem[];
                if (settings != null)
                {
                    ResetArgNDVIMaxMin(settings, ref MinNDVI, ref dst);
                }
                IPixelFeatureMapper <float> memresult = new MemPixelFeatureMapper <float>("BPCD", 1000, new Size(ndviDataProvider.Width, ndviDataProvider.Height), ndviDataProvider.CoordEnvelope, ndviDataProvider.SpatialRef);
                ArgumentProvider            ap        = new ArgumentProvider(ndviDataProvider, null);
                RasterPixelsVisitor <float> visitor   = new RasterPixelsVisitor <float>(ap);
                visitor.VisitPixel(new int[] { 1 }, (index, values) =>
                {
                    if (values[0] == -9999f)
                    {
                        memresult.Put(index, -9999);
                    }
                    else if (dst == 0)
                    {
                        memresult.Put(index, -9999);
                    }
                    else
                    {
                        memresult.Put(index, (float)((values[0] - MinNDVI) / dst));
                    }
                });
                iir.Dispose();
                return(memresult);
            }
            finally
            {
                if (ndviDataProvider != null)
                {
                    ndviDataProvider.Dispose();
                }
                if (File.Exists(iir.FileName))
                {
                    File.Delete(iir.FileName);
                }
            }
        }
Example #11
0
        public IExtractResult GetCloudBAG()
        {
            double niBandRoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
            bool   needcloud  = (bool)_argumentProvider.GetArg("isAppCloud");

            UCSetNearTool uccontrl = _argumentProvider.GetArg("UCSetNearTool") as UCSetNearTool;

            if (uccontrl.ckbone.Checked)
            {
                uccontrl.btnGetAOIIndex(null, null);
            }
            string cloudfile    = GetClmFile(_argumentProvider.DataProvider);
            bool   isexistcloud = File.Exists(cloudfile);

            MinNear = double.Parse(uccontrl.txtnearmin.Text) * 100;//放大调节 跟界面参数设置有关
            IRasterDataProvider prd = _argumentProvider.DataProvider;

            if (prd == null)
            {
                PrintInfo("未能获取当前影像数据。");
                return(null);
            }
            IBandNameRaster bandNameRaster = prd as IBandNameRaster;
            int             niBandNo       = TryGetBandNo(bandNameRaster, "NearInfrared");

            if (niBandNo == -1 || niBandRoom == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            List <RasterMaper> rms = new List <RasterMaper>();

            rms.Add(new RasterMaper(_argumentProvider.DataProvider, new int[] { niBandNo }));
            if (isexistcloud)
            {
                rms.Add(new RasterMaper(GeoDataDriver.Open(cloudfile) as IRasterDataProvider, new int[] { 1 }));
            }
            RasterIdentify rid = new RasterIdentify(_argumentProvider.DataProvider);

            rid.ProductIdentify    = "BAG";
            rid.SubProductIdentify = "DBLV";
            string outfile = rid.ToPrjWksFullFileName(".dat");
            IRasterDataProvider outRaster = null;

            outRaster = CreateOutRaster(outfile, rms.ToArray(), enumDataType.Int16);
            IPixelIndexMapper result = PixelIndexMapperFactory.CreatePixelIndexMapper("BAG", _argumentProvider.DataProvider.Width, _argumentProvider.DataProvider.Height,
                                                                                      _argumentProvider.DataProvider.CoordEnvelope, _argumentProvider.DataProvider.SpatialRef);

            try
            {
                RasterProcessModel <Int16, Int16> rfr = null;
                RasterMaper[] fileIns  = rms.ToArray();
                RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                rfr = new RasterProcessModel <Int16, Int16>();
                int totalindex = 0;
                rfr.SetRaster(fileIns, fileOuts);
                rfr.SetArgumentProviderAOI(_argumentProvider.AOI);
                rfr.RegisterCalcModel(new RasterCalcHandlerFun <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData[0] != null && rvInVistor[1].RasterBandsData[0] != null)
                    {
                        int dataLength = rvInVistor[0].SizeY * rvInVistor[0].SizeX;
                        for (int i = 0; i < aoi.Length; i++)
                        {
                            int index = aoi[i];
                            if (rvInVistor[0].RasterBandsData[0][index] / niBandRoom > MinNear)
                            {
                                if (needcloud)
                                {
                                    if (!isexistcloud)
                                    {
                                        result.Put(totalindex + index);
                                        continue;
                                    }
                                    else if (rvInVistor[1].RasterBandsData[0][index] == 0)//非云
                                    {
                                        result.Put(totalindex + index);
                                    }
                                    else
                                    {
                                        //rvOutVistor[0].RasterBandsData[0][aoi[i]] = -9999;// 云 这里是否需要配置一下?
                                    }
                                }
                                else
                                {
                                    result.Put(totalindex + index);
                                    //rvOutVistor[0].RasterBandsData[0][aoi[i]] = 1;
                                }
                            }
                            else
                            {
                            }
                        }
                        totalindex = totalindex += dataLength;
                    }

                    return(false);
                }));
                rfr.Excute();
                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                outRaster.Dispose();
            }
        }
        private unsafe bool GetSameSizeFilePrdMap(ref Dictionary <string, FilePrdMap> filePrdMap, bool interpolation)
        {
            if (filePrdMap == null || filePrdMap.Count == 0)
            {
                return(false);
            }
            FilePrdMap    fpm          = null;
            int           startBand    = 1;
            CoordEnvelope dstEnvelope  = null;
            double        dstResoltion = 0;
            Size          dstSize      = Size.Empty;
            string        dstPath      = GetTemplateFilePath();
            bool          same         = GetDstRegionInfos(ref filePrdMap, interpolation, out dstEnvelope, out dstResoltion, out dstSize);

            if (dstEnvelope == null)
            {
                return(false);
            }
            if (!same)
            {
                int        offsetX = 0;
                int        offsetY = 0;
                string     dstFilename;
                List <int> bandNumTemp = new List <int>();
                using (IRasterDataDriver drv = GeoDataDriver.GetDriverByName("LDF") as IRasterDataDriver)
                {
                    foreach (string key in filePrdMap.Keys)
                    {
                        fpm = filePrdMap[key];
                        //if (!fpm.SameRegion)
                        //{
                        IRasterBand band = null;
                        offsetX     = GetOffset(fpm.Prd.CoordEnvelope.MinX, dstEnvelope.MinX, fpm.Prd.ResolutionX);
                        offsetY     = GetOffset(fpm.Prd.CoordEnvelope.MaxY, dstEnvelope.MaxY, fpm.Prd.ResolutionY);
                        dstFilename = dstPath + Guid.NewGuid() + ".ldf";
                        IRasterDataProvider prdWriter = drv.Create(dstFilename, dstSize.Width, dstSize.Height, fpm.BandNums.Length,
                                                                   fpm.Prd.DataType, "INTERLEAVE=BSQ", "VERSION=LDF", "WITHHDR=TRUE", "SPATIALREF=" + GetSpatialRefString(fpm.Prd),
                                                                   GetMapInfoString(dstEnvelope, dstSize.Width, dstSize.Height)) as IRasterDataProvider;
                        switch (fpm.Prd.DataType)
                        {
                        case enumDataType.Byte:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                byte[] dataBlock = new byte[dstSize.Width * dstSize.Height];
                                fixed(byte *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.Double:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                double[] dataBlock = new double[dstSize.Width * dstSize.Height];
                                fixed(double *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.Float:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                float[] dataBlock = new float[dstSize.Width * dstSize.Height];
                                fixed(float *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.Int16:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                Int16[] dataBlock = new Int16[dstSize.Width * dstSize.Height];
                                fixed(Int16 *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.Int32:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                Int32[] dataBlock = new Int32[dstSize.Width * dstSize.Height];
                                fixed(Int32 *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.Int64:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                Int64[] dataBlock = new Int64[dstSize.Width * dstSize.Height];
                                fixed(Int64 *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.UInt16:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                UInt16[] dataBlock = new UInt16[dstSize.Width * dstSize.Height];
                                fixed(UInt16 *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.UInt32:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                UInt32[] dataBlock = new UInt32[dstSize.Width * dstSize.Height];
                                fixed(UInt32 *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;

                        case enumDataType.UInt64:
                            for (int i = 0; i < fpm.BandNums.Length; i++)
                            {
                                UInt64[] dataBlock = new UInt64[dstSize.Width * dstSize.Height];
                                fixed(UInt64 *buffer = dataBlock)
                                {
                                    IntPtr ptr = new IntPtr(buffer);

                                    ReadWriteCustomizingRegion(fpm, dstEnvelope, dstSize, prdWriter, offsetX, offsetY, dstFilename, bandNumTemp, drv, band, i, ptr);
                                }
                            }
                            break;
                        }
                        fpm.StartBand = startBand;
                        fpm.BandCount = fpm.BandNums.Length;
                        fpm.BandNums  = bandNumTemp.ToArray();
                        bandNumTemp.Clear();
                        fpm.Filename   = dstFilename;
                        fpm.SameRegion = true;
                        fpm.Prd.Dispose();
                        prdWriter.Dispose();
                        fpm.Prd    = GeoDataDriver.Open(dstFilename) as IRasterDataProvider;
                        startBand += fpm.BandCount;
                        //}
                        //else
                        //    fpm.StartBand = startBand;
                    }
                }
            }
            return(true);
        }
Example #13
0
        private IExtractResult FIRFMack(Action <int, string> progressTracker)
        {
            IBandNameRaster bandNameRaster   = _argumentProvider.DataProvider as IBandNameRaster;
            int             NearInfrared     = TryGetBandNo(bandNameRaster, "NearInfrared");
            int             CoverageBand     = (int)_argumentProvider.GetArg("CoverageBand");
            double          NearInfraredZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
            double          CoverageZoom     = (double)_argumentProvider.GetArg("CoverageBand_Zoom");
            float           NearInfraredMax  = (float)_argumentProvider.GetArg("NearInfraredMax");
            float           CoverageMin      = (float)_argumentProvider.GetArg("CoverageMin");
            float           FIRLZoom         = (float)_argumentProvider.GetArg("FIRFZoom");

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

            string coverageFile = _argumentProvider.GetArg("coverageFile") == null ? null : _argumentProvider.GetArg("coverageFile").ToString();

            if (string.IsNullOrEmpty(coverageFile))
            {
                PrintInfo("请设置背景农田百分比数据!");
                return(null);
            }

            float maxAvgValue;
            float minAvgValue;

            string[] nearInfValues = _argumentProvider.GetArg("NearInfraredValues") as string[];
            if (nearInfValues == null || nearInfValues.Count() != 2)
            {
                return(null);
            }
            if (!float.TryParse(nearInfValues[0], out maxAvgValue) || !float.TryParse(nearInfValues[1], out minAvgValue))
            {
                return(null);
            }
            if (maxAvgValue == minAvgValue)
            {
                return(null);
            }
            float dltValue                  = maxAvgValue - minAvgValue;
            List <RasterMaper>  rms         = new List <RasterMaper>();
            IRasterDataProvider curPrd      = _argumentProvider.DataProvider;
            IRasterDataProvider coveragePrd = null;

            try
            {
                RasterMaper nearRm = new RasterMaper(curPrd, new int[] { NearInfrared });
                rms.Add(nearRm);

                coveragePrd = RasterDataDriver.Open(coverageFile) as IRasterDataProvider;
                if (coveragePrd.BandCount < CoverageBand)
                {
                    PrintInfo("请选择正确的农田百分比数据文件通道值!");
                    return(null);
                }
                RasterMaper coverageRm = new RasterMaper(coveragePrd, new int[] { CoverageBand });
                rms.Add(coverageRm);

                string                      outFileName = GetFileName(new string[] { curPrd.fileName }, _subProductDef.ProductDef.Identify, _identify, ".dat", null);
                IPixelIndexMapper           result      = null;
                IPixelFeatureMapper <Int16> resultTag   = null;
                int   totalDatalength = 0;
                float tempValue       = 0;
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    result = PixelIndexMapperFactory.CreatePixelIndexMapper("FIR", outRaster.Width, outRaster.Height, outRaster.CoordEnvelope, outRaster.SpatialRef);
                    if (this.Tag == null || (this.Tag as MemPixelFeatureMapper <Int16>) == null)
                    {
                        resultTag = new MemPixelFeatureMapper <Int16>("FIFLT", 1000, new Size(outRaster.Width, outRaster.Height), outRaster.CoordEnvelope, outRaster.SpatialRef);
                    }
                    else
                    {
                        resultTag = this.Tag as MemPixelFeatureMapper <Int16>;
                    }
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = null;
                    rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.SetFeatureAOI(_argumentProvider.AOIs);
                    rfr.RegisterCalcModel(new RasterCalcHandlerFun <short, short>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        if (rvInVistor[0].RasterBandsData == null || rvInVistor[1].RasterBandsData == null ||
                            rvInVistor[0].RasterBandsData[0] == null || rvInVistor[1].RasterBandsData[0] == null)
                        {
                            totalDatalength += dataLength;
                            return(false);
                        }
                        if (_argumentProvider.AOIs == null)
                        {
                            for (int index = 0; index < dataLength; index++)
                            {
                                if (IsFirA(rvInVistor, index, NearInfraredZoom, NearInfraredMax))
                                {
                                    result.Put(totalDatalength + index);

                                    tempValue = (maxAvgValue - rvInVistor[0].RasterBandsData[0][index]) / dltValue;
                                    if (tempValue < rvInVistor[1].RasterBandsData[0][index] / CoverageZoom)
                                    {
                                        resultTag.Put(totalDatalength + index, tempValue < 0 ? (Int16)0 : (tempValue > 1 ? (Int16)(FIRLZoom) : (Int16)(tempValue * FIRLZoom)));
                                    }
                                    else
                                    {
                                        resultTag.Put(totalDatalength + index, (Int16)(rvInVistor[1].RasterBandsData[0][index] / CoverageZoom * FIRLZoom));
                                    }
                                }
                            }
                        }
                        else if (_argumentProvider.AOIs != null && aoi != null && aoi.Length != 0)
                        {
                            int indexFromAOI = 0;
                            for (int i = 0; i < aoi.Length; i++)
                            {
                                indexFromAOI = aoi[i];
                                if (IsFirA(rvInVistor, indexFromAOI, NearInfraredZoom, NearInfraredMax))
                                {
                                    result.Put(totalDatalength + indexFromAOI);

                                    tempValue = (maxAvgValue - rvInVistor[0].RasterBandsData[0][aoi[i]]) / dltValue;
                                    if (tempValue < rvInVistor[1].RasterBandsData[0][aoi[i]] / CoverageZoom)
                                    {
                                        resultTag.Put(totalDatalength + indexFromAOI, tempValue < 0 ? (Int16)0 : (tempValue > 1 ? (Int16)(FIRLZoom) : (Int16)(tempValue * FIRLZoom)));
                                    }
                                    else
                                    {
                                        resultTag.Put(totalDatalength + indexFromAOI, (Int16)(rvInVistor[1].RasterBandsData[0][aoi[i]] / CoverageZoom * FIRLZoom));
                                    }
                                }
                            }
                        }
                        totalDatalength += dataLength;
                        return(false);
                    }));
                    //执行
                    rfr.Excute();
                    this.Tag = resultTag;
                    return(result);
                }
            }
            finally
            {
                if (coveragePrd != null)
                {
                    coveragePrd.Dispose();
                }
            }
        }