Beispiel #1
0
 public static Dictionary <string, SortedDictionary <string, double> > Stat <T>(
     string rasterFile,
     string templateName,
     Dictionary <string, Func <T, bool> > multiFilter,
     Action <int, string> progressTracker, bool weight, float weightZoom, string vectorTemplate) where T : struct, IConvertible
 {
     if (string.IsNullOrWhiteSpace(templateName))
     {
         RasterStatByRaster stat = new RasterStatByRaster(progressTracker);
         return(stat.Stat <T>(rasterFile, null, multiFilter, weight, weightZoom));
     }
     else if (templateName.Contains("vector"))
     {
         string[] split           = templateName.Split(':');
         string   key             = split[0];
         string   shpFilename     = split[1];
         string   fieldName       = split[2];
         RasterStatByVector <T> v = new RasterStatByVector <T>(progressTracker);
         return(v.CountByVector(rasterFile, shpFilename, fieldName, multiFilter));
     }
     else if (templateName.Contains("raster"))
     {
         string tmpValue = templateName;
         if (templateName.Contains("raster"))
         {
             string[] split = templateName.Split(':');
             tmpValue = split[1];
         }
         RasterStatByRaster stat = new RasterStatByRaster(progressTracker);
         return(stat.Stat <T>(rasterFile, tmpValue, multiFilter, weight, weightZoom, vectorTemplate));
     }
     return(null);
 }
Beispiel #2
0
        public static void totest()
        {
            //RasterStatByVector<short>.test();
            //return;
            string dblv = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\FLD\2013-01-17\栅格产品\FLD_0MIX_洞庭湖流域._FY3A_MERSI_0250M_20120517023500.dat";

            dblv = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\FLD\2013-03-27\栅格产品\FLD_DBLV_FY3A_MERSI_1000M_20120328014000.dat";
            dblv = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\FLD\2013-03-30\栅格产品\FLD_DBLV_FY3B_VIRR_1000M_20120427054500.dat";
            string dblv2 = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\FLD\2013-03-30\栅格产品\FLD_DBLV_FY3B_VIRR_1000M_20120427054500.dat";

            dblv  = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\DST\2013-03-30\栅格产品\DST_DBLV_FY3A_VIRR_1000M_20120322051500.dat";
            dblv2 = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\DST\2013-03-30\栅格产品\DST_DBLV_FY3B_VIRR_1000M_20120427054500.dat";
            dblv  = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\FLD\2013-04-01\栅格产品\FLD_DBLV_洞庭湖流域._FY3A_MERSI_0250M_20120517023500.dat";
            dblv2 = @"E:\Smart\staterror\FLD_DBLV_EOST_MODIS_NULL_20110517025700.dat";
            dblv  = @"E:\Smart\staterror\FLD_DBLV_洞庭湖流域._FY3A_MERSI_0250M_20120624022000.dat";
            dblv2 = @"D:\WorkFolder\Smart二期\1.联机开发@Smart\SMART\bin\Release\Workspace\DST\2013-04-08\栅格产品\DST_VISY_FY3A_VIRR_1000M_20120322051500.dat";
            string[] statf = new string[] { dblv };
            //string vct = "vector:省级行政区域_面.shp:NAME";

            int p = 0;
            Action <int, string> progress = (i, t) =>
            {
                if (p < i)
                {
                    p = i;
                    Console.WriteLine(i + t);
                }
            };
            Dictionary <string, Func <short, bool> > dics = new Dictionary <string, Func <short, bool> >();

            dics.Add("等于1", new Func <short, bool>((t) => { return(t == 1); }));
            dics.Add("等于0", new Func <short, bool>((t) => { return(t == 0); }));

            RasterStatByRaster rsm = new RasterStatByRaster(progress);

            dic3 = rsm.Stat <short>(dblv, "China_XjRaster", dics);

            string vct = "vector:土地利用类型_合并.shp:NAME";

            p    = 0;
            dic2 = RasterStatFactory.Stat <short>(new string[] { dblv, dblv2 }, vct, new Func <short, bool>((t) => { return(t == 1); }), progress, false);

            RasterStatFactory.Stat <short>(dblv, "raster:China_XjRaster", dics, progress);
        }
Beispiel #3
0
 /// <summary>
 /// 单条件,面积及覆盖面积统计
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="rasterFiles"></param>
 /// <param name="templateName">
 /// 如果是矢量:
 /// vector:省级行政区.shp:Name
 /// 如果是栅格:
 /// 直接China_XjRaster|China_LandRaster
 /// 或者
 /// raster:China_XjRaster
 /// raster:China_LandRaster
 /// 如果是空,则代表统计当前区域面积。
 /// </param>
 /// <param name="func"></param>
 /// <param name="progressTracker"></param>
 /// <returns></returns>
 public static SortedDictionary <string, StatAreaItem> Stat <T>(string[] rasterFiles, string templateName, Func <T, bool> func, Action <int, string> progressTracker, bool isCombinSameDay)
 {
     if (templateName.Contains("vector"))
     {
         string[] split           = templateName.Split(':');
         string   key             = split[0];
         string   shpFilename     = split[1];
         string   fieldName       = split[2];
         RasterStatByVector <T> v = new RasterStatByVector <T>(progressTracker);
         return(v.CountByVector(rasterFiles, shpFilename, fieldName, func, isCombinSameDay));
     }
     else
     {
         string value = templateName;
         if (templateName.Contains("raster"))
         {
             string[] split = templateName.Split(':');
             value = split[1];
         }
         RasterStatByRaster rsm = new RasterStatByRaster(progressTracker);
         return(rsm.Stat <T>(rasterFiles, value, func, isCombinSameDay));
     }
 }