爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7520|回复: 17

MeteoInfo脚本示例:绘制同心圆

[复制链接]

新浪微博达人勋

发表于 2013-7-29 16:02:22 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 MeteoInfo 于 2013-7-29 16:10 编辑

之前示例了用脚本进行一些图形的绘制:MeteoInfo脚本示例:MeteoInfo脚本示例:图形绘制http://bbs.06climate.com/forum.php?mod=viewthread&tid=10278&fromuid=106

这个帖子补充讲一下同心圆图形的绘制。圆的绘制用到了CircleShape类,该类继承自PolygonShape类,可以用圆心点和半径来构造CircleShape。通过圆心不同角度的线段可以用PolylineShape来绘制。需要MeteoInfo最新文件(见置顶帖子)。

比较简单,多看看代码应该能理解,运行效果如下(注意MapView的XYScaleFactor属性要设为1,缺省是1.2):
Image00420.png

脚本代码如下:
  1. #--------------------------------------------------------        
  2. # Author: Yaqiang Wang                                          
  3. # Date: 2013-7-29                                                
  4. # Purpose: Add cicle graphics  
  5. # Note: Sample                                                   
  6. #-----------------------------------------------------------  
  7. #---- Import clr and classes
  8. import clr
  9. clr.AddReferenceByPartialName("System")
  10. clr.AddReferenceByPartialName("System.Drawing")
  11. from System import *
  12. from System.Drawing import *
  13. from System.Collections.Generic import *
  14. clr.AddReference("MeteoInfoC.dll")
  15. from MeteoInfoC import *
  16. from MeteoInfoC.Data.MapData import *
  17. from MeteoInfoC.Geoprocess import *
  18. from MeteoInfoC.Layer import *
  19. from MeteoInfoC.Shape import *
  20. from MeteoInfoC.Legend import *
  21. from MeteoInfoC.Drawing import *
  22. import os.path
  23. from math import *

  24. #---- Create circle graphics
  25. print 'Create circle graphics...'
  26. cpoint = PointD(120.6, 30.6)
  27. radius = [0.5, 1, 1.5]
  28. pLegend = PolygonBreak()
  29. pLegend.DrawFill = False
  30. pLegend.OutlineColor = Color.Black

  31. for r in radius:
  32.         cshape = CircleShape(cpoint, r)
  33.         cgraphic = Graphic(cshape, pLegend)
  34.         mipy.MapDocument.ActiveMapFrame.MapView.GraphicCollection.Add(cgraphic)

  35. #---- Create polyline graphics
  36. print 'Create polyline graphics...'
  37. def getcirclepoint(cp, r, a):
  38.         x = cp.X + r * cos(a * 3.1416 / 180.0)
  39.         y = cp.Y + r * sin(a * 3.1416 / 180.0)
  40.         p = PointD(x, y)
  41.         return p

  42. llegend = PolyLineBreak()
  43. llegend.Color = Color.Black
  44. r = 1.5
  45. plist = List[PointD]()
  46. plist.Add(PointD(cpoint.X - r, cpoint.Y))
  47. plist.Add(PointD(cpoint.X + r, cpoint.Y))
  48. lshape = PolylineShape()
  49. lshape.Points = plist
  50. lgraphic = Graphic(lshape, llegend)
  51. mipy.MapDocument.ActiveMapFrame.MapView.GraphicCollection.Add(lgraphic)
  52. plist = List[PointD]()
  53. plist.Add(PointD(cpoint.X, cpoint.Y + r))
  54. plist.Add(PointD(cpoint.X, cpoint.Y - r))
  55. lshape = PolylineShape()
  56. lshape.Points = plist
  57. lgraphic = Graphic(lshape, llegend)
  58. mipy.MapDocument.ActiveMapFrame.MapView.GraphicCollection.Add(lgraphic)
  59. plist = List[PointD]()
  60. angle = 45.0
  61. p = getcirclepoint(cpoint, r, angle)
  62. plist.Add(p)
  63. angle = 225.0
  64. p = getcirclepoint(cpoint, r, angle)
  65. plist.Add(p)
  66. lshape = PolylineShape()
  67. lshape.Points = plist
  68. lgraphic = Graphic(lshape, llegend)
  69. mipy.MapDocument.ActiveMapFrame.MapView.GraphicCollection.Add(lgraphic)
  70. plist = List[PointD]()
  71. angle = 135.0
  72. p = getcirclepoint(cpoint, r, angle)
  73. plist.Add(p)
  74. angle = 315.0
  75. p = getcirclepoint(cpoint, r, angle)
  76. plist.Add(p)
  77. lshape = PolylineShape()
  78. lshape.Points = plist
  79. lgraphic = Graphic(lshape, llegend)
  80. mipy.MapDocument.ActiveMapFrame.MapView.GraphicCollection.Add(lgraphic)

  81. #---- Refresh MapView
  82. mipy.MapDocument.ActiveMapFrame.MapView.PaintLayers()
  83. print 'Finished!'


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

新浪微博达人勋

发表于 2013-7-29 20:50:22 | 显示全部楼层
谢谢王老师分享和指导
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-7-29 23:14:09 | 显示全部楼层
王老师辛苦了,将脚本文件翻译成C#语言了,交作业了~ radarcircle.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-7-29 23:19:08 | 显示全部楼层
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-7-29 23:26:25 | 显示全部楼层
MeteoInfo 发表于 2013-7-29 23:19
很强悍实用的作业!

雷达数据是什么格式的?

王老师过奖了~转成micap4类再显示的,回波的空间位置和实际位置还有偏差,还要再调整~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-7-30 18:11:46 | 显示全部楼层
wbriver 发表于 2013-7-29 23:26
王老师过奖了~转成micap4类再显示的,回波的空间位置和实际位置还有偏差,还要再调整~

哥们能不能共享一哈转换成micaps类数据的程序算法或者源代码呢?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-8-6 21:59:37 | 显示全部楼层
♂雨已~○ 发表于 2013-8-6 21:41
恩,谢谢,这个我也查到了这篇文献,我想问问你那个转成micaps格点数据是咋个插值的呢?分辨率多大呢?给 ...

双线性差值就够了,按照你的需求,个人觉得想插细了可以考虑1km*1km,不过数据量比较大,用shaded图层显示会比较慢,raster快多了,不过效果不是很好啊~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-8-6 22:02:18 | 显示全部楼层
wbriver 发表于 2013-8-6 21:59
双线性差值就够了,按照你的需求,个人觉得想插细了可以考虑1km*1km,不过数据量比较大,用shaded图层显示 ...

恩,谢咯哈
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-8-6 21:41:00 | 显示全部楼层
wbriver 发表于 2013-8-6 14:45
好久没来了。。。我这里直接用的省里转好的micaps 4类数据~
其实你只要根据雷达站经纬计算出起止经纬度, ...

恩,谢谢,这个我也查到了这篇文献,我想问问你那个转成micaps格点数据是咋个插值的呢?分辨率多大呢?给个思路呢,兄台,然后出图的时候用的是shaded图层还是raster图层呢?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-8-6 14:45:58 | 显示全部楼层
本帖最后由 wbriver 于 2013-8-6 14:53 编辑
♂雨已~○ 发表于 2013-7-30 18:11
哥们能不能共享一哈转换成micaps类数据的程序算法或者源代码呢?

好久没来了。。。我这里直接用的省里转好的micaps 4类数据~
其实你只要根据雷达站经纬计算出起止经纬度,以及径向和纬向的格点数就可以转了,网上有相关文献的~ 文献.jpg
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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