I think this is what you are looking for: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Using_geometry_objects_with_geoprocess...I've done some limited stuff with this, and it seems to work well... The idea is the geometry stuff is evaluated in RAM anyway... why not just keep it there as an object you can use instead of always reading/writting a featureclass from disk? Here is a practical example... an elaboration of some ESRI-authored code (I wrote the search tree part to get at a solution quicker)... Builds approximate maximum inscribed circles inside a polygon featureclass. Note that there is a bug with the ESRI buffer tool in v10.0 that prevents this from "always" being the actual maximum inscribed circle. Also, this code needs some refining on my part, but it should work well as-is.
try:
import arcpy, os, sys, traceback
arcpy.env.overwriteOutput = True
#Get the input feature class or layer
## inFeatures = arcpy.GetParameterAsText(0)
## outFeatures = arcpy.GetParameterAsText(1)
inFeatures = r"C:\csny490\habitat_frag_analysis_20110919\circles.gdb\mature_interior_forest"
outFeatures = r"C:\csny490\habitat_frag_analysis_20110919\circles.gdb\out_polys"
#Some housekeeping
inDesc = arcpy.Describe(inFeatures)
oidName = str(inDesc.OIDFieldName)
if inDesc.dataType == "FeatureClass":
inFeatures = arcpy.MakeFeatureLayer_management(inFeatures)
sR = inDesc.spatialReference
xyTol = sR.XYTolerance
arcpy.env.overwriteOutput = True
#Create the stub output feature class
arcpy.CopyFeatures_management(inFeatures,outFeatures)
arcpy.AddField_management(outFeatures, "BUFFDIST", "DOUBLE")
OIDFieldName = arcpy.Describe(outFeatures).OIDFieldName
arcpy.MinimumBoundingGeometry_management(outFeatures, "in_memory\\br", "RECTANGLE_BY_WIDTH", "NONE", "", "MBG_FIELDS")
#Create dictionary of ORIG_FID,MBR_WIDTH
fidWidthDict = dict([(r.ORIG_FID, r.MBG_WIDTH) for r in arcpy.SearchCursor("in_memory\\br")]) #
arcpy.Delete_management("in_memory\\br")
#Calculate the inscribed circles
rows = arcpy.UpdateCursor(outFeatures)
for row in rows:
print "Processing polygon " + str(row.getValue(OIDFieldName))
inShape = row.shape
aGeom = arcpy.Geometry()
maxBuffDist = fidWidthDict[row.getValue(OIDFieldName)] / 2
minBuffDist = xyTol
geomList = []
while (maxBuffDist - minBuffDist) >= xyTol:
midBuffDist = (minBuffDist + maxBuffDist) / 2.0
print "Checking buffer distance = " + str(midBuffDist * -1)
geomList = arcpy.Buffer_analysis(inShape, aGeom, midBuffDist * -1, "FULL","", "NONE", "")
if len(geomList) > 0:
minBuffDist = midBuffDist
else:
maxBuffDist = midBuffDist
geomList = arcpy.Buffer_analysis(inShape, aGeom, (midBuffDist - (2 * xyTol)) * -1, "FULL","", "NONE", "")
inPoint = arcpy.FeatureToPoint_management(geomList[0], aGeom, "INSIDE")[0]
geomList = arcpy.Buffer_analysis(inPoint, aGeom, (midBuffDist - xyTol), "FULL" ,"", "NONE", "")
row.BUFFDIST = midBuffDist * -1
row.shape = geomList[0]
rows.updateRow(row)
del row, rows
print "Done!!!"
except:
print "\n*** LAST GEOPROCESSOR MESSAGE (may not be source of the error)***"
print arcpy.GetMessages()
print "\n*** PYTHON ERRORS *** "
print "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]
print "Python Error Info: " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"