请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
楼主: 记忆碎片

利用meteoinfo实现Surfer二次开发效果,绘制等值线图,并白化(maskout)边框外内容

[复制链接]

新浪微博达人勋

发表于 2013-1-1 21:32:59 | 显示全部楼层

建议先在网上搜搜何为shape文件

抠数据有很多方法,手动选择、按属性选择、按位置选择等。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-1-5 16:20:23 | 显示全部楼层
最后确认下来还是数据源的问题
找到了正确的数据,预期效果很快就出来了
上图,交作业
浙江叠加图.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-1-24 11:04:50 | 显示全部楼层
遇到一个新的问题
之前调试完好的内容,现在把核心的MeteoInfoC.dll从1.0.5升级到1.0.8,仅对部分属性名称做了对应调整。没有进行功能性修改
发现报错,而且报错很莫名其妙,说wContour缺失,经过查看,该文件存在的。
不知道如何解决好?
报错.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-24 11:44:36 | 显示全部楼层
记忆碎片 发表于 2013-1-24 11:04
遇到一个新的问题
之前调试完好的内容,现在把核心的MeteoInfoC.dll从1.0.5升级到1.0.8,仅对部分属性名称 ...

wContour.dll也需要用最新的文件。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-1-25 12:06:11 | 显示全部楼层
MeteoInfo 发表于 2013-1-24 11:44
wContour.dll也需要用最新的文件。

请问与1.0.8对应的MeteoInfo.dll对应的应该是1.6.0.0的wContour?
还对?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-25 14:15:16 | 显示全部楼层
记忆碎片 发表于 2013-1-25 12:06
请问与1.0.8对应的MeteoInfo.dll对应的应该是1.6.0.0的wContour?
还对?

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

新浪微博达人勋

 楼主| 发表于 2013-2-3 00:18:18 | 显示全部楼层
效果图.jpg
通过如下代码得到上图效果图(源文件: Ng值文件.txt (4.59 KB, 下载次数: 1)
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-2-3 10:10:14 | 显示全部楼层
记忆碎片 发表于 2013-2-3 00:18
通过如下代码得到上图效果图(源文件:),可是效果很奇怪,照理应该是个方形或者圆形,至少不至于不连续 ...

看了一下,你的数据其实是格点数据,建议你把它改成格点数据格式,比如GrADS的二进制,或者简单的Surfer文本格点格式。

你目前用站点格式处理,在绘制等值线的时候需要先插值成格点数据,插值都是一些数学假设,且参数设置不同结果会完全不同,显然你的插值参数设置是有问题的。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-2-3 14:28:47 | 显示全部楼层
本帖最后由 记忆碎片 于 2013-2-3 14:31 编辑
MeteoInfo 发表于 2013-2-3 10:10
看了一下,你的数据其实是格点数据,建议你把它改成格点数据格式,比如GrADS的二进制,或者简单的Surfer文 ...

果然是问题出在插值参数设置上,按照上述的代码,将差值部分代码修改为下示代码,插值后效果好多了就。
代码:
  1.         /// <summary>
  2.         /// 需要原文件格式“stationID,Longitude,Latitude,Value”
  3.         /// </summary>
  4.         /// <param name="_targetLayersLegend"></param>
  5.         /// <param name="_targetMapLayout"></param>
  6.         /// <param name="fileSource"></param>
  7.         public static void DrawStationShadedNew(LayersLegend _targetLayersLegend,MapLayout _targetMapLayout,string fileSource)
  8.         {
  9.             //Read data info
  10.             MeteoDataInfo aDataInfo = new MeteoDataInfo();
  11.             string aFile = fileSource;
  12.             aDataInfo.OpenLonLatData(aFile);

  13.             //Get station data
  14.             StationData stationData = aDataInfo.GetStationData("Value");

  15.             //Interpolate
  16.             GridDataSetting aGDP = new GridDataSetting();
  17.             aGDP.DataExtent.minX = 121;//x最小值
  18.             aGDP.DataExtent.maxX = 122;//x最大值
  19.             aGDP.DataExtent.minY = 28;//y最小值
  20.             aGDP.DataExtent.maxY = 29;//y最大值
  21.             aGDP.XNum = 81;//列数
  22.             aGDP.YNum = 81;//行数
  23.             InterpolationSetting gridInterp = new InterpolationSetting();
  24.             gridInterp.GridDataSet = aGDP;

  25.             gridInterp.InterpolationMethod = InterpolationMethods.IDW_Neighbors;//差值方法
  26.             gridInterp.Radius = 3;//差值半径
  27.             gridInterp.MinPointNum = 1;

  28.             double[] X = new double[1];
  29.             double[] Y = new double[1];
  30.             ContourDraw.CreateGridXY(gridInterp.GridDataSet, ref X, ref Y);
  31.             double[,] S = stationData.Data;
  32.             S = ContourDraw.FilterDiscreteData_Radius(S, gridInterp.Radius,
  33.                 gridInterp.GridDataSet.DataExtent, stationData.UNDEF);
  34.             GridData gridData = ContourDraw.InterpolateDiscreteData_Radius(S,
  35.                 X, Y, gridInterp.MinPointNum, gridInterp.Radius, stationData.UNDEF);

  36.             //Create legend scheme
  37.             bool hasNoData = true;
  38.             LegendScheme aLS = LegendManage.CreateLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
  39.                 ShapeTypes.Polygon, ref hasNoData);
  40.             ((PolygonBreak)aLS.LegendBreaks[0]).DrawFill = false;

  41.             //Create layer
  42.             VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
  43.             aLayer = DrawMeteoData.CreateShadedLayer(gridData, aLS, "Ng", "Ng");
  44.             aLayer.IsMaskout = true;

  45.             //Add layer
  46.             _targetLayersLegend.ActiveMapFrame.AddLayer(aLayer);
  47.             _targetLayersLegend.ActiveMapFrame.MoveLayer(aLayer.Handle, 0);
  48.             _targetLayersLegend.Refresh();

  49.             //Change title of the layout
  50.             LayoutGraphic aTitle = _targetMapLayout.GetTexts()[0];
  51.             aTitle.SetLabelText("Station Ng Layer");

  52.             //Add or change the legend in layout
  53.             LayoutLegend aLegend;
  54.             if (_targetMapLayout.GetLegends().Count > 0)
  55.                 aLegend = _targetMapLayout.GetLegends()[0];
  56.             else
  57.                 aLegend = _targetMapLayout.AddLegend(650, 100);
  58.             aLegend.LegendStyle = LegendStyleEnum.Bar_Vertical;
  59.             aLegend.LegendLayer = aLayer;
  60.             //if (tabControl1.SelectedIndex == 1)
  61.                 _targetMapLayout.PaintGraphics();
  62.         }

插值图层后,再Maskout,然后效果图如下:

插值效果图

插值效果图

差值细节图

差值细节图


接下来的待完成工作:
1  自动化找到数据中的行数、列数、经纬度最大、最小值。

等把这部分功能完成后。抽空把内容整合起来分享给大家。现在虽然方法都有了,不过太零散 呵呵 再次感谢王老师一路的指导。


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

新浪微博达人勋

发表于 2014-5-21 09:05:17 | 显示全部楼层
记忆碎片 发表于 2013-1-5 16:20
最后确认下来还是数据源的问题
找到了正确的数据,预期效果很快就出来了
上图,交作业

请问您的数据在那找到的,谢谢
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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