| 
 
	积分5038贡献 精华在线时间 小时注册时间2012-11-6最后登录1970-1-1 
 | 
 
 发表于 2015-6-7 12:27:56
|
显示全部楼层 
| 复制代码' ================================
' 演示如何剔除负值,把负值区变成空白
' Scripter + Surfer 12
' Use on your own risk.
' ================================
Option Explicit
Sub Main
        Dim SurferApp As Object
        Dim objGrd As Object
        Dim inGrd As String
        Dim outGrd As String
        Dim GrdNoNeg As String
        Dim blkValue As Double
        '初始化应用程序
        Set SurferApp=CreateObject("Surfer.Application")
        SurferApp.Visible=True
        '为了演示,先制造一个有负值的网格文件。
        inGrd=SurferApp.Path+"\Samples\demogrid.grd"
        outGrd=SurferApp.Path+"\Samples\DemoNeg.grd"
        SurferApp.GridMath(Function:="c=a-70",InGridA:=inGrd,OutGridC:=outGrd)
        '了解网格文件用什么值作为白化值。
        Set objGrd=SurferApp.NewGrid
        objGrd.LoadFile(outGrd, True)
        blkValue=objGrd.BlankValue
        '先用含负值的网格画个图,看看原始状态。
        Dim objPlotDoc As Object
        Dim objMapFrame As Object
        Set objPlotDoc=SurferApp.Documents.Add(srfDocPlot)
        Set objMapFrame=objPlotDoc.Shapes.AddContourMap(inGrd)
        objMapFrame.Top=objMapFrame.Top+8.0
        '用白化的方式剔除负值。
        Dim FuncStr As String
        FuncStr="c=if(a<0," & blkValue & ",a)"
        GrdNoNeg=SurferApp.Path+"\Samples\DemoNoNeg.grd"
        SurferApp.GridMath(Function:=FuncStr,ingrida:=outGrd,outgridc:=GrdNoNeg)
        '用结果网格再画个图,与原图对比。
        Set objMapFrame=objPlotDoc.Shapes.AddContourMap(GrdNoNeg)
        objMapFrame.Top=objMapFrame.Top-8.0
        'SurferApp.Quit
End Sub
 | 
 |