Code Examples for Consuming the Web Services
Python
To consume the web services using Python, three modules need to be installed in addition to the main package. They are SOAPpy , fpconst and pyXML.
Code Snippet for GetDEMOneLocation
import SOAPpyurl = 'http://compag.tc.cornell.edu/NRCC/service1.asmx'
ws = SOAPpy.WSDL.Proxy(url + '?WSDL')
#Example 1
startDate = '7/4/2007';
endDate = '7/5/2007';
variable = 'maxt';
lat = '42.45';
long = '-76.45';
print "=", ws.GetDEMOneLocation(weatherStartDate=startDate,weatherEndDate=endDate,weatherVariable=variable,latitude=lat,longitude=long);
#Example 2
startDate = '6/25/2006';
endDate = '6/30/2006';
variable = 'prec';
lat = '42.06';
long = '-75.55';
print "=", ws.GetDEMOneLocation(weatherStartDate=startDate,weatherEndDate=endDate,weatherVariable=variable,latitude=lat,longitude=long);
Code Snippet for GetDEMData
import SOAPpyurl = 'http://compag.tc.cornell.edu/NRCC/service1.asmx'
ws = SOAPpy.WSDL.Proxy(url + '?WSDL')
#Example 1
startDate = '7/4/2007';
endDate = '7/5/2007';
variable = 'maxt';
southLat = '42.50';
northLat = '42.40';
westLong = '-76.40';
eastLong = '-76.50';
print "=", ws.GetDEMData(weatherStartDate=startDate,weatherEndDate=endDate,weatherVariable=variable,northLatitude=northLat,southLatitude=southLat,eastLongitude=eastLong,westLongitude=westLong);
#Example 2
startDate = '6/25/2006';
endDate = '6/30/2006';
variable = 'prec';
southLat = '42.10';
northLat = '42.00';
westLong = '-75.50';
eastLong = '-75.60';
print "=", ws.GetDEMOneLocation(weatherStartDate=startDate,weatherEndDate=endDate,weatherVariable=variable,latitude=lat,longitude=long);
