| 
 
	积分106贡献 精华在线时间 小时注册时间2016-4-29最后登录1970-1-1 
 | 
 
 发表于 2020-6-4 19:04:07
|
显示全部楼层 
| 复制代码'生成等值线图
Public Sub ContourMain()
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = False
    Set Wks = SurferApp.Documents.Open(baseFile)
    
    maxValue = Wks.Columns(2).Statistics().Maximum '获取第二列最大值
    minValue = Wks.Columns(2).Statistics().Minimum
    maxHeight = Wks.Columns(4).Statistics().Maximum
    Wks.Close srfSaveChangesNo '不提示直接关闭
            
    '网格
    SurferApp.GridData DataFile:=baseFile, xCol:=xCombo.Text, yCol:=yCombo.Text, zCol:=zCombo.Text, NumCols:=(maxValue - minValue) / xText.Text + 1, NumRows:=(maxHeight - yMinText.Text) / yText.Text + 1, xMin:=minValue, xMax:=maxValue, yMin:=yMinText.Text, yMax:=maxHeight, _
    ExclusionFilter:=zFilterText.Text, Algorithm:=srfKriging, DupMethod:=srfDupFirst, ShowReport:=False, OutGrid:=baseName & ".grd"
            
    '滤波
    Call SurferApp.GridFilter(baseName & ".grd", srfFilterGaussian, srfFltEdgeReplicate, srfFltBlankLeave, OutGrid:=baseName & ".grd")
            
    '转化为dat
    'Call SurferApp.GridConvert(InGrid:=GridFile, OutGrid:=BaseName + ".dat")
    '平滑
    Call SurferApp.GridSplineSmooth(baseName & ".grd", nRow:=2, nCol:=2, Method:=srfSplineInsert, OutGrid:=baseName & ".grd")
    '加载网格图
    Set Plot = SurferApp.Documents.Add(srfDocPlot)
    Set MapFrame = Plot.Shapes.AddContourMap(baseName & ".grd")
    
    '叠加图形
    'Plot.Shapes.SelectAll
    'Plot.Selection.OverlayMaps
    
    Set plotMape = Plot.Selection.Item(1)
    Call plotMape.SetLimits(xMin:=minValue, xMax:=maxValue, yMin:=yMinText.Text, yMax:=maxHeight)
    With plotMape
        .xMapPerPU = scaleText.Text '设置比例
        .yMapPerPU = scaleText.Text '设置比例
    End With
    
    '填充网格图
    Set ContourMap = MapFrame.Overlays(1)
    ContourMap.FillContours = True
    'ContourMap.ShowColorScale = True
    ContourMap.SmoothContours = srfConSmoothHigh
    ContourMap.Levels.LoadFile (path + "1111.lvl")
    
    Plot.SaveAs (baseName + ".srf")
    SurferApp.Quit
End Sub
'加载地形
Public Sub BlankMian()
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = False
    Set Wks = SurferApp.Documents.Open(baseFile + ".srf")
    
    '加载地形bln
    blankFile = path & "地表" & "" & fileName & ".bln"
    Set blankMap = Plot.Shapes.AddBaseMap(blankFile)
    Set blankMapSet = blankMap.Overlays(1)
    With blankMapSet
        .Fill.Pattern = "Solid"
        .Fill.ForeColor = srfColorWhite
    End With
    
    '叠加图形
    Plot.Shapes.SelectAll
    Plot.Selection.OverlayMaps
    
    Set plotMape = Plot.Selection.Item(1)
    Call plotMape.SetLimits(xMin:=minValue, xMax:=maxValue, yMin:=yMinText.Text, yMax:=maxHeight)
    With plotMape
        .xMapPerPU = scaleText.Text '设置比例
        .yMapPerPU = scaleText.Text '设置比例
    End With
    
    Plot.Save
    SurferApp.Quit
End Sub
'加载底板
Public Sub BaseMain()
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = False
    Set Wks = SurferApp.Documents.Open(baseFile + ".srf")
    
    '加载底板bln
    baseMapFile = path & "底板" & "" & fileName & ".bln"
    Set baseMape = Plot.Shapes.AddBaseMap(baseMapFile)
    
    Set baseMapSet = baseMape.Overlays(1)
    baseMapSet.Line.Width = 0.02
    
    '叠加图形
    Plot.Shapes.SelectAll
    Plot.Selection.OverlayMaps
    
    Set plotMape = Plot.Selection.Item(1)
    Call plotMape.SetLimits(xMin:=minValue, xMax:=maxValue, yMin:=yMinText.Text, yMax:=maxHeight)
    With plotMape
        .xMapPerPU = scaleText.Text '设置比例
        .yMapPerPU = scaleText.Text '设置比例
    End With
    
    Plot.Save
    SurferApp.Quit
End Sub
 | 
 |