用了将近两周的时间来学习surfer画等值线,稍有点成果,拿来跟各位分享。做出的营口地图降雨量分布图:

http://hi.csdn.net/cp.php?ac=album&op=editpic&albumid=54316

作图主要思路为:(1)生成站点数据:从excel等导出数据保存为txt格式,修改为bln格式即可;(2)用surfer的Grid菜单下的Data提供的各种插值方法进行插值计算,生成.grd文件;在此用可设置插值方法的参数,重要的是可能需要设置插图边界x,y坐标的最小和最大值。(3)生成边界bln数据:我是通过导入shapefile文件,导出数据得到的,不过这时要去除多余的信息,只保留边界点数据即可。(4)blank白化处理,依次输入上面生成的.grd 文件, 边界.bln文件,即可输出只保留了边界范围内等值线的grd文件。(5)生成降雨量分布图:对等值线图进行参数设置渲染等,添加post map或classed postmap显示站点数据并设置合适标注,最后overlay图层即可。

下面是生成的C#代码:

Surfer.ApplicationClass AppSurfer = new Surfer.ApplicationClass(); //对Surfer的调用 AppSurfer.Visible = false;//注Surfer窗口是不显现 AppSurfer.WindowState = Surfer.SrfWindowState.srfWindowStateMinimized; AppSurfer.Caption = "营口地区雨量分布图"; AppSurfer.ScreenUpdating = false;//Surfer制图过程是否显示 string DataFile = strFolder + @"/book1.bln"; string OutGrid = strFolder + @"/booktest.grd"; string BlankFile = strFolder + @"/省级行政区.bln"; string BlankedGrid = strFolder + @"/booktestBlanked.grd"; AppSurfer.GridData(DataFile, 1, 2, 6, Type.Missing, Surfer.SrfDupMethod.srfDupNone, 0.03, 0.03, 316, 400, 1000000, 1080000, 4360000, 4470000, Surfer.SrfGridAlgorithm.srfInverseDistance, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, 5, 0, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, OutGrid, Surfer.SrfGridFormat.srfGridFmtAscii, OutGrid, Surfer.SrfGridFormat.srfGridFmtAscii, Type.Missing, Type.Missing, Type.Missing, Type.Missing); AppSurfer.GridBlank(OutGrid, BlankFile, BlankedGrid, Surfer.SrfGridFormat.srfGridFmtAscii); //添加等值面图层 //建立一个绘图文档和一个绘图窗口 Surfer.IPlotDocument Doc = (Surfer.IPlotDocument)AppSurfer.Documents.Add(Surfer.SrfDocTypes.srfDocPlot); Surfer.IMapFrame mapframe = Doc.Shapes.AddContourMap(BlankedGrid); mapframe.Axes.Item(1).Visible = false; mapframe.Axes.Item(2).Visible = false; mapframe.Axes.Item(3).Visible = false; mapframe.Axes.Item(4).Visible = false; //注:将格点化文件GridFile生成等值线图,并给其命名为mapframe; Surfer.IContourMap ClassedCounterMap = (Surfer.IContourMap)mapframe.Overlays.Item(1); ClassedCounterMap.FillContours = true; ClassedCounterMap.ShowColorScale = false; ClassedCounterMap.SmoothContours.Equals(6); double[] CustomLevels = new double[6]; CustomLevels[0] = 0; CustomLevels[1] = 10; CustomLevels[2] = 25; CustomLevels[3] = 50; CustomLevels[4] = 100; CustomLevels[5] = 250; Surfer.ILevels Levels = ClassedCounterMap.Levels; Levels.Set(CustomLevels); Levels.Item(1).Fill.ForeColor = Surfer.srfColor.srfColorLightYellow; Levels.Item(2).Fill.ForeColor = Surfer.srfColor.srfColorBananaYellow; Levels.Item(3).Fill.ForeColor = Surfer.srfColor.srfColorGrassGreen; Levels.Item(4).Fill.ForeColor = Surfer.srfColor.srfColorGreen; Levels.Item(5).Fill.ForeColor = Surfer.srfColor.srfColorBlue; Levels.Item(6).Fill.ForeColor = Surfer.srfColor.srfColorDarkBlue; Surfer.IMapFrame mapframe1 = Doc.Shapes.AddClassedPostMap(DataFile, 1, 2, 7, 4); mapframe1.Axes.Item(1).Visible = false; mapframe1.Axes.Item(2).Visible = false; mapframe1.Axes.Item(3).Visible = false; mapframe1.Axes.Item(4).Visible = false; Surfer.IClassedPostMap ClassedpostMap = (Surfer.IClassedPostMap)mapframe1.Overlays.Item(1); ClassedpostMap.LabelPos = Surfer.SrfPostPosType.srfPostPosRight; ClassedpostMap.LabelFont.Face = "Arial"; ClassedpostMap.LabelFont.Size = 8; ClassedpostMap.LabelFont.Bold = true; ClassedpostMap.NumClasses = 2; ClassedpostMap.BinningMethod = Surfer.SrfPostBinMethod.srfPostUser; double[] binlimits = new double[4]; binlimits[0] = 0; binlimits[1] = 1; binlimits[2] = 1; binlimits[3] = 2; ClassedpostMap.SetBinLimits(binlimits); ClassedpostMap.SymFrequency = 1; Surfer.IMapFrame mapframe2 = Doc.Shapes.AddClassedPostMap(DataFile, 1, 2, 6, 6); mapframe2.Visible = false; Surfer.IClassedPostMap ClassedpostMap2 = (Surfer.IClassedPostMap)mapframe2.Overlays.Item(1); ClassedpostMap2.LabelPos = Surfer.SrfPostPosType.srfPostPosAbove; ClassedpostMap2.LabelFont.Face = "Arial"; ClassedpostMap2.LabelFont.Size = 10; ClassedpostMap2.LabelFont.Bold = true; ClassedpostMap2.LabelFont.Color = Surfer.srfColor.srfColorRed; ClassedpostMap2.NumClasses = 1; //合并三个map Doc.Selection.DeselectAll(); mapframe.Selected = true; mapframe1.Selected = true; mapframe2.Selected = true; Doc.Selection.OverlayMaps(); Doc.Export(OutGrpahic, false, "Defaults=1,width=1013,height=655,KeepAspect=1,ColorDepth=24,Automatic=0,Quality=100"); AppSurfer.Documents.CloseAll(Surfer.SrfSaveTypes.srfSaveChangesNo); AppSurfer.Quit();

下面是vb脚本代码:

Sub Main 'Declare the variable that will reference the application Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True 'Declares Plot as an object Dim Plot As Object Set Plot = SurferApp.Documents.Add Dim strFolder As String strFolder="C:/Documents and Settings/Administrator/桌面/surfer最新" DataFile = strFolder + "/book1.bln" OutGrid =strFolder + "/booktest.grd" BlankFile =strFolder+ "/省级行政区.bln" BlankedGrid = strFolder+ "/booktestBlanked.grd" 'Grids the data with a fault file using IDw Curvature SurferApp.GridData(DataFile:=DataFile,xCol:=1,yCol:=2,zCol:=6, NumCols:=316,NumRows:=400,xMin:=1000000,xMax:=1080000,yMin:=4360000,yMax:=4470000,Algorithm:=srfInverseDistance,IDPower:=5,IDSmoothing:=0) SurferApp.GridBlank(OutGrid,BlankFile,BlankedGrid,srfGridFmtAscii) '添加等值面 'Declares MapFrame as Object Dim MapFrame As Object 'Creates a contour map and assigns the map frame to the variable "MapFrame" Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=BlankedGrid) 'Declares ContourMap as an Object and assigns the contour map to variable "ContourMap" Dim ContourMap As Object Set ContourMap = MapFrame.Overlays(1) ContourMap.FillContours = True ContourMap.ShowColorScale=False ContourMap.SmoothContours=srfConSmoothHigh Dim CustomLevels(1 To 6) As Double CustomLevels(1)=0 CustomLevels(2)=10 CustomLevels(3)=25 CustomLevels(4)=50 CustomLevels(5)=100 CustomLevels(6)=250 Set Levels = ContourMap.Levels Levels.Set(CustomLevels) Levels(1).Fill.ForeColor=srfColorLightYellow Levels(2).Fill.ForeColor=srfColorBananaYellow Levels(3).Fill.ForeColor=srfColorGrassGreen Levels(4).Fill.ForeColor=srfColorGreen Levels(5).Fill.ForeColor=srfColorBlue Levels(6).Fill.ForeColor=srfColorDarkBlue 'MapFrame set unvisible MapFrame.Axes.Item(1).Visible=False MapFrame.Axes.Item(2).Visible=False MapFrame.Axes.Item(3).Visible=False MapFrame.Axes.Item(4).Visible=False 'Set Classed post map Dim MapFrame1 As Object Set MapFrame1 = Plot.Shapes.AddClassedPostMap(DataFileName:=DataFile, xCol:= 1, yCol:=2, zCol:=7, LabCol:=4) MapFrame1.Axes.Item(1).Visible=False MapFrame1.Axes.Item(2).Visible=False MapFrame1.Axes.Item(3).Visible=False MapFrame1.Axes.Item(4).Visible=False Dim ClassedPostMap As Object Set ClassedPostMap = MapFrame1.Overlays(1) 'Sets the number of classes ClassedPostMap.NumClasses = 2 'Sets the binning method for the classed post map ClassedPostMap.BinningMethod = srfPostUser 'Sets the bins for the classed post map Dim binlimits(1 To 4) As Double binlimits(1) = 0 : binlimits(2) = 2 binlimits(3) = 2 : binlimits(4) = 4 ClassedPostMap.SetBinLimits(Limits:=binlimits) 'Sets the symbols for the specified bin. The bin with the lowest value is bin 1. See MarkerFormat for all symbol property options. ClassedPostMap.BinSymbol(Index:=1).Size = 0.15 ClassedPostMap.BinSymbol(Index:=2).Size = 0.25 ClassedPostMap.LabelPos=SrfPostPosType.srfPostPosRight ClassedPostMap.LabelFont.Face="Arial" ClassedPostMap.LabelFont.Size=8 ClassedPostMap.LabelFont.Bold=True 'Set Classed post map Dim MapFrame2 As Object Set MapFrame2 = Plot.Shapes.AddClassedPostMap(DataFileName:=DataFile, xCol:= 1, yCol:=2, zCol:=6, LabCol:=6) MapFrame2.Axes.Item(1).Visible=False MapFrame2.Axes.Item(2).Visible=False MapFrame2.Axes.Item(3).Visible=False MapFrame2.Axes.Item(4).Visible=False Dim ClassedPostMap1 As Object Set ClassedPostMap1 = MapFrame2.Overlays(1) 'Sets the number of classes ClassedPostMap1.NumClasses = 1 'Sets the binning method for the classed post map ClassedPostMap1.BinningMethod = srfPostUser ClassedPostMap1.LabelPos=SrfPostPosType.srfPostPosAbove ClassedPostMap1.LabelFont.Face="Arial" ClassedPostMap1.LabelFont.Size=10 ClassedPostMap1.LabelFont.Color=srfColor.srfColorRed ClassedPostMap1.LabelFont.Bold=True 'Overlay maps Plot.Selection.DeselectAll() MapFrame.Selected=True MapFrame1.Selected=True MapFrame2.Selected=True Plot.Selection.OverlayMaps() End Sub

surfer画等值线相关推荐

  1. Grads画等值线(一)-----心得感言

    之前研究了如何用surfer画等值线,总体来说还算不错,在实际项目中得到了应用.但是在surfer等软件中使用的插值法都是纯数学差值法,在孤立点附近容易产生一些不合理区域.后来知道Grads中有在气象 ...

  2. matlab调用surfer绘制等值线

    实现流程 matlab计算得到的三列数据,分别为x坐标.y坐标和对应坐标的数值,文件名为originalData.dat 开启surfer软件,本人用的surfer13 matlab命令行输入下述代码 ...

  3. 用Grads画等值线(二)------.map生成

    要生成.map文件,需要以下四步: (一)准备一个.ch文件,其中有需要的站点数据: (二)编写一个简单的程序把.ch中的数据写成二进制格式的.dat文件.(三)编写一个站点控制文件.ctl.(四)运 ...

  4. c#环境下的surfer等值线制图开发

    private void toolBtnContour_Click(object sender, EventArgs e)         {             if (m_MyTable == ...

  5. MATLAB中的三维图形等值线

    在军事.地理等学科中,经常会到等值线.在MATLAB中有许多绘制等值线的命令. 1.contour3命令 contour3是三维绘图中最常用的绘制等值线的命令,利用该命令可生成一个定义在矩形格栅上曲面 ...

  6. 小白学习cartopy画地图的第六天

    小白学习cartopy画地图的第六天 从开始学习画地图开始,就是打算用cartopy的,但是不知不觉跑偏了,跑去了Basemap,最近感觉这样不对,因为Basemap已经停止更新了,主要还是个人觉得c ...

  7. 使用Arcgis画等值线图

    使用Arcgis画等值线图 前言 一.开启Geostatistical Analyst工具 二.使用地统计向导画图 三.调整配色 四.插入图例 参考 前言 本来我没打算写这一篇的,因为关于Arcgis ...

  8. matlab将surfer格式转化矩阵,matlab调用surfer

    (); // 退出后台运行的 Surfer 对象 1.2 通过 C++ 的 COM 接口技术调用 Surfer 对 Surfer Automation 的调用 , 除了通过上述的 MFC Automa ...

  9. Python 等值线生成(TIN三角网)

    基于TIN三角网生成不光滑等值线 等值线功能实现 等值点插值 TIN 边界边查找 单个三角形内生长等值线 一条等值线生成 按等高距生成全部等值线 可视化结果 可视化代码 等值线(未平滑) 全部代码 等 ...

最新文章

  1. 天线3db波束宽度_天线的主瓣波束宽度越窄天线增益越高.PPT
  2. 使用apache的ab对想迪科技站点www.thinkdee.com进行压力测试
  3. mysql 保留两位小数
  4. 女人赢了 未来500万年男性将灭绝
  5. 磁铁还能用来爬铁墙?简直惊呆了
  6. 《产品设计与开发(原书第5版)》——3.2 机会识别的评比结构
  7. 解决复杂问题的思路 —— 从简单到复杂
  8. python语言程序设计是干什么的-Python语言程序设计
  9. 怎样搬运视频不侵权,王者剪辑的指纹检测如何检测原创度
  10. Remote-SSH 安装教程
  11. 对图像 香农费诺编码 matlab 实现,香农编码费诺编码.doc
  12. 计算机房图怎么画,机房CAD图纸的画法教程
  13. 深思考AI机器人-巧思首登央视  “以一当十”接受宫颈癌病理专家检验
  14. 真人qq秀代码_关于QQ我的记忆
  15. python解密m3u8没有声音_ts文件解密+python脚本m3u8下载
  16. 好男人都死到哪去了?
  17. 哈希(哈希表的应用)
  18. TinkerBoard-S 上手体验
  19. Java微服务面试题整理
  20. 知乎上关于电子商务话题的精彩问答

热门文章

  1. WiFi信号扩展的最佳方案
  2. VScode如何恢复误删文件
  3. Elasticsearch: analyzer
  4. 用计算机桁架各杆内力,运用AUTO CAD求解桁架内力
  5. YouTube 网红程序员一夜走红,修复美、日、俄多国街景视频
  6. linux和windows木马排查思路
  7. C盘清理瘦身就这三招,收好下次不必到处找。
  8. iphone忘记访问控制密码之后如何找回
  9. java聊天室测试_Java网络聊天室实训能力测试
  10. jdbc连接mysql8.0.21_MySQL的JDBC驱动(8.0版本)