<?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: Transfer attributes without spatial join in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/1029597#M60056</link>
    <description>&lt;P&gt;I came across this thread when searching for the tool I have used several times in the past.&amp;nbsp; It can update data based on spatial relationships as well as others.&amp;nbsp; There is some setup involved, but it will do the trick.&lt;/P&gt;&lt;P&gt;&lt;A href="https://solutions.arcgis.com/shared/help/attribute-assistant/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://solutions.arcgis.com/shared/help/attribute-assistant/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2021 15:50:48 GMT</pubDate>
    <dc:creator>MichaelWalden1</dc:creator>
    <dc:date>2021-02-23T15:50:48Z</dc:date>
    <item>
      <title>Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325047#M25269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apologies if this has been answered elsewhere.&amp;nbsp; I have some points that are located within polygons and need to transfer attributes from the polys to the points.&amp;nbsp; Is there a way to do this &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;without&lt;/SPAN&gt;&lt;SPAN&gt; using a spatial join?&amp;nbsp; Spatial joins create a new layer which is not preferable.&amp;nbsp; The best I can think of is using select by location somehow.&amp;nbsp; Anyone got any better ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks heaps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 01:21:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325047#M25269</guid>
      <dc:creator>EdSaunders</dc:creator>
      <dc:date>2014-06-11T01:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325048#M25270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could try selecting the points, adding a field for that attribute you want added, and using an update cursor to populate them.&amp;nbsp; If you have a more specific example, we may be able to help out with the code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 16:16:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325048#M25270</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2014-06-11T16:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325049#M25271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Feature to Point would give you a point for each polygon with the polygon attributes, but I take it that's not what you're looking for...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 17:18:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325049#M25271</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-06-11T17:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325050#M25272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is what I might try, although I am new to python so it might not be the best way...&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In python...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Add fields for each attribute you want to transfer to the point feature class.&amp;nbsp; Lets say you want to transfer two attributes from the polygon you would add those two fields to the point feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Loop through the polygons and select each polygon&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Save the two attributes you want to transfer to variables so they can be used later&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Do a select by location to select all the points within the selected polygon&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5. Use an update cursor to loop through the selected points and populate the two fields with the variables you created earlier&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that would get you your desired outcome and should be fairly simple to put the code together since it is all straight out of esri's help pages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. - I have not tried this so I am not positive it will work jut thinking out loud here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 18:46:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325050#M25272</guid>
      <dc:creator>BrianLord1</dc:creator>
      <dc:date>2014-06-11T18:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325051#M25273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;In python...&lt;BR /&gt;1. Add fields for each attribute you want to transfer to the point feature class.&amp;nbsp; Lets say you want to transfer two attributes from the polygon you would add those two fields to the point feature class.&lt;BR /&gt;&lt;BR /&gt;2. Loop through the polygons and select each polygon&lt;BR /&gt;&lt;BR /&gt;3. Save the two attributes you want to transfer to variables so they can be used later&lt;BR /&gt;&lt;BR /&gt;4. Do a select by location to select all the points within the selected polygon&lt;BR /&gt;&lt;BR /&gt;5. Use an update cursor to loop through the selected points and populate the two fields with the variables you created earlier&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, this is basically what I have done many times to achieve this operation.&amp;nbsp; Here's a little pseudo code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#make feature layer for point shapefile
for row in arcpy.SearchCursor(polygon shapefile):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #get FID and use it to construct a query that would only select the row (polygon) that you're looking at
&amp;nbsp;&amp;nbsp;&amp;nbsp; #make feature layer using that query so now you have a one-feature feature layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; value = row.getValue("name of field you want a value from")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #use this feature layer to make a select by location operation on the point layer you made above
&amp;nbsp;&amp;nbsp;&amp;nbsp; updaterows = arcpy.UpdateCursor(point feature layer) #the cursor should only contain the selected feature(s)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for rw in updaterows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rw.setValue("field name you want to put the value in",value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updaterows.UpdateRow(rw)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325051#M25273</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T15:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325052#M25274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks all - very helpful comments.&amp;nbsp; I'll try it using a combo of Adam's and Mark's responses - select by location and then iterate through selected feature and transfer attributes.&amp;nbsp; Might be quite time consuming but preferable to creating a new layer.&amp;nbsp; Feature to point would work but again I don't want to create an extra layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again, much appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 23:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325052#M25274</guid>
      <dc:creator>EdSaunders</dc:creator>
      <dc:date>2014-06-11T23:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325053#M25275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Might be quite time consuming but preferable to creating a new layer.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It will take 10 to 100 times longer than doing a spatial join.&amp;nbsp; If you sit and wait on this operation it will not be preferable.&amp;nbsp; Your time is the most costly and valuable thing and code that performs this badly will be a waste of effort.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Create an in-memory layer if you are that opposed to creating a permanent layer.&amp;nbsp; If you use a cursor to create a dictionary from the in-memory spatial join and do the transfer with another da cursor rather than a standard join you will beat the code proposed by 100 times.&amp;nbsp; I have seen code that takes 2 hours with the select by attribute/location approach take only 20 seconds after doing the approach I am suggesting.&amp;nbsp; The most time consuming thing about my proposed code is adding the fields to the original layer.&amp;nbsp; I will never, ever, ever use embedded cursor loops with select by anything inside the loop again now that I have this code.&amp;nbsp; It even beats a standard join and field calculator operation by more than 10 times.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Look at this post for the &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/111858-Copy-attribute-values-from-one-table-to-another-in-a-loop?p=394533#post394533"&gt;basic dictionary transfer code&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Almost all Geoprocessing tools are designed around creating new layers, not modifying existing layers. For the most part they are much more optimized than writing code that emulates a manual desktop process in a loop.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 23:14:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325053#M25275</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2014-06-11T23:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325054#M25276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Look at this post for the &lt;A href="http://forums.arcgis.com/threads/111858-Copy-attribute-values-from-one-table-to-another-in-a-loop?p=394533#post394533" rel="nofollow noopener noreferrer" target="_blank"&gt;basic dictionary transfer code&lt;/A&gt;.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dictionaries are absolutely wonderful, but they rely on being able to link the correct two rows.&amp;nbsp;&amp;nbsp; From looking the code in the link, it doesn't seem to have anything to do with location, it's all based on the OBJECTID/FID field.&amp;nbsp; You are assuming that OBJECTID 1 in the poly feature class is the polygon that overlaps OBJECTID 1 in the point feature class, which doesn't seem like a fair assumption at all.&amp;nbsp; That is a nice piece of code though, and you could also simplify it a little bit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if ObjectIDVal in valueDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for n in range (0,len(updateFieldsList)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[n+1] = valueDict[ObjectIDVal]&lt;N&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
&lt;/N&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325054#M25276</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T15:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325055#M25277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Dictionaries are absolutely wonderful, but they rely on being able to link the correct two rows.&amp;nbsp;&amp;nbsp; From looking the code in the link, it doesn't seem to have anything to do with location, it's all based on the OBJECTID/FID field.&amp;nbsp; You are assuming that OBJECTID 1 in the poly feature class is the polygon that overlaps OBJECTID 1 in the point feature class, which doesn't seem like a fair assumption at all.&amp;nbsp; That is a nice piece of code though, and you could also simplify it a little bit:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if ObjectIDVal in valueDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for n in range (0,len(updateFieldsList)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[n+1] = valueDict[ObjectIDVal]&lt;N&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
&lt;/N&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am saying that you should use the Spatial Join tool and do not do embedded loops.&amp;nbsp; Embedded loops with the Search tools are the worst possible design for doing this task as far as I am concerned and will cost at least 10 times the processing overhead.&amp;nbsp; You won't come anywhere close to the Spatial Join performance with that approach.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Create a Spatial Join to an in-memory output and then use the TargetFID of that output to join back to the polygon ObjectID.&amp;nbsp; TargetFID 1 of the Spatial Join will match ObjectID 1 of the polygons.&amp;nbsp; The code does not create the spatial association, but it does the attribute transfer from the separate Spatial Join output in blazing speed through those join field associations.&amp;nbsp; Since the in-memory output is merely temporary, this is similar to using the scratch workspace of the geoprocessing tools, which is part of how ESRI optimizes their tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code you proposed would work for the example.&amp;nbsp; The actual code I normally use does not necessarily align the source field and target field numbering in the simple pattern of the example and typically includes parsing, concatenation or mathematical operations that are specific to each field.&amp;nbsp; The code is flexible and can be adapted to handle any pattern of transfer operation you can imagine.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325055#M25277</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T15:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325056#M25278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Create a Spatial Join to an in-memory output and then use the TargetFID of that output to join back to the polygon ObjectID.&amp;nbsp; TargetFID 1 of the Spatial Join will match ObjectID 1 of the polygons.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok cool, that sounds like a good method.&amp;nbsp; I like it.&amp;nbsp; I've mostly dealt with situations where I only want to transfer values if certain spatial &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;and&lt;/SPAN&gt;&lt;SPAN&gt; attribute criteria match (not what we're talking about here), which didn't seem like a good use for spatial joins.&amp;nbsp; However, now I'm thinking that there may be a good way to incorporate a method similar to this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2014 15:24:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325056#M25278</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2014-06-12T15:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325057#M25279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For the code intended to shorten the match up of fields from the source to the target I had to change it as shown below to avoid causing an index out of range error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if ObjectIDVal in valueDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for n in range (1,len(updateFieldsList)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow&lt;N&gt; = valueDict[ObjectIDVal][n-1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)&lt;/N&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:25:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/325057#M25279</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T15:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer attributes without spatial join</title>
      <link>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/1029597#M60056</link>
      <description>&lt;P&gt;I came across this thread when searching for the tool I have used several times in the past.&amp;nbsp; It can update data based on spatial relationships as well as others.&amp;nbsp; There is some setup involved, but it will do the trick.&lt;/P&gt;&lt;P&gt;&lt;A href="https://solutions.arcgis.com/shared/help/attribute-assistant/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://solutions.arcgis.com/shared/help/attribute-assistant/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 15:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/transfer-attributes-without-spatial-join/m-p/1029597#M60056</guid>
      <dc:creator>MichaelWalden1</dc:creator>
      <dc:date>2021-02-23T15:50:48Z</dc:date>
    </item>
  </channel>
</rss>

