- 积分
- 126
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-8-12
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 guxing-345 于 2014-6-10 10:06 编辑
王老师,最近用MeteoInfoC.dll在开发个生成雨量图的小程序,发现等值线绘制的有的正确,有的等值线绘制填色反了,是怎么回事?
正确的图片:
色标填反的图片:
插值及生成图片的代码为:
- //创建等值线填充图
- private void createShare()
- {
- //设置插值格点数据
- GridDataSetting aGDP = new GridDataSetting();
- Extent ex = new Extent();
- ex.minX = 123.500000;
- ex.minY = 41.200000;
- ex.maxX = 125.500000;
- ex.maxY = 42.500000;
- aGDP.DataExtent = ex; //加入插值范围
- aGDP.YNum = 100; //格点点数
- aGDP.XNum = 100; //格点点数
- //插值方法
- InterpolationSetting agrid = new InterpolationSetting();
- agrid.GridDataSet = aGDP;
- agrid.InterpolationMethod = InterpolationMethods.IDW_Radius;
- agrid.Radius = 2;
- agrid.MinPointNum = 1;
- double[] X = new double[1];
- double[] Y = new double[1];
- ContourDraw.CreateGridXY(aGDP, ref X, ref Y);
- VectorLayer alayer = (VectorLayer)layersLegend1.ActiveMapFrame.MapView.Layers[1];
- AttributeTable att = new AttributeTable();
- att = alayer.AttributeTable;
- DataTable dt = att.Table;
- int column = dt.Columns.Count;
- int row = dt.Rows.Count;
- double[,] S = new double[column - 2, row];
- for (int i = 0; i < row; i++)
- {
- S[0, i] = double.Parse(dt.Rows[i][2].ToString());
- S[1, i] = double.Parse(dt.Rows[i][3].ToString());
- S[2, i] = double.Parse(dt.Rows[i][4].ToString());
- }
-
- S = ContourDraw.FilterDiscreteData_Radius(S, agrid.Radius, agrid.GridDataSet.DataExtent, -9999.0F);
- GridData grid = new GridData();
- grid = ContourDraw.InterpolateDiscreteData_Radius(S, X, Y, agrid.MinPointNum, agrid.Radius, -9999.0F);
- LegendScheme lgd = new LegendScheme(ShapeTypes.Polygon);
- double min = grid.GetMinValue();
- double max = grid.GetMaxValue();
- lgd.ImportFromXMLFile(this.LegendScheme);
- lgd.MaxValue = max;
- lgd.MinValue = min;
- VectorLayer lineLayer = new VectorLayer(ShapeTypes.Polygon);
- lineLayer = DrawMeteoData.CreateShadedLayer(grid, lgd, "图例(毫米)", "LGD");
- lineLayer.Visible = true;
- lineLayer.IsMaskout = true;
- layersLegend1.ActiveMapFrame.AddLayer(lineLayer);
- //加入掩膜
- MaskOut ma = new MaskOut(mapView1);
- ma.MaskLayer = "抚顺县区";
- ma.SetMaskLayer = true;
- mapView1.MaskOut = ma;
- mapView1.PaintLayers();
- layersLegend1.Refresh();
- }
- //设置maplayout
- private void SetMapLayout()
- {
- //设置画布尺寸
- mapLayout1.PageBounds = Rectangle.FromLTRB(0, 0, 900, 600);
- mapLayout1.ActiveLayoutMap.Left = 3;
- mapLayout1.ActiveLayoutMap.Top = 3;
- mapLayout1.ActiveLayoutMap.Width = 893;
- mapLayout1.ActiveLayoutMap.Height = 593;
-
- //设置画布活动区域边界样式
- mapLayout1.ActiveLayoutMap.DrawNeatLine = true;
- mapLayout1.ActiveLayoutMap.NeatLineColor = Color.Black;
- mapLayout1.ActiveLayoutMap.NeatLineSize = 3;
- //加入标题
- mapLayout1.AddText("抚顺市降水分布图", 250, 45, "黑体", 14);
- mapLayout1.AddText(BeginTime.ToString(DateFormat) + "至" + EndTime.ToString(DateFormat), 250, 75, "黑体", 14);
- mapLayout1.AddText("(抚顺市气象台提供)", 250, 105, "黑体", 14);
- //加入图例
- LayoutLegend alegend = mapLayout1.AddLegend(3, 417);
- alegend.Font = new Font("宋体", 10);
- alegend.LegendStyle = LegendStyles.Normal;
- alegend.LegendLayer = layersLegend1.ActiveMapFrame.MapView.Layers[2];
- alegend.DrawNeatLine = true;
- alegend.NeatLineColor = Color.Black;
- alegend.NeatLineSize = 2;
- //加入指北针
- LayoutNorthArrow lna = mapLayout1.AddNorthArrow(820, 40);
- lna.BackColor = Color.White;
- lna.ForeColor = Color.Black;
- lna.Width = 40;
- lna.Height = 60;
- mapLayout1.PaintGraphics();
- mapLayout1.Refresh();
- }
- //添加县区界线
- private void Add_FS_County_Line()
- {
- string aFile = AppDomain.CurrentDomain.BaseDirectory + "\\Maps\\FS_County_Line.shp";
- MapLayer aLayer = MapDataManage.OpenLayer(aFile);
- aLayer.LegendScheme.LegendBreaks[0].Color = Color.Black;
- aLayer.LayerName = "县区";
- aLayer.IsMaskout = false;
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- }
- //导出地图
- private void createPng()
- {
- mapLayout1.ExportToPicture(PicPath);
- }
- //初始化
- public CDrawPicture()
- {
- m_LegendScheme = AppDomain.CurrentDomain.BaseDirectory + "\\Legend\\Rain.lgs";
- m_List_StationPara = new List<cstationpara>();
- }
- }</cstationpara>
复制代码
断点检查时感觉插值后的二维数组没问题,就是绘制面图层时出现的错误,不知道怎样解决?。
|
|