<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using centroid geometry to get values of intersecting feature in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746916#M57726</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Its something about copying the whole shape field value and not an issue with the polygon class its self. If you the points of a polygon and add them to an array you can store sucessfully the polygon they create or just the array and make the polygon sucessfully on the fly. Making them on the fly however is rather slow. Making the polys from array and storing those takes a couple minutes for a large number of polys but not too long. Comparing a large number of geometries to another large group of geometries is rather slow however using this method.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Dec 2010 19:38:46 GMT</pubDate>
    <dc:creator>ChrisMathers</dc:creator>
    <dc:date>2010-12-08T19:38:46Z</dc:date>
    <item>
      <title>Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746903#M57713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know I can get the centroid for a row from the geometry object and I know in theory that I can use that to intersect with another FC and grab some of its values. I just dont know how :p.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Nov 2010 15:08:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746903#M57713</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-11-23T15:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746904#M57714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can't find any documentation in the help about that stuff (arcpy.geometry)...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You've probaly seen it, but here's a good example script though:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=7DCD71C0-1372-4ECD-2860-A023289A7EC5"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=7DCD71C0-1372-4ECD-2860-A023289A7EC5&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Funny that in the code they acknowledge some bug issues and have a work around...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Nov 2010 19:57:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746904#M57714</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-23T19:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746905#M57715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Chris. I think this is what I want to do. Granted this is extremely metaish code lol.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
For update_row in update_cursor:
&amp;nbsp; geo_update_row=create a geometry object for this row's label point
&amp;nbsp; for search_row in search_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geo_search_row=create a geometry object for this row
&amp;nbsp;&amp;nbsp;&amp;nbsp; if geo_update_row.crosses(geo_search_row) == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; update_row.something = search_row.something
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; update_cursor.updaterow(update_row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del geo_search_row
&amp;nbsp;&amp;nbsp;&amp;nbsp; del geo_update_row
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Thats the general idea. Now I just have to learn geometry objects.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746905#M57715</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-12T07:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746906#M57716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After some playing around I know how to make a point-geometry object. All you do is get the centroid from shape field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;parceldesc=arcpy.Describe('parcels')
parcelShapeField=parceldesc.ShapeFieldName
parcel_cursor=arcpy.UpdateCursor('parcels')
for parcel_row in parcel_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; parcel_row_shape=parcel_row.getValue(parcelShapeField) #
&amp;nbsp;&amp;nbsp;&amp;nbsp; centroid=parcel_row_shape.centroid&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and to compare that to another geometry I just need to do&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;centroid.crosses(other geometry object)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dotn know how to get a polygon geometry from a row in a way taht is useful though. I can get a convex hull and an extent envelope but neither are helpful.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746906#M57716</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-12T07:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746907#M57717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have figured it out! Will post code later today once I get it nailed down.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Nov 2010 17:04:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746907#M57717</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-11-29T17:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746908#M57718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Cool! Makes you wonder why there's hardly any ESRI help and/or code examples items with this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. I am wanting to adapt some very inefficient v9.3 code to use this stuff (arcpy.geometry). Can't wait! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Need to get the "important" projects done so I can get into v10 finally &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Nov 2010 17:10:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746908#M57718</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-29T17:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746909#M57719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well the biggest problem I was having was that I assumed it was more complicated than it is. To get the geometry object for a row you only have to set a variable equal to the value of the shape field. Then you can use any of the geometry functions available to that geometry type. This is a simple example that iterates over my parcels and looks for a polygon in the FLU layer that its centroid is inside of.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
parcel_desc=arcpy.Describe("parcels") #describe the parcels and get the shape field name
parcel_shapefield=parcel_desc.ShapeFieldName
 
flu_desc=arcpy.Describe("flu")#describe the flu and get the shape field name
flu_shapefield=flu_desc.ShapeFieldName 
 
parcel_cursor=arcpy.UpdateCursor("parcels")
for row in parcel_cursor: #iterate over the parcels
&amp;nbsp;&amp;nbsp;&amp;nbsp; parcel_row_shape=row.getValue(parcel_shapefield) #get the geometry object
&amp;nbsp;&amp;nbsp;&amp;nbsp; centroid=parcel_row_shape.centroid #get the centroid from the geometry object
&amp;nbsp;&amp;nbsp;&amp;nbsp; flu_cursor=arcpy.SearchCursor("flu") 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for flu_row in flu_cursor: #iterate over the flu
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flu_row_shape=flu_row.getValue(flu_shapefield) #get the geometry object
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if centroid.within(flu_row_shape)==True: #compare the two geometries
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "RENUM: %s&amp;nbsp; FLU: %s" % (parcel_row.A1RENUM, flu_row.FLU_CODE) #do some junk with the two rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; del flu_cursor
del parcel_cursor
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746909#M57719</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-12T07:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746910#M57720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Two ideas that don't really relate to your code structure directly:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Copy the FCs locally to a FGDB (e.g. your C:\ drive). Network/SDE = slow, local FGDB = fast.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. If possible, store the "i" features/attribute values in a dictionary object. This would eliminate the need for the embedded cursor (which I have found to be very slow). In your code I see that for each parcel you open up a whole gaggle of cursors for the "i" FCs. This would be way faster if all this stuff was in a hash table of some sort.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, I have had mixed results loading the geometry objects (the shape field) into a Python dictionary in v9.3. I found that for simple geometry it seemed to always work, but more complicated shapes it seemed to get corrupt somehow... See: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30010&amp;amp;viewfull=1#post30010"&gt;http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30010&amp;amp;viewfull=1#post30010&lt;/A&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30024&amp;amp;viewfull=1#post30024"&gt;http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30024&amp;amp;viewfull=1#post30024&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once something is in a dictionary (assumingly uncorrupted) it seems to be the fastest method of emulating embedded cursor behavior (hundreds/thousands of times faster). It has worked out extremely well for me using tabular data, but the shape stuff is different story...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe this is fixed (or at least works better) in v10?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, maybe improvements could be made to the looping structure, but I don't know your data well enough... What exactly is your work flow? For each parcel see if it intersects any of the other "i" FCs, right? Would a looping SelectByLocation work the same?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 15:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746910#M57720</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-12-01T15:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746911#M57721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I used to do a method that used a spatial join but after upgrading to 10 it started to fail repeatedly without returning any errors. It was as if while loading the data into the parcels a sys.exit() signal was sent. The whole shell restarted instead of a normal crash regardless of what error catching I tried to include. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it may save time to loop once through the parcels for each 'i' instead of the other way around. Im testing that now. I may consider the dictionaries as an option if this doesnt work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason I am using networked data is that it is on an SDE and I would rather not have to have the code reconcile the FGDB with the SDE at the start of each run though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 17:25:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746911#M57721</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-12-01T17:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746912#M57722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can see what you mean about corrupting the geometry. I can write it all out to a dictionary, but trying to use the geometry object crashes python. I first tried comparing it in the normal manner and that didnt work so I tried making it a polygon object with arcpy.Polygon but that crashed as well. I think im going to try writing out the vertex array as a value in teh dictionary and creating the polygon objects on the fly from those. Sorry if this post has turned into a place to deposit my thoughts. I hope to actually post something that not only works but isnt wildly ineffiecient.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 19:03:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746912#M57722</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-12-03T19:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746913#M57723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anyone know why the an ESRI geometry object isnt transferable (at least in an uncorrupted format) to a Python dictionary???&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 19:29:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746913#M57723</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-12-03T19:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746914#M57724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But is it corrupted?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This works for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# create a dictionary of centroids
sr = gp.Describe(fcAU).SpatialReference
cur = gp.SearchCursor(fcAU,"land = 1")
row = cur.next()
dAU = {}
pt = gp.CreateObject("Point")
while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = row.shape.centroid
&amp;nbsp;&amp;nbsp;&amp;nbsp; au = row.AU_NO
&amp;nbsp;&amp;nbsp;&amp;nbsp; dAU[au] = pt
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()
del row,cur
print "OD records",len(dAU)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746914#M57724</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-12T07:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746915#M57725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my experiences, points, simple lines (a few vertices or so), and simple polygons (again - a few vertices or so), were fine. Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Copy the geometry object from a large polygon into a dictionary (it will let you do it).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Spit out the vertices&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are they the same coordinates as the original FC (when you read from the FC directly)? In my adventures with this, they were not always the same, and seemed to be corrupted somehow. Also, sometimes running this code would also give me random memory errors and make PythonWin bomb. Maybe I'm doing something wrong. Can you get this to work? Like I said, point layers, and very small polygonns/lines don't seem to be a problem, but test it on a "real" FC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#THIS CODE LOADS A FC INTO A PYTHON DICTIONARY IN RAM (AT LEAST IT SHOULD)
import arcgisscripting, sys
gp = arcgisscripting.create(9.3)
fc = r"D:\csny490\overlay_20100115\gis_layers\county.gdb\county" #THE INPUT FC

#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:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldNameDict[field.name] = fieldIndex
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldIndex = fieldIndex + 1

#Process: Load the fc into a dictionary
fcDictionary = {}
oidFieldName = gp.describe(fc).oidfieldname
searchRows = gp.searchcursor(fc)
searchRow = searchRows.next()
while searchRow:
&amp;nbsp;&amp;nbsp;&amp;nbsp; oidFieldValue = searchRow.getvalue(oidFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcDictionary[oidFieldValue] = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcDictionary[oidFieldValue].append(searchRow.getvalue(field.name))
&amp;nbsp;&amp;nbsp;&amp;nbsp; searchRow = searchRows.next()
del searchRow
del searchRows

#Print the values of OBJECTID = 1
print fcDictionary[1]

#Print the "COUNTY_NM" field value of OBJECTID = 1
print fcDictionary[1][fieldNameDict["COUNTY_NM"]]

#Print the extent rectangle of OBJECTID = 1
print fcDictionary[1][fieldNameDict[shapeFieldName]].extent

#Print the coordinate pairs of OBJECTID = 1 (assuming it is a single part feature)
shapeObj = fcDictionary[1][fieldNameDict[shapeFieldName]]
pointArray = shapeObj.getpart(0)
pointObj = pointArray.next()
while pointObj:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(pointObj.x) + ", " + str(pointObj.y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; pointObj = pointArray.next()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746915#M57725</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T07:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746916#M57726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Its something about copying the whole shape field value and not an issue with the polygon class its self. If you the points of a polygon and add them to an array you can store sucessfully the polygon they create or just the array and make the polygon sucessfully on the fly. Making them on the fly however is rather slow. Making the polys from array and storing those takes a couple minutes for a large number of polys but not too long. Comparing a large number of geometries to another large group of geometries is rather slow however using this method.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 19:38:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746916#M57726</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-12-08T19:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746917#M57727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The featurecount is 47,713 and the script took 14 seconds.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
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:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldNameDict[field.name] = fieldIndex
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldIndex = fieldIndex + 1
shapeFieldName = gp.Describe(fc).shapeFieldName #&amp;nbsp; 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:
&amp;nbsp;&amp;nbsp;&amp;nbsp; oidFieldValue = searchRow.getvalue(oidFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcDictionary[oidFieldValue] = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcDictionary[oidFieldValue].append(searchRow.getvalue(field.name))
&amp;nbsp;&amp;nbsp;&amp;nbsp; searchRow = searchRows.next()
del searchRow,searchRows
print
print "Size of dictionary",len(fcDictionary)
for sample in range(10):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print
&amp;nbsp;&amp;nbsp;&amp;nbsp; idx = random.randint(0,len(fcDictionary))
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Print the values 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fcDictionary[idx]
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Print a name field value 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fcDictionary[idx][fieldNameDict["LCDB1NAME"]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Print the extent rectangle 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fcDictionary[idx][fieldNameDict[shapeFieldName]].extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Print ALL the coordinate pairs including parts and interior rings
&amp;nbsp;&amp;nbsp;&amp;nbsp; shapeObj = fcDictionary[idx][fieldNameDict[shapeFieldName]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; for p in range(shapeObj.partCount):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part = shapeObj.getPart(p)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = part.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while pnt:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print p,pnt.X,pnt.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = part.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not pnt:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = part.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pnt:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interiorRing = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Hole"
print "Completed",datetime.datetime.now() - start
&lt;/PRE&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
[12139, &amp;lt;geoprocessing describe geometry object object at 0x16A388D8&amp;gt;, 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
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:46:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746917#M57727</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-12T07:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746918#M57728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Kim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems weird but I ran your edited code on my own FC (with some minor edits for the field name), &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It worked twice (flawlessly), and bombed 8 times with one of those bad memory errors that says something like "Can't read memory at BG55XXX05... Application must close."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When it bombs it's always on the 1st attempt to read some aspect of the geometry object (where it prints the .extent property of the geom obj - I edited it to spit out the .xmin BTW).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even manually I can load the thing into the dictionary,&amp;nbsp; and I start typing the '.' (as in fcDictionary[idx][fieldNameDict[shapeFieldName]].*) denoting I want a property of the geom object, and&amp;nbsp; POOF. But not always, which is really weird.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will try some other stuff tommorrow (like running it on another machine).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just curious, but what type of processor do you have? I have a somewhat older (4 or 5 years) AMD Opteron, and I know that it has led to some other quirky ArcGIS-related issues in the past related to raster processing, but nothing like this... i think I am the only goofball that uses an AMD. New machine will be Intel!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2010 00:03:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746918#M57728</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-12-10T00:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746919#M57729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I finally reproduced your errors, and some more using your data. There seems to be something about data in proper metric units that works ok but not US Feet &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; So I thought that it must be a data corruption. I have not found a fault that would explain that, and now after fiddling around have ended up with some similar results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the fundamental problem is similar to one I hit on another project where the shape object is only referenced in memory when it is extracted with a cursor. Later when we try to access it, there are no methods because it is &lt;/SPAN&gt;&lt;STRONG&gt;not a proper Python object&lt;/STRONG&gt;&lt;SPAN&gt;. Try doing a dir(shape). If it was a compliant Python object it would return all the methods listed on the Geometry object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even with interactive mode you cannot do any useful request on a shape retrieved from the dictionary, you get a crash, even when editing a script and invoking a method. It only works while in the cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only solution at 9.3 is to extract out all the vertices into an object that Python can use, like a string based GeoJSON dictionary! (At 10 this is practical because there is a function to convert a shape to a GeoJSON string.) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See Bruce Harold's example trying to comprehensively detect the changes between two feature datasets on the Resource &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=351BEE10-1422-2418-8815-82074A3E6B6C"&gt;Centre&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although the script is in 10 format, the same applies at 9.3. My shortcut solution for a difference machine was to test the perimeter, length or centroid instead of every vertex because if even one changes it will affect these values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you save gp.Geometry objects in a dictionary? It appears to be intended at 10, but I know there were issues at 9.3. So I don't think that there is much point in proceeding with more testing at 9.3.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2010 04:09:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746919#M57729</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2010-12-11T04:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746920#M57730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can save arcpy.Geometry objects to a dictionary. If you create the object instead of just reading it out from the cursor. Using an arcpy.array (I havnt tried using a normal python array) to store points to use with arcpy.Polygon will make an object you can save to and use from a dictionary. Populating a dictionary with the geometry objects taht way works and doesnt take very long even for a large FC. I used it successfully to compare the centroids of one FC to the polygons of another. I just used the example from the Reading Geometries page to populate the arrays.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Dec 2010 13:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746920#M57730</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-12-13T13:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746921#M57731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've noticed when determining centroids for polygon features, they are calculated based on the bounding feature of the polygon (for some features, but not others...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;envelope&lt;/SPAN&gt;&lt;SPAN&gt;, or &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;convex hull&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is problematic, because for a polygon that resembles the shape of the moon (in crescent), the centroid would be placed outside the polygons actual &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;surface area.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;[ATTACH=CONFIG]3845[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;(red crosshair is where the centroid is placed, green is where it would be preferred)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, if using the centroid geometry of a point as reference, then this discrepency can be ignored.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Dec 2010 14:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746921#M57731</guid>
      <dc:creator>DonovanCameron</dc:creator>
      <dc:date>2010-12-13T14:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using centroid geometry to get values of intersecting feature</title>
      <link>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746922#M57732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using the polygon.centroid gives you the true centroid, your red x, if it is inside the polygon. It if falls outside the polygon you are given the label point which is always inside by default. You can use the polygon.trueCentroid method to get the actual centroid regardless of its placement.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Dec 2010 16:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-centroid-geometry-to-get-values-of/m-p/746922#M57732</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-12-13T16:44:57Z</dc:date>
    </item>
  </channel>
</rss>

