Пример #1
0
        public static void GetMatchedRasterValues(string[] rasterfiles, int bandNum, string[] fillValueStrRst, List <ShapePoint> matchedpos, out double[][] rasterdata)
        {
            rasterdata = null;
            int width  = matchedpos.Count;
            int length = rasterfiles.Length;

            Double[] fillValuesRst = null;
            fillValuesRst = CloudParaFileStatics.GetFillValues <Double>(fillValueStrRst, enumDataType.Double);
            rasterdata    = new double[length][];
            double[] matchedRasterValues = new double[width];
            for (int lr = 0; lr < length; lr++)
            {
                matchedRasterValues = GetMatchedRasterValues(rasterfiles[lr], bandNum, matchedpos.ToArray());
                double alue;
                for (int i = 0; i < width; i++)
                {
                    alue = matchedRasterValues[i];
                    if (fillValuesRst != null && fillValuesRst.Contains(alue))
                    {
                        matchedRasterValues[i] = 0;
                    }
                }
                rasterdata[lr] = matchedRasterValues;
            }
        }
Пример #2
0
        /// <summary>
        /// 相关系数计算对应micaps点抽取栅格数据,存在多个数据则该点平均
        /// </summary>
        /// <param name="rasterfiles"></param>
        /// <param name="bandNum"></param>
        /// <param name="fillValueStrRst"></param>
        /// <param name="micapsFiles"></param>
        /// <param name="mbandNo"></param>
        /// <param name="fillValuestr"></param>
        /// <param name="envelope"></param>
        /// <param name="rasterdata"></param>
        /// <param name="micapsdata"></param>
        /// <param name="scL"></param>
        /// <param name="scR"></param>
        public static void GetMatchedValues(string[] rasterfiles, int bandNum, string [] fillValueStrRst, string[] micapsFiles, int mbandNo, string [] fillValuestr, PrjEnvelope envelope, out double[] rasterdata, out double[] micapsdata, out long scL, out long scR)
        {
            rasterdata = null;
            micapsdata = null;
            scL        = 0; scR = 0;
            Envelope dstEnv = GetInterectEnv(rasterfiles, envelope);

            if (dstEnv == null || dstEnv.Width == 0 || dstEnv.Height == 0)
            {
                throw new ArgumentNullException("待分析区域为空,请确认自定义区域范围或数据文件范围!");
            }
            #region 获取micaps数据
            Dictionary <string, ShapePoint>     unionStationPos;
            Dictionary <string, List <string> > unionStationValues;//站点编号,数据索引号,数据值
            GetUnionStationValues(micapsFiles, mbandNo, fillValuestr, dstEnv, out unionStationPos, out unionStationValues);
            if (unionStationPos.Count < 1)
            {
                throw new ArgumentException("指定的Micaps数据不包含站点数据!");
            }
            double        staValue;
            List <double> micapsdatalist = new List <double>();
            foreach (List <string> list in unionStationValues.Values)
            {
                double sum   = 0;
                int    count = 0;
                foreach (string str in list)//list为所有站点非填充值的值的集合,
                {
                    if (double.TryParse(str, out staValue))
                    {
                        sum += staValue;
                        count++;
                        scR++;
                    }
                }
                if (count != 0)
                {
                    micapsdatalist.Add(sum / count);//有效平均
                }
                else
                {
                    micapsdatalist.Add(0);//无效填0
                }
            }
            micapsdata = micapsdatalist.ToArray();
            #endregion
            #region 获取栅格对应点的数据
            int      matchedcount  = micapsdatalist.Count;
            Double[] fillValuesRst = null;
            fillValuesRst = CloudParaFileStatics.GetFillValues <Double>(fillValueStrRst, enumDataType.Double);
            rasterdata    = new double[matchedcount];
            double[] summatchedRasterValues = new double[matchedcount];
            int[]    sumRasterCounts        = new int[matchedcount];
            foreach (string rasterf in rasterfiles)
            {
                rasterdata = GetMatchedRasterValues(rasterf, bandNum, unionStationPos.Values.ToArray());
                double alue;
                for (int i = 0; i < matchedcount; i++)
                {
                    alue = rasterdata[i];
                    if (fillValuesRst == null || !fillValuesRst.Contains(alue))
                    {
                        summatchedRasterValues[i] += alue;
                        sumRasterCounts[i]++;
                        scL++;
                    }
                }
            }
            for (int i = 0; i < matchedcount; i++)
            {
                if (sumRasterCounts[i] != 0)
                {
                    rasterdata[i] = summatchedRasterValues[i] / sumRasterCounts[i];
                }
                else
                {
                    rasterdata[i] = 0;
                }
            }
            #endregion
        }