Example #1
0
        public override IExtractResult MakeExtProduct(IPixelIndexMapper piexd, Action <int, string> progressTracker)
        {
            object        obj           = _argumentProvider.GetArg("ucAnlysisTool");
            UCAnlysisTool ucAnlysisTool = null;

            if (obj != null)
            {
                ucAnlysisTool = obj as UCAnlysisTool;
            }
            else
            {
                return(null);
            }
            RasterIdentify rid = new RasterIdentify(_argumentProvider.DataProvider.fileName);

            rid.ProductIdentify    = _subProductDef.ProductDef.Identify;
            rid.SubProductIdentify = _subProductDef.Identify;
            string dstfilename = rid.ToWksFullFileName(".txt");

            if (File.Exists(dstfilename))
            {
                File.Delete(dstfilename);
            }
            if (!string.IsNullOrEmpty(ucAnlysisTool.txtInfos.Text))
            {
                File.WriteAllLines(dstfilename, new string[] { ucAnlysisTool.txtInfos.Text }, Encoding.Unicode);
                FileExtractResult resTxt = new FileExtractResult("LST", dstfilename, true);
                resTxt.SetDispaly(false);
                return(resTxt);
            }
            return(null);
        }
Example #2
0
        private IExtractResultArray CalcGFRF(string[] files)
        {
            string datFname   = GetDatFilename(files);
            string GFInfoList = GenGFILfname(files);

            using (StreamWriter sw = new StreamWriter(GFInfoList, false, Encoding.Default))
            {
                sw.WriteLine("NO.\t" + "Latitude\t" + "Longitude\t" + "Size/ha\t" + "Temperature/K\t" + "Fire_Intensity\t" + "Reliability");
            }
            int[,] fireCountArray = InitValueArray();
            int[] firPositionArray = null;
            for (int i = 0; i < files.Length; i++)
            {
                firPositionArray = ProcessVectorToArray(files[i], GFInfoList);
                int col, row;
                foreach (int cr in firPositionArray)
                {
                    row = cr / _datwidth;
                    col = (cr % _datwidth);
                    fireCountArray[row, col] += 1;
                }
            }
            _firePointsCount = 0;
            ProcessArrayToRaster(datFname, fireCountArray);
            _argumentProvider.SetArg("SelectedPrimaryFiles", datFname);
            IFileExtractResult  GFRF  = GFRFAlgorithm() as IFileExtractResult;
            IExtractResultArray array = new ExtractResultArray("全球火点累计");
            IFileExtractResult  GFIL  = new FileExtractResult("GFIL", GFInfoList, true);

            GFIL.SetDispaly(false);
            array.Add(GFRF);
            array.Add(GFIL);
            return(array);
        }
Example #3
0
        private IExtractResult StateUHPI(int NormalLevel, string[] files, Dictionary <string, StatInfo> result)
        {
            float           sum        = 0;
            List <string[]> valueItems = new List <string[]>();
            string          DateStr    = GetStringArgument("DateStr");

            foreach (string key in result.Keys)
            {
                foreach (UInt16 level in result[key].UHPI.Keys)
                {
                    sum += level * ((float)result[key].UHPI[level] / result[key].totalCount);
                }
                valueItems.Add(new string[] { DataIdentifyMatcher.GetOrbitDateTime(key).AddHours(8).ToString(DateStr),
                                              Math.Round((1f / NormalLevel) * sum, 2).ToString() });
                sum = 0;
            }
            string title = "统计日期:" + DateTime.Now.ToShortDateString();

            string[]          columns    = new string[] { "日期", "比例指数" };
            IStatResult       statResult = new StatResult(title, columns, valueItems.ToArray());
            string            filename   = StatResultToFile(files, statResult, "UHE", "UHPI", "比例指数", string.Empty, 1, false);
            FileExtractResult fileResult = new FileExtractResult("UHPI", filename);

            fileResult.Add2Workspace = true;
            fileResult.SetDispaly(false);
            return(fileResult);
        }
Example #4
0
        public IFileExtractResult ClipSNWResult(string filename, string area)
        {
            inputFileName = filename;
            using (IRasterDataProvider raster = GeoDataDriver.Open(filename) as IRasterDataProvider)
            {
                _resolutionX      = raster.ResolutionX;
                _resolutionY      = raster.ResolutionY;
                _fileSize         = new Size(raster.Width, raster.Height);
                _fileEnvelope     = raster.CoordEnvelope;
                _activeSpatialRef = raster.SpatialRef;
                _activeCoordType  = raster.CoordType;
                raster.Dispose();
            }
            _outsizeRegion = new CoordEnvelope(_fileEnvelope.MinX, _fileEnvelope.MaxX, _fileEnvelope.MinY, _fileEnvelope.MaxY);
            OutDir         = Path.GetDirectoryName(filename);

            string                   hdrfile = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + ".hdr");
            List <Feature>           fets    = new List <Feature>();
            IVectorFeatureDataReader dr      = null;

            if (area == "中国区")
            {
                url = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "数据引用\\基础矢量\\行政区划\\面\\中国边界.shp");
            }
            else
            {
                url = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "数据引用\\基础矢量\\行政区划\\面\\省级行政区域_面.shp");
            }
            dr = VectorDataReaderFactory.GetUniversalDataReader(url) as IVectorFeatureDataReader;
            Feature[] temp = null;
            temp = dr.FetchFeatures();
            fets.AddRange(temp);
            Feature[] features = null;
            features   = fets.ToArray();
            _blockName = area;
            int index = GetFeatureIndx(area);

            _vectorFeature = features[index];//_selectFeature
            //string fieldValue = _vectorFeature.GetFieldValue(fieldIndex);
            evp = GetMaskEnvelope(_vectorFeature.Geometry as ShapePolygon);
            BlockDefWithAOI        outEnvelope;
            Size                   size;
            List <BlockDefWithAOI> blockList = new List <BlockDefWithAOI>();

            GetArgs(out outEnvelope, out size, out OutDir, out filename);
            envelopes = new BlockDefWithAOI[] { outEnvelope };
            aoiIndex  = GetFeatureAOIIndex();
            blockList.AddRange(envelopes);
            blockList[0].AOIIndexes = aoiIndex;
            string[] put = RasterClipT(inputFileName, blockList.ToArray(), OutDir, "Cut");
            //put[0] = OutDir + put[0];
            string             getpath = Path.GetDirectoryName(put[0]);
            IFileExtractResult res     = new FileExtractResult("MWS", put[0], true);

            res.SetDispaly(false);
            return(res);
        }
Example #5
0
        private IExtractResult EDGEAlgorithm()
        {
            int   band                = (int)_argumentProvider.GetArg("band");
            int   smaping             = (int)_argumentProvider.GetArg("Smaping");
            float dataValue           = (float)_argumentProvider.GetArg("dataValue");
            bool  isOutputUncompleted = (bool)_argumentProvider.GetArg("IsOutputUncompleted");

            string[] files    = GetStringArray("SelectedPrimaryFiles");
            string   extInfos = GetStringArgument("extinfo");

            if (files == null || files.Length == 0)
            {
                return(null);
            }
            try
            {
                ExtractResultArray  array = new ExtractResultArray("FLD");
                IRasterDataProvider rdp   = null;
                string shpFile            = null;
                GenerateContourLines gcl  = null;
                FileExtractResult    res  = null;
                RasterIdentify       rid;
                foreach (string file in files)
                {
                    try
                    {
                        //生成等值线shp文件
                        shpFile = GenEDGEFiename(file);
                        gcl     = new GenerateContourLines(_progressTracker, _contextMessage);
                        rdp     = GeoDataDriver.Open(file, null) as IRasterDataProvider;
                        rid     = new RasterIdentify(rdp);
                        if (rid.SubProductIdentify == "DBLV" && dataValue == 1)
                        {
                            dataValue = 0;
                        }
                        gcl.DoGenerateContourLines(rdp, band, _argumentProvider.AOI, new double[] { dataValue }, smaping, shpFile, isOutputUncompleted);
                        if (!File.Exists(shpFile))
                        {
                            PrintInfo(Path.GetFileName(file) + ":生成等值线数据失败。");
                            continue;
                        }
                        res = new FileExtractResult(_subProductDef.Identify, shpFile, true);
                        res.SetDispaly(false);
                        array.Add(res);
                    }
                    finally
                    {
                        rdp.Dispose();
                    }
                }
                return(array.PixelMappers == null || array.PixelMappers.Length == 0 ? null : array);
            }
            finally
            {
            }
        }
Example #6
0
        private IFileExtractResult GenrateIInterested(MemPixelFeatureMapper <UInt16> result, IRasterDataProvider currPrd, string subProductIndentify)
        {
            RasterIdentify id = new RasterIdentify(currPrd.fileName.ToUpper());

            id.ThemeIdentify         = "CMA";
            id.ProductIdentify       = "UHE";
            id.SubProductIdentify    = subProductIndentify;
            id.IsOutput2WorkspaceDir = true;
            using (IInterestedRaster <UInt16> iir = new InterestedRaster <UInt16>(id, new Size(currPrd.Width, currPrd.Height), currPrd.CoordEnvelope.Clone(), currPrd.SpatialRef))
            {
                iir.Put(result);
                IFileExtractResult fileResult = new FileExtractResult(subProductIndentify, iir.FileName);
                fileResult.SetDispaly(false);
                return(fileResult);
            }
        }
Example #7
0
        private IExtractResult CompareAlgorithm()
        {
            string compareFile = _argumentProvider.GetArg("CompareFile").ToString();
            string file        = _argumentProvider.GetArg("MainFile").ToString();

            if (file == null && string.IsNullOrEmpty(file))
            {
                return(null);
            }
            string outFileIdentify = GetStringArgument("OutFileIdentify");
            string productIdentify = _subProductDef.ProductDef.Identify;
            IPixelFeatureMapper <Int16> rasterResult = MakeCompareRaster <float, Int16>(productIdentify, compareFile, file, (fstFileValue, sedFileValue) =>
            {
                if (fstFileValue > 0f && sedFileValue == 1f)
                {
                    return(1);
                }
                else if (fstFileValue == 0f && sedFileValue == 1f)
                {
                    return(4);
                }
                else if (fstFileValue > 0f && sedFileValue == 0f)
                {
                    return(5);
                }
                else
                {
                    return(0);
                }
            }, false);

            if (rasterResult == null)
            {
                return(null);
            }
            else
            {
                RasterIdentify            rid = GetRasterIdentifyID(new RasterIdentify(new string[] { compareFile, file }));
                IInterestedRaster <Int16> iir = new InterestedRaster <Int16>(rid, rasterResult.Size, rasterResult.CoordEnvelope, null);
                iir.Put(rasterResult);
                iir.Dispose();
                FileExtractResult result = new FileExtractResult(outFileIdentify, iir.FileName);
                result.SetDispaly(false);
                return(result);
            }
        }
Example #8
0
        private IExtractResult StateAreaCol(int NormalLevel, string[] files, Dictionary <string, StatInfo> result, int HILevel)
        {
            string[]        normalDesc = GetStringArray("NormalDesc");
            List <string[]> valueItems = new List <string[]>();
            List <string>   temp       = null;
            List <string>   columnList = new List <string>();

            columnList.Add("日期");
            string DateStr = GetStringArgument("DateStr");

            for (UInt16 col = 0; col < HILevel; col++)
            {
                columnList.Add(normalDesc == null || col >= normalDesc.Length ? (NormalLevel - col).ToString() : normalDesc[col]);
            }
            IRasterDataProvider rdp = GeoDataDriver.Open(files[0]) as IRasterDataProvider;
            double areaBase         = 0f;

            areaBase = GetAreaBase(rdp, areaBase);
            foreach (string key in result.Keys)
            {
                temp = new List <string>();
                temp.Add(DataIdentifyMatcher.GetOrbitDateTime(key).AddHours(8).ToString(DateStr));
                for (UInt16 level = 0; level < HILevel; level++)
                {
                    if (!result[key].UHPI.ContainsKey((UInt16)(NormalLevel - level)))
                    {
                        temp.Add("0");
                    }
                    else
                    {
                        temp.Add(Math.Round(result[key].UHPI[(UInt16)(NormalLevel - level)] * areaBase / Math.Pow(10, 6), 2).ToString());
                    }
                }
                valueItems.Add(temp.ToArray());
            }
            string title = "统计日期:" + DateTime.Now.ToShortDateString() + " 面积单位:平方公里";

            string[]          columns    = columnList.ToArray();
            IStatResult       statResult = new StatResult(title, columns, valueItems.ToArray());
            string            filename   = StatResultToFile(files, statResult, "UHE", "UHAR", "热岛面积", string.Empty, 1, false, 1);
            FileExtractResult fileResult = new FileExtractResult("UHAR", filename);

            fileResult.Add2Workspace = true;
            fileResult.SetDispaly(false);
            return(fileResult);
        }
        internal IFileExtractResult GeneratorKB(IArgumentProvider argProvider, Dictionary <int, FireAreaFeature> features)
        {
            DateTime        orbitDateTime = DateTime.MinValue;
            string          saveFilename  = GetFALTFilenameKB(argProvider, out orbitDateTime);
            List <string[]> excelInfos    = new List <string[]>();

            string[]      columns  = new string[] { "火区号", "中心经度", "中心纬度", "火点像元个数", "像元覆盖面积(平方公里)", "明火面积(公顷)", "省地县", "林地", "草地", "农田", "其他" };
            List <string> listTemp = new List <string>();

            for (int i = 0; i < features.Count; i++)
            {
                listTemp.Add((features[i].FireReaIndex + 1).ToString());
                listTemp.Add(features[i].Longitude.ToString());
                listTemp.Add(features[i].Latitude.ToString());
                listTemp.Add(features[i].FireCount.ToString("#"));
                listTemp.Add(features[i].FireArea.ToString("#0.000"));
                listTemp.Add(features[i].SecondryFireArea.ToString("#0.000"));
                listTemp.Add(string.IsNullOrEmpty(features[i].XJName) ? @"\" : features[i].XJName);
                listTemp.Add(features[i].WoodlandPercent == 0 ? @"\" : (features[i].WoodlandPercent * 100 + "%"));
                listTemp.Add(features[i].GrasslandPercent == 0 ? @"\" : (features[i].GrasslandPercent * 100 + "%"));
                listTemp.Add(features[i].FarmlandPercent == 0 ? @"\" : (features[i].FarmlandPercent * 100 + "%"));
                listTemp.Add(features[i].OtherPercent == 0 ? @"\" : (features[i].OtherPercent * 100 + "%"));
                excelInfos.Add(listTemp.ToArray());
                listTemp.Clear();
            }
            IStatResult result = new StatResult("火区信息统计结果", columns, excelInfos.ToArray());

            using (StatResultToExcelFile excelControl = new StatResultToExcelFile())
            {
                excelControl.Init();
                excelControl.Add(true, "火区信息数据统计", result, false, 0);
                excelControl.WinExcelControl.SetCellValue(2, 2, 2, 12, 0, masExcelAlignType.Center, "火情信息快报", null);
                string timestring = string.Format("时间:{0}(北京时)", orbitDateTime.AddHours(8).ToString("yyyy年MM月dd日 HH:mm"));
                excelControl.WinExcelControl.SetCellValue(3, 2, 3, 6, 0, masExcelAlignType.Left, timestring, null);
                excelControl.WinExcelControl.SetCellValue(3, 7, 3, 12, 0, masExcelAlignType.Right, "国家卫星气象中心", null);
                excelControl.WinExcelControl.SetCellValue(4, 2, 4, 12, 1, masExcelAlignType.Center, "火区信息数据统计", null);
                excelControl.SaveFile(saveFilename);
            }
            IFileExtractResult resultFile = new FileExtractResult("FRIK", saveFilename);

            resultFile.SetDispaly(false);
            return(resultFile);
        }
Example #10
0
        private IExtractResult StateAreaRow(int NormalLevel, string[] files, Dictionary <string, StatInfo> result, int HILevel)
        {
            string[]            normalDesc = GetStringArray("NormalDesc");
            string              DateStr    = GetStringArgument("DateStr");
            List <string[]>     valueItems = new List <string[]>();
            IRasterDataProvider rdp        = GeoDataDriver.Open(files[0]) as IRasterDataProvider;
            double              areaBase   = 0f;

            areaBase = GetAreaBase(rdp, areaBase);
            int           col        = 0;
            List <string> columnList = new List <string>();

            columnList.Add("日期");
            for (int row = 0; row < HILevel; row++)
            {
                valueItems.Add(new string[result.Count + 1]);
                valueItems[row][0] = normalDesc == null || row >= normalDesc.Length ? (NormalLevel - row).ToString() : normalDesc[row];
            }
            foreach (string key in result.Keys)
            {
                col++;
                columnList.Add(DataIdentifyMatcher.GetOrbitDateTime(key).AddHours(8).ToString(DateStr));
                for (int row = 0; row < HILevel; row++)
                {
                    for (UInt16 level = (UInt16)(NormalLevel - row), num = 0; num < HILevel; num++)
                    {
                        valueItems[row][col] = Math.Round(result[key].UHPI[level] * areaBase / Math.Pow(10, 6), 2).ToString();
                    }
                }
            }
            string title = "统计日期:" + DateTime.Now.ToShortDateString() + " 面积单位:平方公里";

            string[]          columns    = columnList.ToArray();
            IStatResult       statResult = new StatResult(title, columns, valueItems.ToArray());
            string            filename   = StatResultToFile(files, statResult, "UHE", "UHAR", "热岛面积", string.Empty, 1, false, 1);
            FileExtractResult fileResult = new FileExtractResult("UHAR", filename);

            fileResult.Add2Workspace = true;
            fileResult.SetDispaly(false);
            return(fileResult);
        }
Example #11
0
 private IExtractResultBase ComputeSingleFile(string fname, IRasterExtracter <ushort, short> extracter, int[] bandNos, string express)
 {
     using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
     {
         if (prd == null)
         {
             return(null);
         }
         int bandCount = prd.BandCount;
         foreach (int band in bandNos)
         {
             if (bandCount == 0 || bandCount == 1)
             {
                 PrintInfo("请选择正确的局地文件进行计算。");
                 return(null);
             }
             if (bandCount < band)
             {
                 PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误!");
                 return(null);
             }
         }
         IArgumentProvider aPrd = new ArgumentProvider(prd, null);
         extracter.Reset(aPrd, bandNos, express);
         string filename = string.Empty;
         using (IPixelFeatureMapper <Int16> resultNDVI = new MemPixelFeatureMapper <Int16>(_identify, prd.Width * prd.Height, new System.Drawing.Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef))
         {
             extracter.Extract(resultNDVI);
             RasterIdentify rid = GetRasterIdentify(fname);
             using (InterestedRaster <Int16> iir = new InterestedRaster <Int16>(rid, new System.Drawing.Size(prd.Width, prd.Height), prd.CoordEnvelope))
             {
                 iir.Put(resultNDVI);
                 filename = iir.FileName;
             }
             IFileExtractResult ndviResult = new FileExtractResult(_identify, filename);
             ndviResult.SetDispaly(false);
             return(ndviResult);
         }
     }
 }
        /// <summary>
        /// 生成Txt火区信息列表
        /// </summary>
        /// <param name="argProvider"></param>
        /// <param name="features"></param>
        /// <returns></returns>

        /*
         * internal IFileExtractResult Generator(IArgumentProvider argProvider, Dictionary<int, FireAreaFeature> features)
         * {
         *  DateTime orbitDateTime = DateTime.MinValue;
         *  string saveFilename = GetFALTFilename(argProvider, out orbitDateTime);
         *  using (StreamWriter sw = new StreamWriter(saveFilename, false, Encoding.UTF8))
         *  {
         *      foreach (FireSubareaColumnHeader item in FireSubareaColumnHeaderDef.FireSubarea)
         *      {
         *          sw.Write(item.Caption);
         *          sw.Write("\t");
         *      }
         *      sw.WriteLine();
         *      for (int i = 0; i < features.Count; i++)
         *      {
         *          sw.Write(features[i].FireReaIndex);
         *          sw.Write("\t");
         *          sw.Write(DegreeConvert(features[i].Longitude));
         *          sw.Write("\t");
         *          sw.Write(DegreeConvert(features[i].Latitude));
         *          sw.Write("\t");
         *          sw.Write(features[i].FireCount.ToString("#").PadRight(10));
         *          sw.Write("\t");
         *          sw.Write(features[i].FireArea.ToString("#0.000").PadRight(10));
         *          sw.Write("\t");
         *          sw.Write(features[i].SecondryFireArea.ToString("#0.000").PadRight(10));
         *          sw.Write("\t");
         *          sw.Write(string.IsNullOrEmpty(features[i].XJName) ? @"\".PadRight(30) : features[i].XJName.PadRight(30));
         *          sw.Write("\t");
         *          sw.Write(features[i].WoodlandPercent == 0 ? @"\".PadRight(20) : (features[i].WoodlandPercent * 100 + "%").PadRight(10));
         *          sw.Write("\t");
         *          sw.Write(features[i].GrasslandPercent == 0 ? @"\".PadRight(20) : (features[i].GrasslandPercent * 100 + "%").PadRight(10));
         *          sw.Write("\t");
         *          sw.Write(features[i].FarmlandPercent == 0 ? @"\".PadRight(20) : (features[i].FarmlandPercent * 100 + "%").PadRight(10));
         *          sw.Write("\t");
         *          sw.Write(features[i].OtherPercent == 0 ? @"\".PadRight(20) : (features[i].OtherPercent * 100 + "%").PadRight(10));
         *          sw.Write("\t");
         *          sw.WriteLine();
         *      }
         *  }
         *  IFileExtractResult result = new FileExtractResult("FRIL", saveFilename);
         *  result.SetDispaly(false);
         *  return result;
         * }
         */

        /// <summary>
        /// 生成Excel火区信息列表
        /// </summary>
        /// <param name="argProvider"></param>
        /// <param name="features"></param>
        /// <returns></returns>
        internal IFileExtractResult Generator(IArgumentProvider argProvider, Dictionary <int, FireAreaFeature> features)
        {
            DateTime        orbitDateTime = DateTime.MinValue;
            string          saveFilename  = GetFALTFilename(argProvider, out orbitDateTime);
            List <string[]> excelInfos    = new List <string[]>();

            string[]      columns  = new string[] { "火区号", "中心经度", "中心纬度", "火点像元个数", "像元覆盖面积(平方公里)", "明火面积(公顷)", "省地县", "林地", "草地", "农田", "其他" };
            List <string> listTemp = new List <string>();

            for (int i = 0; i < features.Count; i++)
            {
                listTemp.Add((features[i].FireReaIndex + 1).ToString());
                listTemp.Add(features[i].Longitude.ToString());
                listTemp.Add(features[i].Latitude.ToString());
                listTemp.Add(features[i].FireCount.ToString("#"));
                listTemp.Add(features[i].FireArea.ToString("#0.000"));
                listTemp.Add(features[i].SecondryFireArea.ToString("#0.000"));
                listTemp.Add(string.IsNullOrEmpty(features[i].XJName) ? @"\" : features[i].XJName);
                listTemp.Add(features[i].WoodlandPercent == 0 ? @"\" : (features[i].WoodlandPercent * 100 + "%"));
                listTemp.Add(features[i].GrasslandPercent == 0 ? @"\" : (features[i].GrasslandPercent * 100 + "%"));
                listTemp.Add(features[i].FarmlandPercent == 0 ? @"\" : (features[i].FarmlandPercent * 100 + "%"));
                listTemp.Add(features[i].OtherPercent == 0 ? @"\" : (features[i].OtherPercent * 100 + "%"));
                excelInfos.Add(listTemp.ToArray());
                listTemp.Clear();
            }
            IStatResult result = new StatResult("火区信息统计结果", columns, excelInfos.ToArray());

            using (StatResultToExcelFile excelControl = new StatResultToExcelFile())
            {
                excelControl.Init();
                excelControl.Add(true, "火区信息数据统计", result, false, 0);
                excelControl.SaveFile(saveFilename);
            }
            IFileExtractResult resultFile = new FileExtractResult("FRIL", saveFilename);

            resultFile.SetDispaly(false);
            return(resultFile);
        }
Example #13
0
        private IExtractResult TauL55Algorithm()
        {
            IFileExtractResult U5TTResult       = null;
            string             instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            if (instance != null)
            {
                U5TTResult = ThemeGraphyResult(null) as IFileExtractResult;
                IExtractResultArray array      = new ExtractResultArray("气溶胶产品");
                IFileExtractResult  U5TIResult = new FileExtractResult("U5TI", _055TauFname, true);
                U5TIResult.SetDispaly(false);
                array.Add(U5TTResult);
                array.Add(U5TIResult);
                return(array);
            }
            return(null);
        }
        public IFileExtractResult ExportILSTToExcel(string saveFileName)
        {
            string[]        lineInfos  = File.ReadAllLines(saveFileName, Encoding.Default);
            List <string[]> excelInfos = new List <string[]>();

            string[] columns = new string[] { "火区号", "中心经度", "中心纬度", "火点像元个数", "像元覆盖面积(平方公里)", "明火面积(公顷)", "省地县", "林地", "草地", "农田", "其他" };
            for (int i = 1; i < lineInfos.Length; i++)
            {
                excelInfos.Add(lineInfos[i].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries));
            }
            IStatResult result = new StatResult("火区信息统计结果", columns, excelInfos.ToArray());

            using (StatResultToExcelFile excelControl = new StatResultToExcelFile())
            {
                excelControl.Init();
                excelControl.Add(true, "火区信息数据统计", result, false, 0);
                saveFileName = Path.Combine(Path.GetDirectoryName(saveFileName), Path.GetFileNameWithoutExtension(saveFileName) + ".XLSX");
                excelControl.SaveFile(saveFileName);
            }
            IFileExtractResult resultFile = new FileExtractResult("FRIL", saveFileName);

            resultFile.SetDispaly(false);
            return(resultFile);
        }
Example #15
0
        private IExtractResult CalcVci(string algorithmName, Action <int, string> progressTracker)
        {
            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();
            }
            if (backFile == ndviFile)
            {
                PrintInfo("请选择正确的背景库数据!");
                return(null);
            }
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                IRasterDataProvider ndviRaster = RasterDataDriver.Open(ndviFile) as IRasterDataProvider;
                if (ndviRaster.BandCount < ndviCH)
                {
                    PrintInfo("");
                    return(null);
                }
                RasterMaper rm = new RasterMaper(ndviRaster, new int[] { ndviCH });
                rms.Add(rm);
                IRasterDataProvider backRaster = RasterDataDriver.Open(backFile) as IRasterDataProvider;
                if (backRaster.BandCount < ndviMinCH || backRaster.BandCount < ndviMaxCH)
                {
                    PrintInfo("背景库通道设置错误,大于实际数据通道数");
                    return(null);
                }
                RasterMaper bm = new RasterMaper(backRaster, new int[] { ndviMaxCH, ndviMinCH });
                rms.Add(bm);
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri = new RasterIdentify(ndviFile);
                ri.ProductIdentify    = _subProductDef.ProductDef.Identify;
                ri.SubProductIdentify = _identify;
                string outFileName = ri.ToWksFullFileName(".dat");
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <short, short> rfr = null;
                    rfr = new RasterProcessModel <short, short>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    //rfr.SetTemplateAOI(aoiTemplate);
                    rfr.RegisterCalcModel(
                        new RasterCalcHandler <short, short>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        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;
                        for (int index = 0; index < dataLength; index++)
                        {
                            short backMax = rvInVistor[1].RasterBandsData[0][index];
                            short backMin = rvInVistor[1].RasterBandsData[1][index];
                            int divi      = backMax - backMin;
                            if (divi == 0)
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = 0;
                            }
                            else
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = (short)((float)(rvInVistor[0].RasterBandsData[0][index] - rvInVistor[1].RasterBandsData[1][index]) / divi * resultZoom);
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    return(res);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Example #16
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 != "0AVG")
            {
                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);
                }
            }
            int bandNo = 1;
            //输入文件准备
            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          = GetRasterIdentifyID(fileNames);
                string         outFileName = ri.ToWksFullFileName(".dat");
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    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);
                    Int16[] nanValues   = GetNanValues("CloudyValue");
                    Int16[] waterValues = GetNanValues("WaterValue");
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength       = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] sumData      = new Int16[dataLength];
                        Int16[] countData    = new Int16[dataLength];
                        Int16[] invailValues = GetNanValues("InvailValue");
                        if (nanValues != null && nanValues.Length > 0)
                        {
                            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 (invailValues.Contains(dt[index]))
                                        {
                                            continue;
                                        }
                                        if (IsNanValue(dt[index], nanValues) || IsNanValue(dt[index], waterValues))
                                        {
                                            //临时修改 用于符合李亚军数据生产
                                            if (IsNanValue(dt[index], nanValues))
                                            {
                                                countData[index] = 0;
                                            }
                                            else
                                            {
                                                sumData[index] = -1;
                                            }
                                            //
                                            //sumData[index] = (sumData[index] == 0 && countData[index] == 0) ? dt[index] : sumData[index];
                                            continue;
                                        }
                                        else
                                        {
                                            //临时修改 用于符合李亚军数据生产
                                            if (sumData[index] == -1)
                                            {
                                                countData[index] = 0;
                                                continue;
                                            }
                                            //

                                            if (IsNanValue(sumData[index], nanValues) ||
                                                IsNanValue(dt[index], waterValues) && countData[index] == 0)
                                            {
                                                sumData[index] = 0;
                                            }
                                            sumData[index] += dt[index];
                                            countData[index]++;
                                        }
                                    }
                                }
                            }
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            if (countData[index] != 0)
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = (Int16)(sumData[index] / countData[index]);
                            }
                            else
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = sumData[index];
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    return(res);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Example #17
0
        private IExtractResult IceThinknessAlgorithm(Action <int, string> progressTracker)
        {
            IRasterDataProvider dataPrd = _argumentProvider.DataProvider;

            if (dataPrd == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("DBLVFile") == null)
            {
                return(null);
            }
            string dblvFile = _argumentProvider.GetArg("DBLVFile").ToString();

            if (string.IsNullOrEmpty(dblvFile) || !File.Exists(dblvFile))
            {
                return(null);
            }
            IRasterDataProvider dblvRaster = GeoDataDriver.Open(dblvFile) as IRasterDataProvider;
            float t1 = Obj2Float(_argumentProvider.GetArg("T1"));
            float t2 = Obj2Float(_argumentProvider.GetArg("T2"));
            float t3 = Obj2Float(_argumentProvider.GetArg("T3"));

            if (float.IsNaN(t1) || float.IsNaN(t2) || float.IsNaN(t3))
            {
                PrintInfo("获取计算参数失败。");
                return(null);
            }
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             bandNo         = TryGetBandNo(bandNameRaster, "FarInfrared");

            if (bandNo == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            string[] aois        = _argumentProvider.GetArg("AOITemplate") as string[];
            string   aoiTemplate = (aois == null || aois.Length == 0) ? null : aois[0];
            //输入文件准备
            List <RasterMaper> rms    = new List <RasterMaper>();
            RasterMaper        rm     = new RasterMaper(dataPrd, new int[] { bandNo });
            RasterMaper        dblvRm = new RasterMaper(dblvRaster, new int[] { 1 });

            rms.Add(rm);
            rms.Add(dblvRm);
            //创建结果数据
            using (IRasterDataProvider outRaster = CreateOutRaster(rm))
            {
                //栅格数据映射
                RasterMaper[] fileIns  = rms.ToArray();
                RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                //创建处理模型
                RasterProcessModel <short, short> rfr = null;
                rfr = new RasterProcessModel <short, short>(progressTracker);
                rfr.SetRaster(fileIns, fileOuts);
                rfr.SetTemplateAOI("vector:海陆模版_反");
                rfr.RegisterCalcModel(new RasterCalcHandler <short, short>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData[0] != null)
                    {
                        if (aoi != null && aoi.Length != 0)
                        {
                            int index;
                            for (int i = 0; i < aoi.Length; i++)
                            {
                                index = aoi[i];
                                if (rvInVistor[1].RasterBandsData[0][index] == 1)
                                {
                                    short value = rvInVistor[0].RasterBandsData[0][index];
                                    if (value > t1)
                                    {
                                        rvOutVistor[0].RasterBandsData[0][index] = -1;
                                    }
                                    else
                                    {
                                        if (value > t2)
                                        {
                                            rvOutVistor[0].RasterBandsData[0][index] = 1;
                                        }
                                        else if (value > t3)
                                        {
                                            rvOutVistor[0].RasterBandsData[0][index] = 5;
                                        }
                                        else
                                        {
                                            rvOutVistor[0].RasterBandsData[0][index] = 10;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }));
                //执行
                rfr.Excute(Int16.MinValue);
                FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outRaster.fileName, true);
                res.SetDispaly(false);
                return(res);
            }
        }
Example #18
0
        private IExtractResult FRDSAlgorithm(Action <int, string> progressTracker)
        {
            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);
                }
            }
            int bandNo = 1;
            ExtractResultArray array = new ExtractResultArray("SNW");
            //输出文件准备(作为输入栅格并集处理)
            RasterIdentify ri          = GetRasterIdentifyID(ref fileNames);
            string         outFileName = ri.ToWksFullFileName(".dat");
            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();
            string             tempFilename;

            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    tempFilename = ProcessCloud(fileNames[i], bandNo);
                    IRasterDataProvider inRaster = RasterDataDriver.Open(tempFilename) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNo)
                    {
                        PrintInfo("请选择正确的数据进行积雪天数统计。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { tempFilename == fileNames[i] ? bandNo : 1 });
                    rms.Add(rm);
                }
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    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);
                    Int16[] nanValues     = GetNanValues("CloudyValue");
                    Int16[] waterValues   = GetNanValues("WaterValue");
                    Int16[] invailValues  = GetNanValues("InvailValue");
                    Int16   currTimeValue = 0;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength         = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] timeValue      = new Int16[dataLength];
                        List <Int16> tempValue = new List <Int16>();
                        for (int i = 0; i < dataLength; i++)
                        {
                            timeValue[i] = 0;
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            foreach (RasterVirtualVistor <Int16> rvs in rvInVistor)
                            {
                                Int16[] dt = rvs.RasterBandsData[0];
                                if (dt == null)
                                {
                                    continue;
                                }
                                tempValue.Add(dt[index]);
                            }

                            if (tempValue.Count == 0)
                            {
                                continue;
                            }
                            if (TimeValue(tempValue.ToArray(), nanValues, invailValues, waterValues, out currTimeValue))
                            {
                                timeValue[index] = currTimeValue;
                            }
                            tempValue.Clear();
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            rvOutVistor[0].RasterBandsData[0][index] = timeValue[index];
                        }
                    }));
                    //执行
                    rfr.Excute(0);
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    array.Add(res);
                    res.SetDispaly(false);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }

            _argumentProvider.SetArg("SelectedPrimaryFiles", new string[] { outFileName });
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(array);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
            IExtractResult        ress     = ThemeGraphyByInstance(instance);

            if (ress != null)
            {
                array.Add(ress as IFileExtractResult);
            }
            return(array);
        }
Example #19
0
        private IFileExtractResult ComputeDepthRaster(string currentRasterFile, string dblvFile, string roughnessFile, string angleFile, int visibleCH, int shortInfraredCH, string[] depthArgs)
        {
            float arg;
            float a0 = 0, a1 = 0, a2 = 0, a3 = 0, b0 = 0, b1 = 0, b2 = 0, b3 = 0;

            if (String2Float(depthArgs[1], out arg))
            {
                a0 = arg;
            }
            if (String2Float(depthArgs[2], out arg))
            {
                a1 = arg;
            }
            if (String2Float(depthArgs[3], out arg))
            {
                a2 = arg;
            }
            if (String2Float(depthArgs[4], out arg))
            {
                a3 = arg;
            }
            if (String2Float(depthArgs[5], out arg))
            {
                b0 = arg;
            }
            if (String2Float(depthArgs[6], out arg))
            {
                b1 = arg;
            }
            if (String2Float(depthArgs[7], out arg))
            {
                b2 = arg;
            }
            if (String2Float(depthArgs[8], out arg))
            {
                b3 = arg;
            }
            List <RasterMaper>  rms               = null;
            IRasterDataProvider outRaster         = null;
            RasterProcessModel <Int16, float> rfr = null;
            bool isCorrectAngle                   = false;

            try
            {
                rms = new List <RasterMaper>();
                IRasterDataProvider argRaster = GeoDataDriver.Open(roughnessFile) as IRasterDataProvider;
                RasterMaper         argRm     = new RasterMaper(argRaster, new int[] { 1 });
                rms.Add(argRm);
                IRasterDataProvider inRaster = GeoDataDriver.Open(currentRasterFile) as IRasterDataProvider;
                RasterMaper         fileIn   = new RasterMaper(inRaster, new int[] { visibleCH, shortInfraredCH });
                rms.Add(fileIn);
                IRasterDataProvider dblvRaster = GeoDataDriver.Open(dblvFile) as IRasterDataProvider;
                RasterMaper         dblvRm     = new RasterMaper(dblvRaster, new int[] { 1 });
                rms.Add(dblvRm);
                if (!string.IsNullOrEmpty(angleFile))
                {
                    IRasterDataProvider angleRaster = GeoDataDriver.Open(angleFile) as IRasterDataProvider;
                    RasterMaper         angleRm     = new RasterMaper(angleRaster, new int[] { 1 });
                    rms.Add(angleRm);
                    isCorrectAngle = true;
                }
                //string outFileId = _argumentProvider.GetArg("OutFileIdentify").ToString();
                string depthFileName = GetFileName(new string[] { currentRasterFile }, _subProductDef.ProductDef.Identify, "0SSD", ".dat", null);
                outRaster = CreateOutRaster(depthFileName, enumDataType.Float, rms.ToArray(), inRaster.ResolutionX);
                RasterMaper   fileOut  = new RasterMaper(outRaster, new int[] { 1 });
                RasterMaper[] fileIns  = rms.ToArray();
                RasterMaper[] fileOuts = new RasterMaper[] { fileOut };
                rfr = new RasterProcessModel <Int16, float>();
                rfr.SetRaster(fileIns, fileOuts);
                rfr.RegisterCalcModel(new RasterCalcHandler <Int16, float>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[2].RasterBandsData[0] != null)
                    {
                        int length = rvInVistor[2].RasterBandsData[0].Length;
                        for (int i = 0; i < length; i++)
                        {
                            if (rvInVistor[2].RasterBandsData[0][i] == 1)
                            {
                                short roughValue = rvInVistor[0].RasterBandsData[0][i];
                                if (roughValue == -9999)
                                {
                                    rvOutVistor[0].RasterBandsData[0][i] = -9999f;
                                }
                                else
                                {
                                    float value;
                                    float ref1 = rvInVistor[1].RasterBandsData[0][i] / 10f;
                                    float ref6 = rvInVistor[1].RasterBandsData[1][i] / 10f;

                                    if (isCorrectAngle)
                                    {
                                        float angle = rvInVistor[3].RasterBandsData[0][i] / 100f;
                                        ref1        = CorrectBandValue(angle, ref1);
                                        ref6        = CorrectBandValue(angle, ref6);
                                    }
                                    if (roughValue <= 2000)
                                    {
                                        value = a0 + a1 * ref1 + a2 * ref1 / ref6 + a3 * (ref1 - ref6);
                                        value = value <= 0 ? 0.1f : (value > 50 ? 50 : value);
                                        rvOutVistor[0].RasterBandsData[0][i] = value;
                                    }
                                    else
                                    {
                                        value = b0 + b1 * ref1 + b2 * ref1 / ref6 + b3 * (ref1 - ref6);
                                        value = value <= 0 ? 0.1f : (value > 50 ? 50 : value);
                                        rvOutVistor[0].RasterBandsData[0][i] = value;
                                    }
                                }
                            }
                        }
                    }
                }));
                rfr.Excute();
                IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, depthFileName, true);
                res.SetDispaly(false);
                return(res);
            }
            finally
            {
                if (outRaster != null)
                {
                    outRaster.Dispose();
                }
                if (rms != null && rms.Count > 0)
                {
                    foreach (RasterMaper rm in rms)
                    {
                        if (rm.Raster != null)
                        {
                            rm.Raster.Dispose();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 单文件计算其NDVI
        /// </summary>
        /// <param name="inputFile"></param>
        /// <param name="bandNos"></param>
        /// <param name="zoom"></param>
        /// <param name="aoiTemplate"></param>
        /// <param name="progressTracker"></param>
        /// <returns></returns>
        private IExtractResult CalcNDVI(string inputFile, int[] bandNos, float zoom, double[] CloudyZoom, float[] cloudyArgs, Int16 defCloudy, bool isFitterCloud, bool isAppCloud, string aoiTemplate, Action <int, string> progressTracker)
        {
            //查找输入文件对应的云判识结果文件
            RasterProcessModel <ushort, 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);
                }
                //输出数据(NDVI)
                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;
                outRaster.GetRasterBand(1).Fill(Int16.MinValue);
                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 <ushort, short>(progressTracker);
                rfr.SetRaster(fileIns.ToArray(), fileOuts);
                rfr.SetTemplateAOI(aoiTemplate);
                rfr.RegisterCalcModel(new RasterCalcHandler <ushort, short>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData != null)
                    {
                        if (rvInVistor == null)
                        {
                            return;
                        }
                        ushort[] inBand0  = rvInVistor[0].RasterBandsData[0];                     //第1个输入文件的第1个波段的各像素值
                        ushort[] inBand1  = rvInVistor[0].RasterBandsData[1];                     //第1个输入文件的第2个波段的各像素值
                        ushort[] inBand2  = rvInVistor[0].RasterBandsData[2];                     //第1个输入文件的第3个波段的各像素值
                        ushort[] inBand3  = rvInVistor[0].RasterBandsData[3];                     //第1个输入文件的第4个波段的各像素值
                        ushort[] inBand12 = isAppCloud ? rvInVistor[1].RasterBandsData[0] : null; //第2个输入文件的第1个波段的各像素值
                        short[] ndvi      = new short[inBand0.Length];
                        if (aoi == null || aoi.Length == 0)
                        {
                            for (int index = 0; index < inBand0.Length; index++)
                            {
                                if ((inBand12 != null && inBand12[index] != 0) || (isFitterCloud && inBand1[index] / CloudyZoom[0] > cloudyArgs[0] && inBand3[index] / CloudyZoom[2] < cloudyArgs[1] && Math.Abs(inBand2[index] / CloudyZoom[1] - inBand3[index] / CloudyZoom[2]) > cloudyArgs[2]))
                                {
                                    rvOutVistor[0].RasterBandsData[0][index] = defCloudy;
                                    continue;
                                }
                                //第1个输出文件的第1个波段存储NDVI值
                                rvOutVistor[0].RasterBandsData[0][index] = (short)((inBand1[index] - inBand0[index]) * zoom / (inBand1[index] + inBand0[index]));
                            }
                        }
                        else if (aoi != null && aoi.Length != 0)
                        {
                            int index;
                            for (int i = 0; i < aoi.Length; i++)
                            {
                                index = aoi[i];
                                if ((inBand12 != null && inBand12[index] != 0) || (isFitterCloud && inBand1[index] / CloudyZoom[0] > cloudyArgs[0] && inBand3[index] / CloudyZoom[2] < cloudyArgs[1] && Math.Abs(inBand2[index] / CloudyZoom[1] - inBand3[index] / CloudyZoom[2]) > cloudyArgs[2]))
                                {
                                    rvOutVistor[0].RasterBandsData[0][index] = defCloudy;
                                    continue;
                                }
                                //第1个输出文件的第1个波段存储NDVI值
                                rvOutVistor[0].RasterBandsData[0][index] = (short)((inBand1[index] - inBand0[index]) * zoom / (inBand1[index] + inBand0[index]));
                            }
                        }
                    }
                }));
                //执行
                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 #21
0
        private IExtractResult CalcAnmi(Action <int, string> progressTracker)
        {
            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);
            }
            Int16 defCloudy           = (Int16)_argumentProvider.GetArg("defCloudy");
            Int16 cloudyInvaildResult = Int16.MinValue;
            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                IRasterDataProvider inRaster = RasterDataDriver.Open(ndvi) as IRasterDataProvider;
                if (inRaster.BandCount < ndviCh)
                {
                    PrintInfo("请选择正确的数据进行距平计算。");
                    return(null);
                }
                RasterMaper brm = new RasterMaper(inRaster, new int[] { ndviCh });
                rms.Add(brm);
                IRasterDataProvider iRaster = RasterDataDriver.Open(avg) as IRasterDataProvider;
                if (iRaster.BandCount < avgCH)
                {
                    PrintInfo("请选择正确的数据进行距平计算。");
                    return(null);
                }
                RasterMaper rm = new RasterMaper(iRaster, new int[] { avgCH });
                rms.Add(rm);
                string[] fileNames = new string[] { ndvi, avg };
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri          = GetRasterIdentifyID(fileNames);
                string         outFileName = ri.ToWksFullFileName(".dat");
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <short, short> rfr = null;
                    rfr = new RasterProcessModel <short, short>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    short[] nanValues   = GetNanValues("CloudyValue");
                    short[] waterValues = GetNanValues("WaterValue");
                    rfr.RegisterCalcModel(new RasterCalcHandler <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)
                        {
                            return;
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            Int16 data1 = rvInVistor[0].RasterBandsData[0][index];
                            Int16 data2 = rvInVistor[1].RasterBandsData[0][index];
                            if (VaildRegionAndCloudyProcess.isNanValue(data1, nanValues) ||
                                VaildRegionAndCloudyProcess.isNanValue(data1, waterValues))
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = data1;
                                continue;
                            }
                            if (VaildRegionAndCloudyProcess.isNanValue(data2, nanValues) ||
                                VaildRegionAndCloudyProcess.isNanValue(data2, waterValues))
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = data2;
                                continue;
                            }
                            rvOutVistor[0].RasterBandsData[0][index] = (short)(data1 - data2);
                        }
                    }));
                    //执行
                    rfr.Excute(0);
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                    return(res);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Example #22
0
        /// <summary>
        /// 算法主要计算过程
        /// </summary>
        /// <param name="progressTracker"></param>
        /// <returns>导出文件结果句柄</returns>
        private IExtractResult TNDVIAlgorithm_VSWI(Action <int, string> progressTracker)
        {
            #region 参数
            int NDVIBandCH = (int)_argumentProvider.GetArg("NDVIBand");
            if (NDVIBandCH == -1 || _argumentProvider.GetArg("NDVIFile") == null)
            {
                PrintInfo("NDVI生产所用文件或通道未设置完全,请检查!");
                return(null);
            }
            //NDVI文件
            string[] ndviFileNames = GetStringArray("NDVIFile");

            int TSBandCH = (int)_argumentProvider.GetArg("TSBand");
            if (TSBandCH == -1 || _argumentProvider.GetArg("TSFile") == null)
            {
                PrintInfo("TS生产所用文件或通道未设置完全,请检查!");
                return(null);
            }
            //地表温度文件
            string[] tsFileNames = GetStringArray("TSFile");
            if (ndviFileNames.Length <= 0 || tsFileNames.Length <= 0)
            {
                PrintInfo("未选择有效输入文件!");
                return(null);
            }
            if (!File.Exists(ndviFileNames[0]))
            {
                PrintInfo("NDVI文件不存在!");
                return(null);
            }
            if (!File.Exists(tsFileNames[0]))
            {
                PrintInfo("TS地表温度数据不存在!");
                return(null);
            }
            //NDVI缩放倍数
            double NDVIZoom = (double)_argumentProvider.GetArg("NDVIBand_Zoom");
            //地表温度缩放倍数
            double TSZoom = (double)_argumentProvider.GetArg("TSBand_Zoom");
            //生成结果放大倍数
            double  BandZoom    = (double)_argumentProvider.GetArg("BandZoom");
            Int16[] CloudValues = GetNanValues("CloudyValue");
            Int16   defCloudy   = (Int16)_argumentProvider.GetArg("defCloudy");

            Int16[] WaterValues = GetNanValues("WaterValue");
            Int16   defWater    = (Int16)_argumentProvider.GetArg("defCloudy");

            Int16[] NullValues = GetNanValues("NullValue");
            Int16   defNull    = (Int16)_argumentProvider.GetArg("defNullValue");
            #endregion

            //输入文件准备
            List <RasterMaper>  rasterInputMaps = new List <RasterMaper>();
            IRasterDataProvider ndviPrd         = null;
            IRasterDataProvider tsPrd           = null;
            try
            {
                ndviPrd = RasterDataDriver.Open(ndviFileNames[0]) as IRasterDataProvider;
                if (ndviPrd.BandCount < NDVIBandCH)
                {
                    PrintInfo("请选择正确的NDVI数据进行植被供水指数计算。");
                    return(null);
                }
                RasterMaper rmNdvi = new RasterMaper(ndviPrd, new int[] { NDVIBandCH });
                rasterInputMaps.Add(rmNdvi);
                tsPrd = RasterDataDriver.Open(tsFileNames[0]) as IRasterDataProvider;
                if (tsPrd.BandCount < NDVIBandCH)
                {
                    PrintInfo("请选择正确的Ts地表温度数据进行植被供水指数计算。");
                    return(null);
                }
                RasterMaper rmTs = new RasterMaper(tsPrd, new int[] { NDVIBandCH });
                rasterInputMaps.Add(rmTs);
                //输出文件准备(作为输入栅格并集处理)
                string outFileName            = GetFileName(tsFileNames, _subProductDef.ProductDef.Identify, _identify, ".dat", null);
                IRasterDataProvider outRaster = null;
                try
                {
                    outRaster = CreateOutRaster(outFileName, rasterInputMaps.ToArray());
                    //栅格数据映射
                    RasterMaper[] fileIns = rasterInputMaps.ToArray();
                    RasterMaper[] fileOuts;
                    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) =>
                    {
                        if (rvInVistor[0].RasterBandsData == null || rvInVistor[1].RasterBandsData == null ||
                            rvInVistor[0].RasterBandsData[0] == null || rvInVistor[1].RasterBandsData[0] == null)
                        {
                            return;
                        }
                        int dataLength     = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] ndviValues = rvInVistor[0].RasterBandsData[0];
                        Int16[] tValues    = rvInVistor[1].RasterBandsData[0];
                        for (int index = 0; index < dataLength; index++)
                        {
                            Int16 refValue = 0;
                            //检验输入的云水值
                            if (GetAndCheckRefValue(ndviValues[index], CloudValues, defCloudy, WaterValues, defWater, NullValues, defNull, out refValue) ||
                                GetAndCheckRefValue(tValues[index], CloudValues, defCloudy, WaterValues, defWater, out refValue))
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = refValue;
                            }
                            else if (ndviValues[index] == 0)
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = defNull;
                            }
                            else
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = (Int16)((float)(tValues[index] * NDVIZoom * BandZoom / ndviValues[index] / TSZoom));
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                }
                finally
                {
                    if (outRaster != null)
                    {
                        outRaster.Dispose();
                    }
                }
                FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                res.SetDispaly(false);

                return(res);
            }
            finally
            {
                if (ndviPrd != null)
                {
                    ndviPrd.Dispose();
                }
            }
        }
Example #23
0
        private IFileExtractResult ComputeSnowDepth(string inputFileName, int[] bandNos, string[] argFiles, double[] sdParas)
        {
            List <RasterMaper>  rms                = null;
            IRasterDataProvider outRaster          = null;
            RasterProcessModel <Int16, double> rfr = null;

            try
            {
                rms = new List <RasterMaper>();
                IRasterDataProvider inRaster = GeoDataDriver.Open(inputFileName) as IRasterDataProvider;
                RasterMaper         fileIn   = new RasterMaper(inRaster, bandNos);
                rms.Add(fileIn);
                foreach (string file in argFiles)
                {
                    IRasterDataProvider argRaster = GeoDataDriver.Open(file) as IRasterDataProvider;
                    RasterMaper         argRm     = new RasterMaper(argRaster, new int[] { 1 });
                    rms.Add(argRm);
                }
                string depthFileName = GetFileName(new string[] { inputFileName }, _subProductDef.ProductDef.Identify, "MWSD", ".dat", null);
                outRaster = CreateOutRaster(depthFileName, enumDataType.Double, rms.ToArray(), inRaster.ResolutionX);
                RasterMaper   fileOut  = new RasterMaper(outRaster, new int[] { 1 });
                RasterMaper[] fileIns  = rms.ToArray();
                RasterMaper[] fileOuts = new RasterMaper[] { fileOut };
                rfr = new RasterProcessModel <Int16, double>();
                rfr.SetRaster(fileIns, fileOuts);
                rfr.RegisterCalcModel(new RasterCalcHandler <Int16, double>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData[0] != null && rvInVistor[1].RasterBandsData[0] != null &&
                        rvInVistor[2].RasterBandsData[0] != null && rvInVistor[3].RasterBandsData[0] != null &&
                        rvInVistor[4].RasterBandsData[0] != null)
                    {
                        int dataLength = rvInVistor[0].RasterBandsData[0].Length;
                        int[] type     = new int[dataLength];
                        double[] sdtmp = new double[dataLength];
                        for (int i = 0; i < dataLength; i++)
                        {
                            //type
                            type[i]      = NO_SCATTER;
                            double ch10v = btValue(rvInVistor[0].RasterBandsData[0][i]);
                            double ch10h = btValue(rvInVistor[0].RasterBandsData[1][i]);
                            double ch18v = btValue(rvInVistor[0].RasterBandsData[2][i]);
                            double ch18h = btValue(rvInVistor[0].RasterBandsData[3][i]);
                            double ch23v = btValue(rvInVistor[0].RasterBandsData[4][i]);
                            double ch23h = btValue(rvInVistor[0].RasterBandsData[5][i]);
                            double ch36v = btValue(rvInVistor[0].RasterBandsData[6][i]);
                            double ch36h = btValue(rvInVistor[0].RasterBandsData[7][i]);
                            double ch89v = btValue(rvInVistor[0].RasterBandsData[8][i]);
                            double ch89h = btValue(rvInVistor[0].RasterBandsData[9][i]);
                            double si1   = ch23v - ch89v;
                            double si2   = ch18v - ch36v;
                            if (si1 >= 5 || si2 >= 5)
                            {
                                if (ch23v <= 260)
                                {
                                    if (ch18v - ch36v >= 20)
                                    {
                                        if (si1 - si2 >= WET_FACTOR)
                                        {
                                            type[i] = THICK_DRY_SNOW;
                                        }
                                        else
                                        {
                                            type[i] = THICK_WET_SNOW;
                                        }
                                    }
                                    else
                                    {
                                        if (si1 - si2 >= 8)
                                        {
                                            type[i] = THIN_DRY_SNOW;
                                        }
                                        else
                                        {
                                            if (si1 - si2 <= WET_FACTOR1)
                                            {
                                                type[i] = VERY_THICK_WET_SNOW;
                                            }
                                            else
                                            {
                                                if (ch18v - ch18h <= 6 && ch18v - ch36v >= 10)
                                                {
                                                    type[i] = THIN_WET_SNOW_OR_FOREST_SNOW;
                                                }
                                                else
                                                {
                                                    type[i] = NO_SNOW;
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    type[i] = NO_SNOW;
                                }
                            }
                            else
                            {
                                type[i] = NO_SNOW;
                            }
                            //sdtmp
                            double sdFarmland = sdParas[0] + sdParas[1] * (ch18v - ch36h) + sdParas[2] * (ch89v - ch89h);
                            double sdGrass    = sdParas[3] + sdParas[4] * (ch18h - ch36h) - sdParas[5] * (ch18v - ch18h) + sdParas[6] * (ch10v - ch89h) - sdParas[7] * (ch18v - ch89h);
                            double sdBaren    = sdParas[8] + sdParas[9] * (ch36h - ch89h) - sdParas[10] * (ch10v - ch89v);
                            double sdForest   = sdParas[11] + sdParas[12] * (ch18h - ch36v) - sdParas[13] * (ch18v - ch18h) + sdParas[14] * (ch89v - ch89h);
                            sdtmp[i]          = (rvInVistor[1].RasterBandsData[0][i] * sdBaren +
                                                 rvInVistor[2].RasterBandsData[0][i] * sdGrass +
                                                 rvInVistor[3].RasterBandsData[0][i] * sdForest +
                                                 rvInVistor[4].RasterBandsData[0][i] * sdFarmland) / 10000; //原地类百分比文件扩大了10000倍
                            //设置输出数据值
                            if (type[i] == NO_SNOW || type[i] == THICK_WET_SNOW || type[i] == THIN_WET_SNOW_OR_FOREST_SNOW || type[i] == VERY_THICK_WET_SNOW)
                            {
                                sdtmp[i] = 0.0;
                            }
                            if (sdtmp[i] < 0)
                            {
                                sdtmp[i] = 0;
                            }
                            else
                            {
                                sdtmp[i] = sdtmp[i];
                            }
                            rvOutVistor[0].RasterBandsData[0][i] = sdtmp[i];
                        }
                    }
                    //输出
                }));
                rfr.Excute();
                IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, depthFileName, true);
                res.SetDispaly(false);
                return(res);
            }
            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 #24
0
        public static IExtractResult AVGProcessor(Action <int, string> progressTracker, IContextMessage contextMessage, bool add2Workspace,
                                                  string[] fileNames, int bandNo, string subProIdentify, UInt16[] cloudValues, UInt16[] waterValues, string outFileName)
        {
            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(contextMessage, "请选择正确的数据进行平均值合成。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { bandNo });
                    rms.Add(rm);
                }
                //输出文件准备(作为输入栅格并集处理)
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <ushort, ushort> rfr = null;
                    rfr = new RasterProcessModel <ushort, ushort>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.RegisterCalcModel(new RasterCalcHandler <ushort, ushort>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength     = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        ushort[] sumData   = new ushort[dataLength];
                        ushort[] countData = new ushort[dataLength];
                        if (cloudValues != null && cloudValues.Length > 0)
                        {
                            foreach (RasterVirtualVistor <ushort> rv in rvInVistor)
                            {
                                if (rv.RasterBandsData == null)
                                {
                                    continue;
                                }
                                ushort[] dt = rv.RasterBandsData[0];
                                if (dt != null)
                                {
                                    for (int index = 0; index < dataLength; index++)
                                    {
                                        if (IsNanValue(dt[index], cloudValues) || IsNanValue(dt[index], waterValues))
                                        {
                                            sumData[index] = (sumData[index] == 0 && countData[index] == 0) ? dt[index] : sumData[index];
                                            continue;
                                        }
                                        else
                                        {
                                            if (IsNanValue(sumData[index], cloudValues) ||
                                                IsNanValue(dt[index], waterValues) && countData[index] == 0)
                                            {
                                                sumData[index] = 0;
                                            }
                                            if (dt[index] == 0)
                                            {
                                                continue;
                                            }
                                            sumData[index] += dt[index];
                                            countData[index]++;
                                        }
                                    }
                                }
                            }
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            if (countData[index] != 0)
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = (ushort)(sumData[index] / countData[index]);
                            }
                            else
                            {
                                rvOutVistor[0].RasterBandsData[0][index] = sumData[index];
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    FileExtractResult res = new FileExtractResult(subProIdentify, outFileName, add2Workspace);
                    res.SetDispaly(false);
                    return(res);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Example #25
0
        private IFileExtractResult ComputeSnowSWE(string filenameDensity, string depthFileName)
        {
            List <RasterMaper>  rms                 = null;
            IRasterDataProvider outRaster           = null;
            RasterProcessModel <double, double> rfr = null;

            try
            {
                rms = new List <RasterMaper>();
                IRasterDataProvider inRaster1 = GeoDataDriver.Open(depthFileName) as IRasterDataProvider;
                RasterMaper         fileIn1   = new RasterMaper(inRaster1, new int[] { 1 });
                rms.Add(fileIn1);
                IRasterDataProvider inRaster2 = GeoDataDriver.Open(filenameDensity) as IRasterDataProvider;
                RasterMaper         fileIn2   = new RasterMaper(inRaster2, new int[] { 1 });
                rms.Add(fileIn2);

                string sweFileName = GetFileName(new string[] { depthFileName }, _subProductDef.ProductDef.Identify, "MSWE", ".dat", null);
                outRaster = CreateOutRaster(sweFileName, enumDataType.Double, rms.ToArray(), inRaster2.ResolutionX);
                RasterMaper   fileOut  = new RasterMaper(outRaster, new int[] { 1 });
                RasterMaper[] fileIns  = rms.ToArray();
                RasterMaper[] fileOuts = new RasterMaper[] { fileOut };
                rfr = new RasterProcessModel <double, double>();
                rfr.SetRaster(fileIns, fileOuts);

                rfr.RegisterCalcModel(new RasterCalcHandler <double, double>((rvInVistor, rvOutVistor, aoi) =>
                {
                    if (rvInVistor[0].RasterBandsData[0] != null && rvInVistor[1].RasterBandsData[0] != null)
                    {
                        int dataLength  = rvInVistor[0].SizeY * rvInVistor[0].SizeX;
                        double[] swetmp = new double[dataLength];
                        for (int i = 0; i < dataLength; i++)
                        {
                            swetmp[i] = rvInVistor[0].RasterBandsData[0][i] * rvInVistor[1].RasterBandsData[0][i] * 10;
                            if (swetmp[i] < 0)
                            {
                                swetmp[i] = 0;
                            }
                            rvOutVistor[0].RasterBandsData[0][i] = swetmp[i];
                        }
                    }
                }));
                rfr.Excute();
                IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, sweFileName, true);
                res.SetDispaly(false);
                return(res);
            }
            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 #26
0
        private IExtractResult CompareAlgorithm()
        {
            string[] files = GetStringArray("SelectedPrimaryFiles");
            string   file  = _argumentProvider.GetArg("SelectedPrimaryFiles").ToString();

            if (files == null && string.IsNullOrEmpty(file))
            {
                return(null);
            }
            if (files != null && files.Length < 2)
            {
                return(null);
            }
            if (files == null && !string.IsNullOrEmpty(file))
            {
                string[] fnames = file.Split('*');
                if (fnames != null && fnames.Length > 1)
                {
                    foreach (string item in fnames)
                    {
                        if (!File.Exists(item))
                        {
                            return(null);
                        }
                    }
                    files = fnames;
                }
                else
                {
                    return(null);
                }
            }
            //文件列表排序
            string[]           dstFiles                    = SortFileName(files);
            string             outFileIdentify             = GetStringArgument("OutFileIdentify");
            string             productIdentify             = _subProductDef.ProductDef.Identify;
            ExtractResultArray results                     = new ExtractResultArray(productIdentify + _identify);
            List <IPixelFeatureMapper <Int16> > rasterList = new List <IPixelFeatureMapper <short> >();
            List <RasterIdentify> rstIdentifys             = new List <RasterIdentify>();

            for (int i = 0; i < dstFiles.Length - 1; i++)
            {
                IPixelFeatureMapper <Int16> rasterResult = MakeCompareRaster <float, Int16>(productIdentify, dstFiles[i], dstFiles[i + 1], (fstFileValue, sedFileValue) =>
                {
                    if (fstFileValue == 1f && sedFileValue == 1f)
                    {
                        return(1);
                    }
                    else if (fstFileValue == 0f && sedFileValue == 1f)
                    {
                        return(4);
                    }
                    else if (fstFileValue == 1f && sedFileValue == 0f)
                    {
                        return(5);
                    }
                    else
                    {
                        return(0);
                    }
                }, true);
                if (rasterResult == null)
                {
                    continue;
                }
                rasterList.Add(rasterResult);
                rstIdentifys.Add(new RasterIdentify(new string[] { dstFiles[i], dstFiles[i + 1] }));
            }
            if (rasterList.Count == 0)
            {
                return(null);
            }
            else
            {
                for (int i = 0; i < rasterList.Count; i++)
                {
                    RasterIdentify            rid = GetRasterIdentifyID(rstIdentifys[i]);
                    IInterestedRaster <Int16> iir = new InterestedRaster <Int16>(rid, rasterList[i].Size, rasterList[i].CoordEnvelope, null);
                    iir.Put(rasterList[i]);
                    iir.Dispose();
                    FileExtractResult res = new FileExtractResult(outFileIdentify, iir.FileName);
                    res.SetDispaly(false);
                    results.Add(res);
                }
            }
            return(results);
        }
Example #27
0
        private IExtractResult LAODAlgorithm(Action <int, string> progressTracker)
        {
            IRasterOperator <Int16> roper = new RasterOperator <Int16>();

            string[] files = GetStringArray("SelectedPrimaryFiles");
            if (files == null || files.Length == 0)
            {
                return(null);
            }
            string[] argFileArg  = _argumentProvider.GetArg("RegionFileName") as string[];
            string   argFileName = argFileArg[0];

            if (string.IsNullOrEmpty(argFileName))
            {
                PrintInfo("请设置等级参数文件!");
                return(null);
            }
            SortedDictionary <float, float[]> levelRegions = GetArgFileRegion(argFileName);

            if (levelRegions == null || levelRegions.Count == 0)
            {
                return(null);
            }
            string AODFile = Convert.ToString(_argumentProvider.GetArg("AODFile"));

            if (string.IsNullOrWhiteSpace(AODFile))
            {
                return(null);
            }
            string[] aodFiles = AODFile.Split(new char[] { ',' });
            if (aodFiles.Length != 2)
            {
                return(null);
            }
            string             aodFile        = aodFiles[0];
            int                bandNo         = 1;
            IBandNameRaster    bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int                aodNo          = TryGetBandNo(bandNameRaster, "AODNO");
            List <RasterMaper> rms            = new List <RasterMaper>();

            try
            {
                IRasterDataProvider dblv   = RasterDataDriver.Open(files[0]) as IRasterDataProvider;
                RasterMaper         rmDBLV = new RasterMaper(dblv, new int[] { bandNo });
                rms.Add(rmDBLV);
                IRasterDataProvider aod = RasterDataDriver.Open(aodFile) as IRasterDataProvider;
                if (aod.BandCount < bandNo)
                {
                    PrintInfo("请选择正确的AOD数据进行定量产品计算。");
                    return(null);
                }
                RasterMaper rmAOD = new RasterMaper(aod, new int[] { aodNo });
                rms.Add(rmAOD);
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri          = GetRasterIdentifyID(files);
                string         outFileName = MifEnvironment.GetTempDir() + "\\" + ri.ToWksFileName(".dat");
                bool           isVaild     = false;
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    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.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        for (int index = 0; index < dataLength; index++)
                        {
                            if (rvInVistor[0].RasterBandsData != null && rvInVistor[0].RasterBandsData[0] != null &&
                                rvInVistor[0].RasterBandsData[0][index] != 0)
                            {
                                if (rvInVistor[1].RasterBandsData != null && rvInVistor[1].RasterBandsData[0] != null)
                                {
                                    foreach (float minValue in levelRegions.Keys)
                                    {
                                        if (rvInVistor[1].RasterBandsData[0][index] >= minValue && rvInVistor[1].RasterBandsData[0][index] < levelRegions[minValue][0])
                                        {
                                            rvOutVistor[0].RasterBandsData[0][index] = (Int16)levelRegions[minValue][1];
                                            isVaild = true;
                                        }
                                    }
                                    if (!isVaild)
                                    {
                                        rvOutVistor[0].RasterBandsData[0][index] = (Int16)1;
                                    }
                                    isVaild = false;
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    if (File.Exists(outFileName))
                    {
                        string dstFilename = ri.ToWksFullFileName(".dat");
                        CopyFileToDstDir(outFileName, dstFilename);
                        FileExtractResult res = new FileExtractResult(_subProductDef.Identify, dstFilename, true);
                        res.SetDispaly(false);
                        CreateThemegrahic(dstFilename);
                        return(res);
                    }
                    return(null);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
Example #28
0
        //生成亮温背景库算法
        //云水 怎么处理
        private IExtractResult BackBGFileAlg(Action <int, string> progressTracker)
        {
            //亮温数据放大倍数
            Int16 TBZoom   = Convert.ToInt16(_argumentProvider.GetArg("LBZoom"));
            int   LBBandCH = (int)_argumentProvider.GetArg("LBBand");
            //亮温数据生成的背景库放大倍数
            Int16 TBBackZoom = Convert.ToInt16(_argumentProvider.GetArg("OutLBBackZoom"));

            //亮温输入文件
            string[] tbfiles = GetStringArray("LBFile");

            //NDVI输出文件--根据输入文件信息输出
            string outtbbackfile = GetFileName(tbfiles, _subProductDef.ProductDef.Identify, _identify, ".ldf", null); //默认位置输出

            List <RasterMaper> rasterInputMaps = new List <RasterMaper>();                                            //从配置文件中读取需要待合成ldf数据,此处只有一个ldf文件

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

            try
            {
                //栅格数据映射
                RasterMaper[] fileIns = rasterInputMaps.ToArray();
                RasterMaper[] fileOuts;
                outLBbackRaster = CreateOutLDFRaster(outtbbackfile, rasterInputMaps.ToArray(), 5);
                fileOuts        = new RasterMaper[] { new RasterMaper(outLBbackRaster, new int[] { 1, 2, 3, 4, 5 }) };//输出为固定5个波段数据
                //创建处理模型
                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 maxNDVI      = Int16.MinValue;
                    Int16 minNDVI      = Int16.MinValue;
                    Int16 secmaxNDVI   = Int16.MinValue;
                    Int16 secminNDVI   = Int16.MinValue;
                    double averageNDVI = Int16.MinValue;
                    for (int index = 0; index < dataLength; index++)
                    {
                        List <Int16> listtemp = new List <Int16>();
                        List <Int16> listavg  = new List <short>();
                        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)
                        {
                            maxNDVI     = 0;
                            minNDVI     = 0;
                            secmaxNDVI  = 0;
                            secminNDVI  = 0;
                            averageNDVI = 0;
                        }
                        else
                        {
                            ////这里是否需要考虑有效范围
                            maxNDVI    = listtemp[listtemp.Count - 1];                                                     //最大值 此处文件个数大于1
                            minNDVI    = listtemp[0];                                                                      //最小值 此处文件数大于1
                            secmaxNDVI = listtemp.Count > 1 ? listtemp[listtemp.Count - 2] : listtemp[listtemp.Count - 1]; //次大值
                            secminNDVI = listtemp.Count > 1 ? listtemp[1] : listtemp[0];                                   //次小值
                            //平均值
                            //去除 0
                            averageNDVI = listavg.Where(num => num != 0).Average(num => (int)(num));//平均值
                        }
                        //给输出Raster填值,此处为固定五个波段 并考虑放大倍数的处理
                        rvOutVistor[0].RasterBandsData[0][index] = (Int16)(maxNDVI * TBBackZoom / TBZoom);
                        rvOutVistor[0].RasterBandsData[1][index] = (Int16)(minNDVI * TBBackZoom / TBZoom);
                        rvOutVistor[0].RasterBandsData[2][index] = (Int16)(secmaxNDVI * TBBackZoom / TBZoom);
                        rvOutVistor[0].RasterBandsData[3][index] = (Int16)(secminNDVI * TBBackZoom / TBZoom);
                        rvOutVistor[0].RasterBandsData[4][index] = (Int16)(averageNDVI * TBBackZoom / TBZoom);
                    }
                }));
                rfr.Excute();
                FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outtbbackfile, true);
                res.SetDispaly(false);
                return(res);
            }
            catch (Exception ex)
            {
                PrintInfo("算法处理过程发生异常!\n" + ex.StackTrace);
                return(null);
            }

            finally
            {
                if (outLBbackRaster != null)
                {
                    outLBbackRaster.Dispose();
                }
                if (outLBbackRaster != null)
                {
                    outLBbackRaster.Dispose();
                }
            }
        }
Example #29
0
        /// <summary>
        /// 判识结果保存事件
        /// </summary>
        /// <param name="piexd">判识结果</param>
        /// <param name="progressTracker"></param>
        /// <returns></returns>
        /// 原始影像和判识结果读取到一个结果集中,分为输入输出两个,输出的就是需要保存的结果
        public override IExtractResult MakeExtProduct(IPixelIndexMapper piexd, Action <int, string> progressTracker)
        {
            //生成判识结果文件
            IInterestedRaster <UInt16> iir = null;
            RasterIdentify             id  = new RasterIdentify(_argumentProvider.DataProvider.fileName);

            id.ThemeIdentify      = "CMA";
            id.ProductIdentify    = "FOG";
            id.SubProductIdentify = _identify;
            id.GenerateDateTime   = DateTime.Now;
            iir = new InterestedRaster <UInt16>(id, piexd.Size, piexd.CoordEnvelope);
            int[] idxs = piexd.Indexes.ToArray();
            iir.Put(idxs, 1);
            //原始影像raster
            IRasterDataProvider sourceraster = _argumentProvider.DataProvider as IRasterDataProvider;
            List <RasterMaper>  listRaster   = new List <RasterMaper>();
            RasterMaper         rmsoure      = new RasterMaper(sourceraster, GetBandArray(sourceraster.BandCount));
            RasterMaper         rmpiexd      = new RasterMaper(iir.HostDataProvider, new int[] { 1 });
            int totalbandcount = sourceraster.BandCount;

            listRaster.Add(rmpiexd);
            listRaster.Add(rmsoure);
            try
            {
                string outFileName = GetFileName(new string[] { _argumentProvider.DataProvider.fileName }, _subProductDef.ProductDef.Identify, "SRDA", ".ldf", null);
                using (IRasterDataProvider outRaster = CreateOutM_BandRaster(outFileName, listRaster.ToArray(), totalbandcount))
                {
                    //波段总数

                    RasterMaper[] fileIns  = listRaster.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, GetBandArray(totalbandcount)) };
                    //创建处理模型
                    RasterProcessModel <UInt16, UInt16> rfr = null;
                    rfr = new RasterProcessModel <UInt16, UInt16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.SetFeatureAOI(_argumentProvider.AOIs);
                    rfr.RegisterCalcModel(new RasterCalcHandler <UInt16, UInt16>((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)
                        {
                            return;
                        }
                        // if (_argumentProvider.AOIs == null)
                        for (int index = 0; index < dataLength; index++)
                        {
                            if (rvInVistor[0].RasterBandsData[0][index] == 1)
                            {
                                for (int i = 0; i < totalbandcount; i++)
                                {
                                    rvOutVistor[0].RasterBandsData[i][index] = rvInVistor[1].RasterBandsData[i][index];
                                }
                            }
                        }
                    }
                                                                                 ));
                    //执行
                    rfr.Excute(0);
                }
                string dstfilename = outFileName.Replace(".ldf", ".dat");
                if (File.Exists(dstfilename))
                {
                    File.Delete(dstfilename);
                }
                File.Move(outFileName, dstfilename);
                FileExtractResult res = new FileExtractResult("FOG", dstfilename, true);

                res.SetDispaly(false);
                return(res);
            }
            finally
            {
                iir.Dispose();
                if (File.Exists(iir.FileName))
                {
                    File.Delete(iir.FileName);
                }
            }
        }
Example #30
0
        private IExtractResult LTLREAlgorithm(Action <int, string> progressTracker)
        {
            float  tempratureMin = (float)_argumentProvider.GetArg("TempratureMin");
            double lftrZoom      = (double)_argumentProvider.GetArg("LTFRZoom");
            bool   isChaz        = (bool)_argumentProvider.GetArg("isChaz");
            Int16  maxLst        = (Int16)((isChaz ? tempratureMin : (273 + tempratureMin)) * lftrZoom);

            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);
                }
            }
            int bandNo = 1;
            //输出文件准备(作为输入栅格并集处理)
            RasterIdentify ri          = GetRasterIdentifyID(fileNames);
            string         outFileName = ri.ToWksFullFileName(".dat");
            //输入文件准备
            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);
                }
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    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);
                    Int16[] nanValues     = GetNanValues("CloudyValue");
                    Int16[] waterValues   = GetNanValues("WaterValue");
                    Int16[] invailValues  = GetNanValues("InvailValue");
                    Int16   currTimeValue = 0;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength    = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] timeValue = new Int16[dataLength];
                        for (int i = 0; i < dataLength; i++)
                        {
                            timeValue[i] = 0;
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            foreach (RasterVirtualVistor <Int16> rvs in rvInVistor)
                            {
                                Int16[] dt = rvs.RasterBandsData[0];
                                if (dt == null)
                                {
                                    continue;
                                }
                                if (invailValues.Contains(dt[index]))
                                {
                                    continue;
                                }
                                if (TimeValue(dt[index], nanValues, waterValues, invailValues, timeValue[index], maxLst, out currTimeValue))
                                {
                                    timeValue[index] = currTimeValue;
                                }
                            }
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            rvOutVistor[0].RasterBandsData[0][index] = timeValue[index];
                        }
                    }));
                    //执行
                    rfr.Excute(0);
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }

            _argumentProvider.SetArg("SelectedPrimaryFiles", new string[] { outFileName });
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            return(ThemeGraphyByInstance(instance));
        }