| Knowledgebase Home | Contact |
| Do you have an example in Python? | |||||||||
Surfer
can be called from a Python script. Below
are some examples. 1.
Here
is an example that shows how to start Surfer: import win32com.client def main():
app = win32com.client.Dispatch("Surfer.Application")
plot = app.Documents.Add(1)
app.Visible = True main() 2.
Here
is another example that shows how to call Surfer:
import win32com.client
Surfer = win32com.client.Dispatch("Surfer.Application")
Grid = Surfer.NewGrid()
Grid.LoadFile("c:/test/test.grd", HeaderOnly=True)
print "BlankValue" + str(Grid.BlankValue)
print "NumCols" + str(Grid.NumCols)
print "NumRows" + str(Grid.NumRows) 3.
Here
is a customer example: from win32com.client import
constants, Dispatch, CastTo 4.
Here
is another customer example: import win32com.client import glob import datetime #call this script like this: #\programs\python25\python.exe
krig_data.py #get an instance of the Surfer application Surfer =
win32com.client.Dispatch('Surfer.Application') lFile = glob.glob('wl*.csv') for i in range(len(lFile)):
#the min and max listed below are center coordinates while gdal_grid
uses edge
#coordinates
sFilePrefix = lFile[i][:lFile[i].index('.')]
Surfer.GridData(DataFile = lFile[i], xCol = 1, yCol = 2, zCol = 3,
NumCols = 4133, NumRows = 3017, xMin = 455355, xMax = 579315, yMin = 1954585,
yMax = 2045065, ShowReport = False, DupMethod =
win32com.client.constants.srfDupAvg, OutFmt =
win32com.client.constants.srfGridFmtBinary, OutGrid = '%s.grd' % sFilePrefix)
print 'finished kriging %s at %s' % (lFile[i],
datetime.datetime.strftime(datetime.datetime.now(), '%a, %d %b %Y %H:%M:%S')) |
| Visitor Comments |
| No visitor comments posted. Post a comment |
| Related Questions |
| No related questions were found. |
| Attachments |
| No attachments were found. |