爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6085|回复: 12

绘制等值线时色标填图错误怎么解决?

[复制链接]

新浪微博达人勋

发表于 2014-6-10 09:59:58 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 guxing-345 于 2014-6-10 10:06 编辑

王老师,最近用MeteoInfoC.dll在开发个生成雨量图的小程序,发现等值线绘制的有的正确,有的等值线绘制填色反了,是怎么回事?
正确的图片:
FS_Rain_1_2014061009.png

色标填反的图片:
FS_Rain_5_2014061009.png

插值及生成图片的代码为:
     
  1. //创建等值线填充图
  2.         private void createShare()
  3.         {
  4.             //设置插值格点数据
  5.             GridDataSetting aGDP = new GridDataSetting();
  6.             Extent ex = new Extent();
  7.             ex.minX = 123.500000;
  8.             ex.minY = 41.200000;
  9.             ex.maxX = 125.500000;
  10.             ex.maxY = 42.500000;
  11.             aGDP.DataExtent = ex;      //加入插值范围
  12.             aGDP.YNum = 100;                         //格点点数
  13.             aGDP.XNum = 100;                         //格点点数

  14.             //插值方法
  15.             InterpolationSetting agrid = new InterpolationSetting();
  16.             agrid.GridDataSet = aGDP;
  17.             agrid.InterpolationMethod = InterpolationMethods.IDW_Radius;
  18.             agrid.Radius = 2;
  19.             agrid.MinPointNum = 1;

  20.             double[] X = new double[1];
  21.             double[] Y = new double[1];
  22.             ContourDraw.CreateGridXY(aGDP, ref X, ref Y);

  23.             VectorLayer alayer = (VectorLayer)layersLegend1.ActiveMapFrame.MapView.Layers[1];
  24.             AttributeTable att = new AttributeTable();
  25.             att = alayer.AttributeTable;
  26.             DataTable dt = att.Table;
  27.             int column = dt.Columns.Count;
  28.             int row = dt.Rows.Count;
  29.             double[,] S = new double[column - 2, row];
  30.             for (int i = 0; i < row; i++)
  31.             {
  32.                 S[0, i] = double.Parse(dt.Rows[i][2].ToString());
  33.                 S[1, i] = double.Parse(dt.Rows[i][3].ToString());
  34.                 S[2, i] = double.Parse(dt.Rows[i][4].ToString());      
  35.             }
  36.            
  37.             S = ContourDraw.FilterDiscreteData_Radius(S, agrid.Radius, agrid.GridDataSet.DataExtent, -9999.0F);

  38.             GridData grid = new GridData();
  39.             grid = ContourDraw.InterpolateDiscreteData_Radius(S, X, Y, agrid.MinPointNum, agrid.Radius, -9999.0F);

  40.             LegendScheme lgd = new LegendScheme(ShapeTypes.Polygon);
  41.             double min = grid.GetMinValue();
  42.             double max = grid.GetMaxValue();
  43.             lgd.ImportFromXMLFile(this.LegendScheme);
  44.             lgd.MaxValue = max;
  45.             lgd.MinValue = min;

  46.             VectorLayer lineLayer = new VectorLayer(ShapeTypes.Polygon);
  47.             lineLayer = DrawMeteoData.CreateShadedLayer(grid, lgd, "图例(毫米)", "LGD");
  48.             lineLayer.Visible = true;
  49.             lineLayer.IsMaskout = true;
  50.             layersLegend1.ActiveMapFrame.AddLayer(lineLayer);

  51.             //加入掩膜
  52.             MaskOut ma = new MaskOut(mapView1);
  53.             ma.MaskLayer = "抚顺县区";
  54.             ma.SetMaskLayer = true;
  55.             mapView1.MaskOut = ma;
  56.             mapView1.PaintLayers();
  57.             layersLegend1.Refresh();
  58.         }

  59.         //设置maplayout
  60.         private void SetMapLayout()
  61.         {
  62.             //设置画布尺寸
  63.             mapLayout1.PageBounds = Rectangle.FromLTRB(0, 0, 900, 600);
  64.             mapLayout1.ActiveLayoutMap.Left = 3;
  65.             mapLayout1.ActiveLayoutMap.Top = 3;
  66.             mapLayout1.ActiveLayoutMap.Width = 893;
  67.             mapLayout1.ActiveLayoutMap.Height = 593;
  68.             

  69.             //设置画布活动区域边界样式
  70.             mapLayout1.ActiveLayoutMap.DrawNeatLine = true;
  71.             mapLayout1.ActiveLayoutMap.NeatLineColor = Color.Black;
  72.             mapLayout1.ActiveLayoutMap.NeatLineSize = 3;

  73.             //加入标题
  74.             mapLayout1.AddText("抚顺市降水分布图", 250, 45, "黑体", 14);
  75.             mapLayout1.AddText(BeginTime.ToString(DateFormat) + "至" + EndTime.ToString(DateFormat), 250, 75, "黑体", 14);
  76.             mapLayout1.AddText("(抚顺市气象台提供)", 250, 105, "黑体", 14);

  77.             //加入图例
  78.             LayoutLegend alegend = mapLayout1.AddLegend(3, 417);
  79.             alegend.Font = new Font("宋体", 10);
  80.             alegend.LegendStyle = LegendStyles.Normal;
  81.             alegend.LegendLayer = layersLegend1.ActiveMapFrame.MapView.Layers[2];
  82.             alegend.DrawNeatLine = true;
  83.             alegend.NeatLineColor = Color.Black;
  84.             alegend.NeatLineSize = 2;

  85.             //加入指北针
  86.             LayoutNorthArrow lna = mapLayout1.AddNorthArrow(820, 40);
  87.             lna.BackColor = Color.White;
  88.             lna.ForeColor = Color.Black;
  89.             lna.Width = 40;
  90.             lna.Height = 60;

  91.             mapLayout1.PaintGraphics();
  92.             mapLayout1.Refresh();
  93.         }

  94.         //添加县区界线
  95.         private void Add_FS_County_Line()
  96.         {
  97.             string aFile = AppDomain.CurrentDomain.BaseDirectory + "\\Maps\\FS_County_Line.shp";
  98.             MapLayer aLayer = MapDataManage.OpenLayer(aFile);
  99.             aLayer.LegendScheme.LegendBreaks[0].Color = Color.Black;
  100.             aLayer.LayerName = "县区";
  101.             aLayer.IsMaskout = false;
  102.             layersLegend1.ActiveMapFrame.AddLayer(aLayer);
  103.         }

  104.         //导出地图
  105.         private void createPng()
  106.         {
  107.             mapLayout1.ExportToPicture(PicPath);
  108.         }

  109.         //初始化
  110.         public CDrawPicture()
  111.         {
  112.             m_LegendScheme = AppDomain.CurrentDomain.BaseDirectory + "\\Legend\\Rain.lgs";
  113.             m_List_StationPara = new List<cstationpara>();
  114.         }
  115.     }</cstationpara>
复制代码

断点检查时感觉插值后的二维数组没问题,就是绘制面图层时出现的错误,不知道怎样解决?。

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-6-10 10:34:00 | 显示全部楼层
首先确保你用的是最新版的wContour和MeteoInfoC类库,如果还有同样问题应该是wContour类库的bug,你可以把相关数据发给我,以便调试修改。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-6-10 15:54:03 | 显示全部楼层
MeteoInfo 发表于 2014-6-10 10:34
首先确保你用的是最新版的wContour和MeteoInfoC类库,如果还有同样问题应该是wContour类库的bug,你可以把 ...

王老师,我用的MeteoInfoC和wContour应该都是最新版的,分别是1.1版本和1.6版本。我把我所用的数据和色标发给您吧,麻烦您在不忙的时候帮我看看,谢谢了!

TestData.rar

74.06 KB, 下载次数: 17, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-6-10 23:49:23 | 显示全部楼层
guxing-345 发表于 2014-6-10 15:54
王老师,我用的MeteoInfoC和wContour应该都是最新版的,分别是1.1版本和1.6版本。我把我所用的数据和色标 ...

更新了wContour类库(见置顶帖子),你再试试。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-6-12 17:29:14 | 显示全部楼层
MeteoInfo 发表于 2014-6-10 23:49
更新了wContour类库(见置顶帖子),你再试试。

谢谢王老师,问题解决了,显示正确了!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-8-16 17:51:43 | 显示全部楼层
原来aGDP.YNum和x是插值点数
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-8-17 20:32:03 | 显示全部楼层
谢谢,下载下来学习下。如果有其他语言版本的最好了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-11-13 17:00:43 | 显示全部楼层
xqls0203 发表于 2014-8-17 20:32
谢谢,下载下来学习下。如果有其他语言版本的最好了

以前用VB.NET写过,不过后来也转到了C#
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-3 09:55:56 | 显示全部楼层
学习了。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-4-25 10:16:42 | 显示全部楼层
命名和代码都很清晰 基本可以收做范例了
刚刚学习meteoInfo的二次开发,有个问题请教 vs10中引入两个类库后,但添加不了mapview等三个控件,这个等下再查查原因~
昨晚至今试了一下 LayersLegend layersLegend1 = new LayersLegend(); 实例化不了 意思是一定得把控件添加上 然后进行如教程一种所言的属性之间的关联么? 不甚感激
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表