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); }
private void AngleMosaicToFile() { int length = inArg.MosaicEnvelopes.Length; DataIdentify di = DataIdentifyMatcher.Match(GetFirstname(inArg.InputFilename)); for (int i = 0; i < length; i++) { string tFilename = GetSpliceFilename(inArg.MosaicResoultionX, di, inArg, inArg.MosaicEnvelopes[i].Name); AngleMosaic.Mosaic(new string[] { inArg.InputFilename, inArg.OutputDir + "\\" + tFilename, inArg.MosaicBands, GetGeoHeadInfo(inArg.MosaicEnvelopes[i]), inArg.MosaicIdentify }); } }
private void UpdateFileItemsAddToList(string[] files, bool checkTime, DateTime beginTime, DateTime endTime) { lstFileInfoList.Items.Clear(); RasterIdentify rid = null; FileListItem fli = null; if (checkTime) { foreach (string file in files) { DataIdentify di = DataIdentifyMatcher.Match(Path.GetFileName(file)); rid = new RasterIdentify(); rid.OriFileName = new string[] { file }; rid.Satellite = di.Satellite; rid.Sensor = di.Sensor; rid.OrbitDateTime = di.OrbitDateTime; FillRid(ref rid); if (rid.OrbitDateTime == DateTime.MinValue || rid.OrbitDateTime > Convert.ToDateTime(endTime.ToString("MM-dd-yyyy") + " 23:59:59") || rid.OrbitDateTime < Convert.ToDateTime(beginTime.ToString("MM-dd-yyyy") + " 00:00:00")) { continue; } fli = new FileListItem(file, rid); AddToFileListItem(fli); } } else { foreach (string file in files) { DataIdentify di = DataIdentifyMatcher.Match(Path.GetFileName(file)); rid = new RasterIdentify(); rid.OriFileName = new string[] { file }; rid.Satellite = di.Satellite; rid.Sensor = di.Sensor; rid.OrbitDateTime = di.OrbitDateTime; FillRid(ref rid); fli = new FileListItem(file, rid); AddToFileListItem(fli); } } if (lstFileInfoList.Items.Count != 0) { lstFileInfoList.Items[0].Selected = true; } }
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); }
/* *分卫星 传感器 *日信息:卫星_传感器_年_季_月_旬_日_时间起_时间止 *旬信息: 卫星_传感器_年_季_月_旬_时间起_时间止 *月信息:卫星_传感器_年_季_月_时间起_时间止 * 季信息:卫星_传感器_年_季_时间起_时间止 * 年信息:卫星_传感器_年_时间起_时间止 * * 周信息:卫星_传感器_年_周_时间起_时间止 */ public static CYCAFileListInfo GeneralFileList(string[] files, RegionArg args, SubProductDef subPro, string outSubProIdentify) { CYCAFileListInfo result = new CYCAFileListInfo(); GetMaxCyctime(args, ref result); if (result.Days001Files == null) { return(null); } DataIdentify di = null; string fileInfo = string.Empty; RasterIdentify ri = null; foreach (string file in files) { di = DataIdentifyMatcher.Match(file); string days001file = AddDays001FilesInfo(ref result, di, args, subPro, file, out ri, out fileInfo, outSubProIdentify); if (result.Days007Files != null && !string.IsNullOrEmpty(days001file)) { AddDays007FilesInfo(ref result, ri, args, subPro, days001file, fileInfo); } string days010file = string.Empty; if (result.Days010Files != null && !string.IsNullOrEmpty(days001file)) { days010file = AddDays010FilesInfo(ref result, ri, args, subPro, days001file, ref fileInfo); } string days030file = string.Empty; if (result.Days030Files != null && !string.IsNullOrEmpty(days010file)) { days030file = AddDays030FilesInfo(ref result, ri, args, subPro, days010file, ref fileInfo); } string days090file = string.Empty; if (result.Days090Files != null && !string.IsNullOrEmpty(days030file)) { days090file = AddDays090FilesInfo(ref result, ri, args, subPro, days030file, ref fileInfo); } string days365file = string.Empty; if (result.Days365Files != null && !string.IsNullOrEmpty(days090file)) { days365file = AddDays365FilesInfo(ref result, ri, args, subPro, days090file, ref fileInfo); } } return(result); }
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); }
private void UpdateOutPutFilename(string inFilename) { string filename = Path.GetFileNameWithoutExtension(inFilename); DataIdentify df = DataIdentifyMatcher.Match(inFilename); string[] names = filename.Split('_'); if (names.Length > 8) { names[2] = "GLL"; } string newFilename = names[0]; for (int i = 1; i < names.Length; i++) { string name = names[i]; newFilename = newFilename + "_" + name; } string filenameExt = ".LDF"; textBox3.Text = Path.Combine(Path.GetDirectoryName(inFilename), newFilename + filenameExt); }
private void TryGetBandProviderDefinition(string fname, Dictionary <string, string> subdatasets) { List <string> datasetNames = null; if (subdatasets != null) { datasetNames = GetDatasetNames(subdatasets); } BandProviderDef[] bandProviderDefs = null; //Console.WriteLine(this.GetType().Assembly.Location); string configfile = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), "GeoDo.RSS.DF.GDAL.H4BandPrd.xml"); using (H4BandProviderXmlParser xml = new H4BandProviderXmlParser(configfile)) { bandProviderDefs = xml.GetBandProviderDefs(); } if (bandProviderDefs == null) { return; } string dayornight = ""; using (Hdf4Operator hdf = new Hdf4Operator(fname)) { foreach (BandProviderDef prddef in bandProviderDefs) { bool isMatched = true; if (datasetNames != null) { foreach (DefaultBandDatasetDef bandDef in prddef.DefaultBandDatasetDefs) { if (!datasetNames.Contains(bandDef.Name)) { isMatched = false; break; } } if (!isMatched) { continue; } } foreach (IdentifyAttDef id in prddef.IdentifyAttDefs) { string attvalue = hdf.GetAttributeValue(id.Name); if (attvalue != id.Value) { isMatched = false; break; } } //增加对网站下载MODIS数据的支持,数据未在属性中定义卫星、传感器信息 if (!isMatched) { DataIdentify di = DataIdentifyMatcher.Match(fname); if (di != null && !string.IsNullOrEmpty(di.Satellite)) { foreach (IdentifyAttDef id in prddef.IdentifyAttDefs) { if (di.Satellite.ToUpper() == id.Value.ToUpper()) { isMatched = true; break; } } } } if (isMatched) { _matchedBandProviderDef = prddef; break; } } dayornight = TryGetDayOrnight(hdf); } if (_matchedBandProviderDef != null) { _dataIdentify = new DataIdentify(_matchedBandProviderDef.Satellite, _matchedBandProviderDef.Sensor); _dataIdentify.IsOrbit = true; TrySetIdentifyByName(fname); TryGetOrbitDirection(dayornight, _matchedBandProviderDef.Satellite); } }