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") Set SurferApp = CreateObject("Surfer.Application") Path = "C:\Inetpub\wwwroot\AUTORUN\" Method =2 Dim j As Integer For j = 3 To 6 Step 1 retValue = SurferApp.GridData(DataFile:=Path+"RAINRT\Data3hrs.xls",xcol:=1,ycol:=2,zcol:=j ,xmin:=97.4465,xmax:=105.641418, _ ymin:=5.61075,ymax:=20.46511,numcols:=820,numrows:=1486,Algorithm:=Method, _ ShowReport:=False, OutGrid:=Path + Grid) SurferApp.GridBlank(InGrid:=Path+Grid , _ BlankFile:=Path+"SURFDATA\thailand.bln" , _ OutGrid:=Path+"SURFDATA\out.grd" , _ OutFmt:=srfGridFmtS7) Dim Plot As Object Set Plot = SurferApp.Documents.Add(srfDocPlot) Dim Shapes As Object Set Shapes = Plot.Shapes Dim BaseMap As Object 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) ContourMap.LabelFont.Size=10 ContourMap.LabelFont.Face="AngsanaUPC" ContourMap.LabelLabelDist = 0.5 ContourMap.LabelEdgeDist = 0.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,TextTitle As Object If j =3 Then LevelFileName =Path+"LEVELCOLOR\Temp.lvl" Set TextTitle = Shapes.AddText(3.42,9.15,"TEMPERATURE") Set TextUnit = Shapes.AddText(4.75,5.6,"Temperature : C ") GifFileName="GIFMAP3hrs\TEMP" & DateFilename() ElseIf j = 5 Then LevelFileName =Path+"LEVELCOLOR\1_rain_daily.lvl" 'LevelFileName =Path+"LEVELCOLOR\rain.lvl" Set TextTitle = Shapes.AddText(3.75,9.15,"RAINFALL") Set TextUnit = Shapes.AddText(5.0,5.6,"Rain fall : mm") GifFileName="GIFMAP3hrs\RAIN" & DateFilename() ElseIf j = 4 Then LevelFileName =Path+"LEVELCOLOR\rh.lvl" Set TextTitle = Shapes.AddText(3.18,9.15,"RELATIVE HUMIDITY") Set TextUnit = Shapes.AddText(4.75,5.6," Relative Humidity : %") GifFileName="GIFMAP3hrs\RH" & DateFilename() Else LevelFileName =Path+"LEVELCOLOR\PRESSURE.lvl" Set TextTitle = Shapes.AddText(3.18,9.15,"MEAN SEA LEVEL PRESSURE") Set TextUnit = Shapes.AddText(4.75,5.6,"PRESSURE : mb") GifFileName="GIFMAP3hrs\MSL" & DateFilename() End If With TextUnit.Font .Face = "AngsanaUPC" .Size = 14 .Bold =True .Color=srfColorDarkBlue End With With TextTitle.Font .Face = "AngsanaUPC" .Size = 18 .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 Set DiscreteColorScale = ContourMap.ColorScale DiscreteColorScale.Left=5.07 DiscreteColorScale.Top=5.2 DiscreteColorScale.Width=0.5 DiscreteColorScale.Height=2.5 DiscreteColorScale.LabelFont.Face = "AngsanaUPC" DiscreteColorScale.LabelFont.Size = 16 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 baseMap1=BaseMap.Overlays(1) baseMap1.Line.ForeColor=srfColorBabyBlue 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 clpost1.LabelFont.Bold = True clpost1.LabelFont.Color = srfColorDarkBlueGreen 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 TextDate As Object Dim DateString As String Set TextDate = Shapes.AddText(3.3,8.9,Day(Date()) &" "& MonthName(Month(Date())) &" "& Year(Date()) & " " & Hour(Now()) & ":00") With TextDate.Font .Face = "AngsanaUPC" .Size = 19 .Bold =True .Color=srfColorDarkGreen End With Set TextMet = Shapes.AddText(3.3,2.4,"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.47 MetLoGo.Top=2.55 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 Plot.Selection.OverlayMaps Plot.Export(FileName:=Path+ GifFileName+ ".gif", Options:="Width=320, height=669") Next j 'SurferApp.Visible=True Err_Handling: Exit Sub End Sub Function DateFilename() Dim Dday,Mmonth,Yyear As String Dim Nday,Nmonth As Integer If Day(Date()) < 10 Then Dday="0" & Day(Date()) Else Dday="" & Day(Date()) End If If Month(Date()) < 10 Then Mmonth="0" & Month(Date()) Else Mmonth="" & Month(Date()) End If Yyear= "" & Year(Date()) Yyear= Right(Yyear,2) DateFilename=Dday & Mmonth & Yyear & Hour(Now()) End Function Function FileName() If Hour(Now()) <10 Then FileName="0" & Hour(Now()) & "00" Else FileName= Hour(Now()) & "00" End If End Function