예제 #1
0
        private static ArgumentItem ReadFileParaParas(XElement pNode, string nodeName)
        {
            XElement fileParaRoot = ReadXElement(pNode, nodeName);

            if (fileParaRoot == null)
            {
                return(null);
            }
            ArgumentItem filePara = new ArgumentItem();
            string       str      = ReadAttributeValue(fileParaRoot, "max");

            if (!string.IsNullOrEmpty(str))
            {
                filePara.Max = int.Parse(str);
            }
            str = ReadAttributeValue(fileParaRoot, "min");
            if (!string.IsNullOrEmpty(str))
            {
                filePara.Min = int.Parse(str);
            }
            filePara.Band    = GetIntXElementValue(fileParaRoot, "Band");
            filePara.Zoom    = GetIntXElementValue(fileParaRoot, "Zoom");
            filePara.Cloudy  = GetIntXElementValue(fileParaRoot, "Cloudy");
            filePara.Invaild = GetIntArrayXElementValue(fileParaRoot, "Invaild");
            return(filePara);
        }
예제 #2
0
        private static DryWetEdgeArgs DryWetEdgesArgsCalc(TVDIUCArgs ucArgs, NdviList[] NDVIHistograms)
        {
            List <Samples> minData    = new List <Samples>();
            List <Samples> maxData    = new List <Samples>();
            TVDIParaClass  tvdiP      = ucArgs.TVDIParas;
            ArgumentItem   ndviArgs   = tvdiP.NdviFile;
            int            ndviCloudy = ndviArgs.Cloudy;
            ArgumentItem   lstArgs    = tvdiP.LstFile;

            try
            {
                int rangeSize = (int)Math.Ceiling((double)(ndviArgs.Max - ndviArgs.Min) / tvdiP.Length);//区间个数
                if (rangeSize == 0)
                {
                    return(null);
                }
                int   key    = 0;
                float minLst = 0;
                float maxLst = 0;
                for (int rangeIndex = 0; rangeIndex < rangeSize; rangeIndex++)//每个步长区间,0~step;step~step*rangeIndex;step
                {
                    key = (int)(ndviArgs.Min + tvdiP.Length * rangeIndex - (-1000));
                    if (key >= NDVIHistograms.Length || NDVIHistograms[key] == null)
                    {
                        continue;
                    }
                    if (NDVIHistograms[key].Ndvi == ndviCloudy || NDVIHistograms[key].Ndvi == 0)
                    {
                        continue;
                    }
                    if (!ValidValueHelper.IsVaild(key, ndviArgs))
                    {
                        continue;
                    }
                    if (NDVIHistograms[key].Lst == null || NDVIHistograms[key].Lst.Count == 0)
                    {
                        continue;
                    }
                    NDVIHistograms[key].Lst.Sort();
                    NdviLstPCStat(NDVIHistograms[key].Lst, out minLst, out maxLst, ucArgs.TVDIParas.LstFile, tvdiP.LstFreq);
                    if (minLst == 0 && maxLst == 0)
                    {
                        continue;
                    }
                    minData.Add(new Samples(NDVIHistograms[key].Ndvi, minLst));
                    maxData.Add(new Samples(NDVIHistograms[key].Ndvi, maxLst));
                }
                GC.Collect();
                return(NihePara(maxData, minData, tvdiP.FLimit, tvdiP.HGYZ));
            }
            finally
            {
            }
        }
예제 #3
0
        private static DryWetEdgeArgs DryWetEdgesArgsCalc(TVDIUCArgs ucArgs, Dictionary <float, List <float> > NDVIHistograms)
        {
            List <Samples> minData  = new List <Samples>();
            List <Samples> maxData  = new List <Samples>();
            TVDIParaClass  tvdiP    = ucArgs.TVDIParas;
            ArgumentItem   ndviArgs = tvdiP.NdviFile;
            ArgumentItem   lstArgs  = tvdiP.LstFile;

            try
            {
                int rangeSize = (int)Math.Ceiling((double)(ndviArgs.Max - ndviArgs.Min) / tvdiP.Length);//区间个数
                if (rangeSize == 0)
                {
                    return(null);
                }
                float key    = 0;
                float minLst = 0;
                float maxLst = 0;
                for (int rangeIndex = 0; rangeIndex < rangeSize; rangeIndex++) //每个步长区间,0~step;step~step*rangeIndex;step
                {
                    key = (float)(ndviArgs.Min + tvdiP.Length * rangeIndex);   // / ndviArgs.Zoom;

                    if (!NDVIHistograms.ContainsKey(key))
                    {
                        continue;
                    }
                    if (key == 0 || !ValidValueHelper.IsVaild(key, ndviArgs))
                    {
                        continue;
                    }
                    if (NDVIHistograms[key] == null || NDVIHistograms[key].Count == 0)
                    {
                        continue;
                    }
                    NDVIHistograms[key].Sort();
                    minLst = 0;
                    maxLst = 0;
                    NdviLstPCStat(NDVIHistograms[key], out minLst, out maxLst, ucArgs.TVDIParas.LstFile, tvdiP.LstFreq);
                    if (minLst == 0 && maxLst == 0)
                    {
                        continue;
                    }
                    minData.Add(new Samples(key * ndviArgs.Zoom, minLst * lstArgs.Zoom));
                    maxData.Add(new Samples(key * ndviArgs.Zoom, maxLst * lstArgs.Zoom));
                }
                GC.Collect();
                return(NihePara(maxData, minData, ndviArgs, tvdiP.LstFile, tvdiP.FLimit, tvdiP.HGYZ));
            }
            finally
            {
            }
        }
예제 #4
0
        private static void WriteArgumentItem(XmlNode pNode, string nodeName, ArgumentItem filePara)
        {
            if (filePara == null)
            {
                return;
            }
            XmlNode fileParaRoot = WriteNode(pNode, nodeName, string.Empty);

            WriteAttribue(fileParaRoot, "max", filePara.Max.ToString());
            WriteAttribue(fileParaRoot, "min", filePara.Min.ToString());
            WriteNode(fileParaRoot, "Band", filePara.Band.ToString());
            WriteNode(fileParaRoot, "Zoom", filePara.Zoom.ToString());
            WriteNode(fileParaRoot, "Invaild", filePara.Invaild);
            WriteNode(fileParaRoot, "Cloudy", filePara.Cloudy.ToString());
        }
예제 #5
0
 internal static bool IsVaild(float key, ArgumentItem argItem)
 {
     if (key == (float)argItem.Cloudy / argItem.Zoom)
     {
         return(false);
     }
     if (argItem.Invaild != null && argItem.Invaild.Length != 0)
     {
         foreach (int item in argItem.Invaild)
         {
             if (key == (float)item / argItem.Zoom)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #6
0
        private static DryWetEdgeArgs NihePara(List <Samples> maxData, List <Samples> minData, ArgumentItem ndviArgItem, ArgumentItem lstArgItem, float fLimit, float hgYZ)
        {
            double aMin = 0, aMax = 0, bMin = 0, bMax = 0;
            double fEigenValue = 0;

            MathHelper.MethodOfLeastSquares(minData, out aMin, out bMin, out fEigenValue);
            if (!CalcAB(ref minData, ref aMin, ref bMin, ref fEigenValue, fLimit, hgYZ))
            {
                return(null);
            }
            if (aMin == 0 && bMin == 0)
            {
                return(null);
            }
            MathHelper.MethodOfLeastSquares(maxData, out aMax, out bMax, out fEigenValue);
            if (!CalcAB(ref maxData, ref aMax, ref bMax, ref fEigenValue, fLimit, hgYZ))
            {
                return(null);
            }
            if (aMax == 0 && bMax == 0)
            {
                return(null);
            }
            return(new DryWetEdgeArgs(aMin, aMax, bMin, bMax));
        }
예제 #7
0
        private static void NdviLstPCStat(List <float> ndviList, out float minLst, out float maxLst, ArgumentItem lstArgItem, int LstFreq)
        {
            minLst = maxLst = 0;
            int                     length     = ndviList.Count;
            List <float>            resultTemp = new List <float>();
            Dictionary <float, int> freqDic    = new Dictionary <float, int>();
            bool                    isEnough   = false;

            for (int i = 0; i < length; i++)
            {
                if (!ValidValueHelper.IsVaild(ndviList[i], lstArgItem))
                {
                    continue;
                }
                if (!freqDic.ContainsKey(ndviList[i]))
                {
                    freqDic.Add(ndviList[i], 0);
                }
                freqDic[ndviList[i]] += 1;
                if (!isEnough && freqDic[ndviList[i]] > LstFreq)
                {
                    minLst   = ndviList[i];
                    isEnough = true;
                }
                if (freqDic[ndviList[i]] > LstFreq)
                {
                    maxLst = ndviList[i];
                }
            }
        }
예제 #8
0
        private static void NdviLstPCStat(List <Int16> ndviList, out float minLst, out float maxLst, ArgumentItem lstArgItem, int LstFreq)
        {
            minLst = maxLst = 0;
            int          length = ndviList.Count;
            List <float> resultTemp = new List <float>();
            bool         isEnough = false;
            int          start = lstArgItem.Min, end = lstArgItem.Max;

            Int16[] result = new short[end - start + 1];
            int     index  = 0;

            for (int i = 0; i < length; i++)
            {
                if (ndviList[i] == 9000 || ndviList[i] == 9998 ||
                    ndviList[i] == 9997 || ndviList[i] == 9999)
                {
                    continue;
                }
                if (!ValidValueHelper.IsVaild(ndviList[i], lstArgItem))
                {
                    continue;
                }
                index = ndviList[i] - start;
                if (index < 0 || index >= result.Length)
                {
                    continue;
                }
                result[index] += 1;
                if (!isEnough && result[index] > LstFreq)
                {
                    minLst   = ndviList[i];
                    isEnough = true;
                }
                if (result[index] > LstFreq)
                {
                    maxLst = ndviList[i];
                }
            }
        }
예제 #9
0
        public static bool DoElevationCorrections(TVDIUCArgs ucArgs, ref string error)
        {
            if (string.IsNullOrEmpty(ucArgs.LSTFile) || string.IsNullOrEmpty(ucArgs.DEMFile) || ucArgs.TVDIParas == null || ucArgs.TVDIParas.LstFile == null)
            {
                error = "陆表高温高程订正所需数据或参数设置不全.";
                return(false);
            }

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

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

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

            IInterestedRaster <float> iir = null;

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

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