private FireAreaFeature UpdateFireAreaFeature(FireAreaFeature faf, PixelFeature pixelFeature, IRasterDataProvider prd) { int row = pixelFeature.PixelIndex / prd.Width; int col = pixelFeature.PixelIndex - row * prd.Width; //faf.FireReaIndex = pixelFeature.FireAreaNum; //faf.Longitude = (float)(prd.CoordEnvelope.MinX + col * prd.ResolutionX); //faf.Latitude = (float)(prd.CoordEnvelope.MaxY - row * prd.ResolutionY); faf.FireArea += pixelFeature.PixelArea; faf.SecondryFireArea += pixelFeature.SecondPixelArea; //faf.XJName = _xianJieDictionary.GetPixelName(faf.Longitude, faf.Latitude); faf.FireCount += 1; string solidType = _landTypeDictionary.GetPixelName(faf.Longitude, faf.Latitude); if (solidType.IndexOf("草地") != -1) { faf.GrasslandCount += 1; } else if (solidType.IndexOf("林地") != -1) { faf.WoodlandCount += 1; } else if (solidType.IndexOf("耕地") != -1) { faf.FarmlandCount += 1; } else { faf.OtherCount += 1; } faf.FarmlandPercent = (float)faf.FarmlandCount / faf.FireCount; faf.WoodlandPercent = (float)faf.WoodlandCount / faf.FireCount; faf.GrasslandPercent = (float)faf.GrasslandCount / faf.FireCount; faf.OtherPercent = (float)faf.OtherCount / faf.FireCount; //环保部新增字段 if (faf.FireIndeies == null) { faf.FireIndeies = new List <int>(); } if (!faf.FireIndeies.Contains(pixelFeature.PixelIndex)) { faf.FireIndeies.Add(pixelFeature.PixelIndex); } int code = _xianJieDictionary.GetCode(faf.Longitude, faf.Latitude); faf.SJName = _xianJieDictionary.GetPixelName((int)(Math.Floor(code / 10000f) * 10000)); faf.ShiName = _xianJieDictionary.GetPixelName((int)(Math.Floor(code / 100f) * 100)); if (!string.IsNullOrEmpty(faf.ShiName)) { faf.ShiName = string.IsNullOrEmpty(faf.SJName) ? faf.ShiName : faf.ShiName.Replace(faf.SJName, ""); } return(faf); }
private void button5_Click(object sender, EventArgs e) { IRasterDictionaryTemplate <int> temp = RasterDictionaryTemplateFactory.GetXjRasterTemplate(); aoi = temp.GetAOI("北京市", 114, 124, 36, 46, new Size(1000, 1000)); //temp.CodeNameParis name = temp.GetPixelName(114d, 39d); }
private Dictionary <string, FireAreaInfo> StatPriviceArea(string[] plstFiles) { Dictionary <string, FireAreaInfo> statArea = new Dictionary <string, FireAreaInfo>(); using (IRasterDictionaryTemplate <int> xianJieDictionary = RasterDictionaryTemplateFactory.CreateXjRasterTemplate()) { foreach (string file in plstFiles) { string[] lines = File.ReadAllLines(file); foreach (string line in lines) { string[] infos = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (infos != null && infos.Length == 12) { //按行进行统计 //前两位为省标识 float pixelArea, fireRate; if (!float.TryParse(infos[6], out pixelArea) || !float.TryParse(infos[7], out fireRate)) { continue; } string privice = infos[4].Substring(0, 2); int priviceNum; if (!int.TryParse(privice, out priviceNum) || infos[4].Trim() == "0") { if (statArea.ContainsKey("其他")) { statArea["其他"].PixelCount++; statArea["其他"].PixelArea += pixelArea; statArea["其他"].FireArea += fireRate * pixelArea; } else { statArea.Add("其他", new FireAreaInfo(1, pixelArea, fireRate * pixelArea)); } } else { priviceNum = priviceNum * 10000; privice = xianJieDictionary.GetPixelName(priviceNum); if (statArea.ContainsKey(privice)) { statArea[privice].PixelCount++; statArea[privice].PixelArea += pixelArea; statArea[privice].FireArea += fireRate * pixelArea; } else { statArea.Add(privice, new FireAreaInfo(1, pixelArea, fireRate * pixelArea)); } } } } } return(statArea); } }
private Dictionary <string, FireAreaInfo> StatUseTypeArea(string[] plstFiles) { Dictionary <string, FireAreaInfo> statArea = new Dictionary <string, FireAreaInfo>(); using (IRasterDictionaryTemplate <byte> landTypeDictionary = RasterDictionaryTemplateFactory.CreateLandRasterTemplate()) { foreach (string file in plstFiles) { string[] lines = File.ReadAllLines(file); foreach (string line in lines) { string[] infos = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (infos != null && infos.Length == 12) { //按行进行统计 //前两位为省标识 string useType = infos[5].Trim(); float pixelArea, fireRate; if (!float.TryParse(infos[6], out pixelArea) || !float.TryParse(infos[7], out fireRate)) { continue; } if (useType == "0") { if (statArea.ContainsKey("其他")) { statArea["其他"].PixelCount++; statArea["其他"].PixelArea += pixelArea; statArea["其他"].FireArea += fireRate * pixelArea; } else { statArea.Add("其他", new FireAreaInfo(1, pixelArea, fireRate * pixelArea)); } } else { Byte useTypeNum = Byte.Parse(useType); useType = landTypeDictionary.GetPixelName(useTypeNum); if (statArea.ContainsKey(useType)) { statArea[useType].PixelCount++; statArea[useType].PixelArea += pixelArea; statArea[useType].FireArea += fireRate * pixelArea; } else { statArea.Add(useType, new FireAreaInfo(1, pixelArea, fireRate * pixelArea)); } } } } } return(statArea); } }
private Dictionary <string, FireAreaInfo> StatCountyArea(string[] plstFiles) { Dictionary <string, FireAreaInfo> statArea = new Dictionary <string, FireAreaInfo>(); IRasterDictionaryTemplate <int> xianJieDictionary = RasterDictionaryTemplateFactory.CreateXjRasterTemplate(); foreach (string file in plstFiles) { string[] lines = File.ReadAllLines(file); foreach (string line in lines) { string[] infos = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (infos != null && infos.Length == 12) { //按行进行统计 //前两位为省标识 string county = infos[4].Trim(); float pixelArea, fireRate; if (!float.TryParse(infos[6], out pixelArea) || !float.TryParse(infos[7], out fireRate)) { continue; } if (county == "0") { if (statArea.ContainsKey("其他")) { statArea["其他"].PixelCount++; statArea["其他"].PixelArea += pixelArea; statArea["其他"].FireArea += fireRate * pixelArea; } else { statArea.Add("其他", new FireAreaInfo(1, pixelArea, fireRate * pixelArea)); } } else { int countyNum = Int32.Parse(county); county = xianJieDictionary.GetPixelName(countyNum); if (statArea.ContainsKey(county)) { statArea[county].PixelCount++; statArea[county].PixelArea += pixelArea; statArea[county].FireArea += fireRate * pixelArea; } else { statArea.Add(county, new FireAreaInfo(1, pixelArea, fireRate * pixelArea)); } } } } } return(statArea); }
private unsafe void PrintPixelInfo(PixelInfo pixelInfo) { _sb.Clear(); // ICanvasViewer v = _session.SmartWindowManager.ActiveViewer as ICanvasViewer; if (v == null) { return; } IRasterDrawing drawing = v.ActiveObject as IRasterDrawing; int bandCount = drawing.BandCount; if (txtOriginChannels.Checked || txtSelectChannels.Checked) { fixed(double *ptr = bandValues) { //Stopwatch sw1 = new Stopwatch(); //sw1.Start(); drawing.ReadPixelValues(pixelInfo.RasterX, pixelInfo.RasterY, ptr); //sw1.Stop(); //Console.WriteLine("read data:" +sw1.ElapsedMilliseconds.ToString()); } } int[] selectedBandNos = drawing.SelectedBandNos; // _sb.AppendLine("-------------------------------"); // if (txtSecondaryInfo.Checked) { _sb.AppendLine("辅助信息"); if (drawing.DataProviderCopy.CoordType != enumCoordType.Raster) { if (_landTypeDictionary != null) { _sb.AppendLine(string.Format(ITEM_EXTAND_INFO, "土地利用类型", _landTypeDictionary.GetPixelName(pixelInfo.GeoX, pixelInfo.GeoY))); } if (_xianJieDictionary != null) { _sb.AppendLine(string.Format(ITEM_EXTAND_INFO, "行政区划", _xianJieDictionary.GetPixelName(pixelInfo.GeoX, pixelInfo.GeoY))); } } } // if (txtCoordInfo.Checked) { _sb.AppendLine("坐标信息"); _sb.AppendLine(string.Format(ITEM_SCREEN_COORD, pixelInfo.ScreenX, pixelInfo.ScreenY)); _sb.AppendLine(string.Format(ITEM_RASTER_COORD, pixelInfo.RasterX, pixelInfo.RasterY)); _sb.AppendLine(string.Format(ITEM_PRJ_COORD, pixelInfo.PrjX.ToString("0.##"), pixelInfo.PrjY.ToString("0.##"))); if (rd10DecimalDegree.Checked) { _sb.AppendLine(string.Format(ITEM_GEO_COORD, pixelInfo.GeoX.ToString("0.####"), pixelInfo.GeoY.ToString("0.####"))); } else { _sb.AppendLine(string.Format(ITEM_GEO_COORD, DegreeToString(pixelInfo.GeoX), DegreeToString(pixelInfo.GeoY))); } } // if (txtSelectChannels.Checked) { Color rgb = drawing.GetColorAt(pixelInfo.ScreenX, pixelInfo.ScreenY); _sb.AppendLine("显示通道"); if (drawing.SelectedBandNos.Length == 1) { _sb.AppendLine(string.Format(ITEM_RGB_BANDS1, selectedBandNos[0])); _sb.AppendLine(string.Format(ITEM_RGB_VALUES1, rgb.R)); _sb.AppendLine(string.Format(ITEM_DATA_VALUES1, bandValues[selectedBandNos[0] - 1])); } else { _sb.AppendLine(string.Format(ITEM_RGB_BANDS3, selectedBandNos[0], selectedBandNos[1], selectedBandNos[2])); _sb.AppendLine(string.Format(ITEM_RGB_VALUES3, rgb.R, rgb.G, rgb.B)); _sb.AppendLine(string.Format(ITEM_DATA_VALUES3, bandValues[selectedBandNos[0] - 1], bandValues[selectedBandNos[1] - 1], bandValues[selectedBandNos[2] - 1])); } } // if (txtOriginChannels.Checked) { _sb.AppendLine("原始通道值"); for (int i = 1; i <= bandCount; i++) { string bandDesc = drawing.DataProviderCopy.GetRasterBand(i).Description; if (string.IsNullOrEmpty(bandDesc)) { _sb.AppendLine(string.Format(ITEM_BAND_VALUE, i, bandValues[i - 1])); } else { _sb.AppendLine(string.Format(ITEM_BAND_VALUE_WITHNAME, i, bandValues[i - 1], bandDesc)); } } } //判识面积 string extractingArea = TryGetExtractingArea(); string tempStr = _sb.ToString() + extractingArea + TryGetExtInfoFromInfoProvider(pixelInfo); //面板显示参数 string argInfos = TryGetExtractingArgInfos(); txtInfo.Text = tempStr + argInfos; }