for k, v in fc_dict.items(): print k, "=>", v
A pythonic way of iterating a dictionary is:for k, v in fc_dict.items(): print k, "=>", v
What version are you using? This was fixed for 10.1, I'm not certain it made it into any service pack on 10.0.
objA = None objB = None sc = arcpy.SearchCursor(fc) q = 0 for row in sc: q += 1 print str(q) print str(row.SHAPE.area) if q == 1: objA = row.SHAPE if q == 2: objB = row.SHAPE if objA: print "A " + str(objA.area) if objB: print "B " + str(objB.area)
Basically it was using a recycling cursor and now it's not, there;s not really a workaround aside from serializing to another format (such as using Geometry.__geo_interface__ and arcpy.AsShape) to store in a dictionary.
searchCursor = arcpy.SearchCursor(in_fc) fc_dict = {} for row in searchCursor: geom = row.SHAPE fc_dict[row.OBJECTID] = geom.__geo_interface__ # browse the dict and get back the geoms for k, v in fc_dict.items(): new_geom = arcpy.AsShape(v) print new_geom.area
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.