import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = 1
gp.CheckOutExtension("Spatial")
gp.cellSize = "0.0041666667"
Since this code was being repeated throughout all of the gp services, I simply turned it into a function in my helpers class. This removed about 100 lines of boiler plate and gave the ability to fine-tune the geoprocessor for all of the services. There are some additional debugging methods inside createGeoprocessor which also reside in the helpers class. I will do a future post on those basic error handling functions soon.
def createGeoprocessor(self):
'''
Returns a 9.3/9.3.1 Geoprocessor whose
overwrite property is set to true
and Spatial Analyst extension checked-out
'''
import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = 1
try:
if(gp.CheckExtension("Spatial") == "Available"):
gp.CheckOutExtension("Spatial")
else:
raise "LicenseError"
except "LicenseError":
self.toScreen(gp, Messages.SPATIAL_ANALYST_ERROR)
except:
self.reportGPErrors(gp)
self.reportSysErrors(gp)
return gp
No comments:
Post a Comment