private IStatResult CreatStatResultItem(SortedDictionary <float, float> ndviRegions, Dictionary <string, int[]> aoiShengJie, IRasterDataProvider prd, float resultZoom, string productTitle) { StatAnalysisEngine <int> statEngine = new StatAnalysisEngine <int>(); string[] columns = new string[ndviRegions.Count() + 1]; columns[0] = "行政分区"; List <string[]> rows = new List <string[]>(); foreach (KeyValuePair <string, int[]> keyValue in aoiShengJie) { string[] s = new string[ndviRegions.Count() + 1]; s[0] = keyValue.Key; int i = 1; foreach (KeyValuePair <float, float> region in ndviRegions) { columns[i] = "植被指数[" + region.Key.ToString() + "到" + region.Value.ToString() + "]"; s[i] = (CalcTotalArea(prd, keyValue.Value, region.Key * resultZoom, region.Value * resultZoom).ToString()); i++; } rows.Add(s); } string[][] ros = rows.ToArray(); return(new StatResult(productTitle, columns, ros)); }
private void 显示_Click(object sender, EventArgs e) { IStatAnalysisEngine <UInt16> stat = new StatAnalysisEngine <UInt16>(); StatResultItem[] results = stat.StatArea(_fname, "省级行政区划", x => x == 1); //IStatResultWindow window = new frm }
private void 统计行政区划_Click(object sender, EventArgs e) { //fname = @"D:\MAS_Workspace\OutputItem\SandDust\MultiValueGraph\20110615\DST_DBLV_FY3A_VIRR_1000M_DXX_P001_20110430030500.MVG"; IStatAnalysisEngine <UInt16> stat = new StatAnalysisEngine <UInt16>(); StatResultItem[] results = stat.StatArea(_fname, "省级行政区划", x => x == 1); }
private void 分级行政区划_Click(object sender, EventArgs e) { string fname = @"E:\王羽\历史数据\FOG_DBLV_FY3A_MERSI_1000M_20120614005135_20120615005135.dat"; using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider) { StatResultItem[] items = null; IStatAnalysisEngine <UInt16> exe = new StatAnalysisEngine <UInt16>(); items = exe.StatArea(prd, "分级行政区划", (v) => { return(v == 1); }); } }
private StatResultItem[] AreaStat(object aoiObj, Func <Int16, bool> filter, string[] files) { if (files == null || files.Length == 0) { return(null); } IStatAnalysisEngine <Int16> exe = new StatAnalysisEngine <Int16>(); if (aoiObj as Dictionary <string, int[]> != null) { Dictionary <string, int[]> aoi = aoiObj as Dictionary <string, int[]>; List <StatResultItem> items = new List <StatResultItem>(); IRasterDataProvider prd = null; try { prd = GeoDataDriver.Open(files[0]) as IRasterDataProvider; if (aoi == null || aoi.Count == 0) { return(null); } StatResultItem[] item = exe.StatAreaCustom(prd, aoi, filter); if (item != null && item.Length > 0) { items.AddRange(item); } // RasterOperator <Int16> oper = new RasterOperator <Int16>(); int count = oper.Count(prd, null, filter); StatResultItem sri = new StatResultItem(); sri.Name = "整个湖区"; sri.Value = Math.Round(count * BAGStatisticHelper.CalPixelArea(prd.ResolutionX), 3); items.Add(sri); return(items.ToArray()); } catch { throw new ArgumentException("选择的文件:“" + Path.GetFileName(files[0]) + "”无法进行自定义面积统计。"); } finally { if (prd != null) { prd.Dispose(); prd = null; } } } else { return(null); } }
public override IExtractResult Make(Action <int, string> progressTracker) { if (_argumentProvider == null || _argumentProvider.GetArg("AlgorithmName") == null) { return(null); } if (_argumentProvider.GetArg("AlgorithmName").ToString() == "FLLS") { string[] files = GetStringArray("SelectedPrimaryFiles"); if (files == null || files.Count() == 0) { return(null); } foreach (string file in files) { if (!File.Exists(file)) { return(null); } } IRasterOperator <Int16> roper = new RasterOperator <Int16>(); IInterestedRaster <Int16> timeResult = null; DataIdentify di = GetDataIdentify(); timeResult = roper.Times(files, CreatRasterIndetifyId(files, "FLD", "FLLS", di, null, null), (dstValue, srcValue) => { //泛滥水体值==4 if (srcValue == 4) { return(++dstValue); } else { return(dstValue); } }); if (timeResult != null && !string.IsNullOrEmpty(timeResult.FileName) && File.Exists(timeResult.FileName)) { //发生[1,5)次 StatResultItem[] lowResults = null; //发生[5,10)次 StatResultItem[] midResults = null; //发生十次及十次以上 StatResultItem[] highResults = null; IStatAnalysisEngine <Int16> exe = new StatAnalysisEngine <Int16>(); using (IRasterDataProvider prd = timeResult.HostDataProvider) { lowResults = exe.StatArea(prd, "省级行政区+土地利用类型", (srcValue) => { if (srcValue >= 1 && srcValue < 5) { return(true); } else { return(false); } }); if (files.Count() >= 5) { midResults = exe.StatArea(prd, "省级行政区+土地利用类型", (srcValue) => { if (srcValue >= 5 && srcValue < 10) { return(true); } else { return(false); } }); } if (files.Count() >= 10) { highResults = exe.StatArea(prd, "省级行政区+土地利用类型", (srcValue) => { if (srcValue >= 10) { return(true); } else { return(false); } }); } } List <StatResultItem> resultList = new List <StatResultItem>(); if (lowResults != null && lowResults.Count() > 0) { foreach (StatResultItem item in lowResults) { item.Name += "_1-5次"; } resultList.AddRange(lowResults); } if (midResults != null && midResults.Count() > 0) { foreach (StatResultItem item in midResults) { item.Name += "_5-10次"; } resultList.AddRange(midResults); } if (highResults != null && highResults.Count() > 0) { foreach (StatResultItem item in midResults) { item.Name += "_10次以上"; } resultList.AddRange(highResults); } FileExtractResult fileResult = null; if (resultList != null && resultList.Count() > 0) { string filename = StatResultToFile(files, resultList.ToArray(), "FLD", "FLLS", "水情泛滥历时面积", null); fileResult = new FileExtractResult("FLLS", filename); } timeResult.Dispose(); File.Delete(timeResult.FileName); return(fileResult); } return(null); } return(null); }