The code example worked for me. I could not get it to fail on a complex polygon featureclass such as the pine forest landcover for a small country. I changed the test to a random shape and printed all vertices and handled possible donuts. I did not compare the vertices with a normal cursor, but they look plausible. There are a few more convenient touches at 10 for iterating over parts and of course the spatial operators but otherwise its the same for 9.3 or 10.The featurecount is 47,713 and the script took 14 seconds.
THIS CODE LOADS A FC INTO A PYTHON DICTIONARY IN RAM
# http://forums.arcgis.com/threads/17956-Using-centroid-geometry-to-get-values-of-intersecting-feature#post60607
# edits by Kimo
import arcgisscripting, sys
import random,datetime,pprint
start = datetime.datetime.now()
gp = arcgisscripting.create(9.3)
#THE INPUT FC
fc = "d:/workspace/datetest.gdb/pineforest"
#Process: Build a field list and a mini dictionary to look up the field order (aka index) given a field name
fieldList = gp.listfields(fc)
fieldIndex = 0
fieldNameDict = {}
for field in fieldList:
fieldNameDict[field.name] = fieldIndex
fieldIndex = fieldIndex + 1
shapeFieldName = gp.Describe(fc).shapeFieldName # fix missing definition
pprint.pprint(fieldNameDict)
#Process: Load the fc into a dictionary
fcDictionary = {}
oidFieldName = gp.describe(fc).oidfieldname
searchRows = gp.searchcursor(fc)
searchRow = searchRows.next()
while searchRow:
oidFieldValue = searchRow.getvalue(oidFieldName)
fcDictionary[oidFieldValue] = []
for field in fieldList:
fcDictionary[oidFieldValue].append(searchRow.getvalue(field.name))
searchRow = searchRows.next()
del searchRow,searchRows
print
print "Size of dictionary",len(fcDictionary)
for sample in range(10):
print
idx = random.randint(0,len(fcDictionary))
#Print the values
print fcDictionary[idx]
#Print a name field value
print fcDictionary[idx][fieldNameDict["LCDB1NAME"]]
#Print the extent rectangle
print fcDictionary[idx][fieldNameDict[shapeFieldName]].extent
#Print ALL the coordinate pairs including parts and interior rings
shapeObj = fcDictionary[idx][fieldNameDict[shapeFieldName]]
for p in range(shapeObj.partCount):
part = shapeObj.getPart(p)
pnt = part.next()
while pnt:
print p,pnt.X,pnt.Y
pnt = part.next()
if not pnt:
pnt = part.next()
if pnt:
interiorRing = True
print "Hole"
print "Completed",datetime.datetime.now() - start
[12139, <geoprocessing describe geometry object object at 0x16A388D8>, 66.0, u'Pine Forest - Closed Canopy', 66.0, u'Pine Forest - Closed Canopy', u'no', 64.70760971, 182.0, u'Rodney District', 16.0, u'Auckland Region', 11067.655349413637, 646803.66190707707]
Pine Forest - Closed Canopy
1811685.23719998 5594544.72269999 1811781.95419998 5594599.59829999 NaN NaN NaN NaN
0 1811685.2372 5594544.9228
0 1811688.5206 5594544.9241
0 1811733.3278 5594561.747
0 1811781.9542 5594599.5983
0 1811780.0872 5594596.3042
0 1811757.3881 5594569.9774
0 1811726.5661 5594549.7439
0 1811689.9306 5594544.7227
0 1811685.2372 5594544.9228
Completed 0:00:14