Attribute VB_Name = "Module2" Sub Main On Error GoTo Err_Handling Dim SurferApp As Object Dim Doc As Object Dim Plotwindow As Object Dim Map As Object Dim MapTitle1 As Object Dim MapTitle2 As Object Dim MethodLabel As Variant Dim retValue As Boolean Dim Data As String Dim Grid As String Dim Path As String Dim Method As Integer Dim GifFileName,TimeFileName As String Data = "data.dat" Grid = "RAINRT\data.grd" MethodLabel = Array("Kriging", "Inverse Distance", "Minimum Curvature", _ "Modified Shepard's Method", "Natural Neighbor", "Nearest Neighbor", _ "Polynomial Regression", "Radial Basis Functions", _ "Triangulation with Linear Interpolation") 'Creates an instance of the Surfer Application object and assigns it to the 'variable named "SurferApp" Set SurferApp = CreateObject("Surfer.Application") 'Assigns the location of the data and grid files to the variable named "Path" Path = "C:\Inetpub\wwwroot\AUTORUN\" 'Disables Plotwindow's AutoRedraw to speed up the script 'Plotwindow.AutoRedraw = False Method =2 For j=3 To 54 'Grids the specified data file using the Kriging algorithm and 'assigns the return value to the variable named "retValue" retValue = SurferApp.GridData(DataFile:=Path+"RAINRT\WeekRainGamma.xls",xcol:=1,ycol:=2,zcol:=j ,xmin:=97.4465,xmax:=105.641418, _ ymin:=5.61075,ymax:=20.46511,numcols:=800,numrows:=1000,Algorithm:=Method, _ ShowReport:=False, OutGrid:=Path + Grid) SurferApp.GridBlank(InGrid:=Path+Grid , _ BlankFile:=Path+"SURFDATA\thailand.bln" , _ OutGrid:=Path+"SURFDATA\out.grd" , _ OutFmt:=srfGridFmtS7) 'Creates a contour map from the gridded data and assigns it to the variable 'named "Map" Dim Plot As Object Set Plot = SurferApp.Documents.Add(srfDocPlot) 'Declares Shapes as an object Dim Shapes As Object 'Assigns the Shapes collection to the variable named "Shapes" Set Shapes = Plot.Shapes 'Declares MapFrame as an object Dim BaseMap As Object 'Creates a base map and assigns the map coordinate system to the 'variable named "MapFrame" Set MapFrame1 = Shapes.AddContourMap(GridFileName:=Path+"SURFDATA\out.grd") For Each Axis In MapFrame1.Axes Axis.ShowLabels = False Axis.MajorTickType = srfTickNone Axis.MinorTickType = srfTickNone Axis.Visible = False Next Axis Dim ContourMap As Object 'Assigns the contour map properties to the variable named "ContourMap" Set ContourMap = MapFrame1.Overlays(1) 'Declares Levels as an object Dim Levels As Object Dim LevelFileName As String 'Assigns the Levels collection to the variable named "Levels" Set Levels = ContourMap.Levels Dim TextUnit As Object LevelFileName =Path+"LEVELCOLOR\Probrain.lvl" Set TextUnit = Shapes.AddText(5.0,5.9,"RAINFALL : mm.") GifFileName="AKOM\WEEK_" & j-2 With TextUnit.Font .Face = "AngsanaUPC" .Size = 14 .Bold =True .Color=srfColorDarkBlue End With Levels.LoadFile(LevelFileName) Dim ColorScale As Object Set ColorScale=ContourMap.ColorScale ContourMap.ShowColorScale = True ContourMap.FillContours=True Dim DiscreteColorScale As Object 'Assigns the color scale properties to the variable named 'DiscreteColorScale" Set DiscreteColorScale = ContourMap.ColorScale DiscreteColorScale.Left=5.25 DiscreteColorScale.Top=5.5 DiscreteColorScale.Width=0.5 DiscreteColorScale.Height=2.5 DiscreteColorScale.LabelFont.Face = "AngsanaUPC" DiscreteColorScale.LabelFont.Size = 18 Set BaseMap = Shapes.AddBaseMap(ImportFileName:=Path+"SHAPEFILE\province.shp") For Each Axis In BaseMap.Axes Axis.ShowLabels = False Axis.MajorTickType = srfTickNone Axis.MinorTickType = srfTickNone Axis.Visible = False Next Axis Set Plot = BaseMap.Parent Set PostMap = Shapes.AddClassedPostMap(Path+"SURFDATA\postmap.xls", _ xCol:=1, yCol:=2, zCol:=4,labcol:=5) PostMap.BackgroundFill.ForeColor = srfColorWhite PostMap.BackgroundFill.Pattern = "Solid" Set clpost1 = PostMap.Overlays("Classed Post") clPost1.NumClasses = 3 clpost1.ShowLegend = False clpost1.LabelFont.Face = "AngsanaUPC" clpost1.LabelFont.Size = 5 For i = 1 To 3 With clpost1.BinSymbol(i) .Set = "GSI Default Symbols" .Index = 11 .Size = 0.02 End With Next i clpost1.BinSymbol(1).Color =srfColorRed clpost1.BinSymbol(2).Color =srfColorDarkBlueGreen clpost1.BinSymbol(3).Color =srfColorBlue Plot.Selection.DeselectAll BaseMap.Selected = True MapFrame1.Selected = True PostMap.Selected=True Dim TextTitle,TextSub As Object Dim DateString As String Set TextMet = Shapes.AddText(3.2,2.7,"THAI METEOROLOGICAL DEPARTMENT ") With TextMet.Font .Face = "AngsanaUPC" .Size = 12 .Bold =True .Color=srfColorDarkGreen End With Dim MetLoGo As Object Set MetLoGo=Shapes.AddBaseMap(ImportFileName:=Path+"SURFDATA\LoGo.bmp") MetLoGo.Left=2.37 MetLoGo.Top=2.85 MetLoGo.Width=.6 MetLoGo.Height=.6 For Each Axis In MetLoGo.Axes Axis.ShowLabels = False Axis.MajorTickType = srfTickNone Axis.MinorTickType = srfTickNone Axis.Visible = False Next Axis Set TextSub = Shapes.AddText(2.25,9.5,"RAINFALL EXPECTED AT 0.75 PROBABILITY") With TextSub.Font .Face = "AngsanaUPC" .Size = 20 .Bold =True .Color=srfColorDarkBlue End With Set TextTitle = Shapes.AddText(3.35,9.25,"WEEK " & j-2 & StandardWeek(j-2) ) With TextTitle.Font .Face = "AngsanaUPC" .Size = 20 .Bold =True .Color=srfColorDarkGreen End With Plot.Selection.OverlayMaps SurferApp.Visible=True Plot.Export(FileName:=Path+ GifFileName+ ".gif", Options:="Width=325, height=600") Plot.SaveAs(FileName:=Path+ GifFileName+ ".srf") Next Err_Handling: Exit Sub End Sub Function StandardWeek(N) Select Case N Case 1 StandardWeek =" (1 Jan-7 Jan)" Case 2 StandardWeek ="(8 Jan-14 Jan)" Case 3 StandardWeek ="(15 Jan-21 Jan)" Case 4 StandardWeek ="(22 Jan-28 Jan)" Case 5 StandardWeek ="(29 Jan-4 Feb)" Case 6 StandardWeek ="(5 Feb-11 Feb)" Case 7 StandardWeek ="(12 Feb-8 Feb)" Case 8 StandardWeek ="(19 Feb- 5 Feb)" Case 9 StandardWeek ="(26 Feb-4 Mar)" Case 10 StandardWeek ="(5 Mar-11 Mar)" Case 11 StandardWeek ="(12 Mar-18 Mar)" Case 12 StandardWeek ="(19 Mar-25 Mar)" Case 13 StandardWeek ="(26 Mar-1 Apr)" Case 14 StandardWeek ="(2 Apr-8 Apr)" Case 15 StandardWeek ="(9 Apr-15 Apr)" Case 16 StandardWeek ="(16 Apr-22 Apr)" Case 17 StandardWeek ="(23 Apr-29 Apr)" Case 18 StandardWeek ="(30 Apr-6 May)" Case 19 StandardWeek ="(7 May-13 May)" Case 20 StandardWeek ="(14 May-20 May)" Case 21 StandardWeek ="(21 May-27 May)" Case 22 StandardWeek ="(28 May-3 Jun)" Case 23 StandardWeek ="(4 Jun-10 Jun)" Case 24 StandardWeek ="(11 Jun-17 Jun)" Case 25 StandardWeek ="(18 Jun-24 Jun)" Case 26 StandardWeek ="(25 Jun-1 Jul)" Case 27 StandardWeek ="(2 Jul-8 Jul)" Case 28 StandardWeek ="(9 Jul-15 Jul)" Case 29 StandardWeek ="(16 Jul-22 Jul)" Case 30 StandardWeek ="(23 Jul- 9 Jul)" Case 31 StandardWeek ="(30 Jul-5 Aug)" Case 32 StandardWeek ="(6 Aug-12 Aug)" Case 33 StandardWeek ="(13 Aug-19 Aug)" Case 34 StandardWeek ="(20 Aug-26 Aug)" Case 35 StandardWeek ="(27 Aug-2 Sep)" Case 36 StandardWeek ="(3 Sep-9 Sep)" Case 37 StandardWeek ="(10 Sep-16 Sep)" Case 38 StandardWeek ="(17 Sep-23 Sep)" Case 39 StandardWeek ="(24 Sep-30 Sep)" Case 40 StandardWeek ="(1 Oct-7 Oct)" Case 41 StandardWeek ="(8 Oct-14 Oct)" Case 42 StandardWeek ="(15 Oct-21 Oct)" Case 43 StandardWeek ="(22 Oct-28 Oct)" Case 44 StandardWeek ="(29 Oct-4 Nov)" Case 45 StandardWeek ="(5 Nov-11 Nov)" Case 46 StandardWeek ="(12 Nov- 8 Nov)" Case 47 StandardWeek ="(19 Nov-25 Nov)" Case 48 StandardWeek ="(26 Nov-2 Dec)" Case 49 StandardWeek ="(3 Dec-9 Dec)" Case 50 StandardWeek ="(10 Dec-16 Dec)" Case 51 StandardWeek ="(17 Dec-23 Dec)" Case 52 StandardWeek ="(24 Dec-31 Dec)" End Select End Function