<?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 Iterate through features and select by location in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695906#M53929</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;I have a layer with Zoning Overlays. I have a layer with parcels. I need to iterate through zoning Overlay, select the parcels falling inside, add a new field to the parcels Feature class and add some text to the selected fields, then repeat for the next zoning overlay. The loop works, insofar but it stops with a particular error that is not specific enough.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;The code runs until it has to assign the values to the second field.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;Please see below for more details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Import arcpy

&lt;SPAN style="color: #808080;"&gt;# Set two geoprocessing environments
&lt;/SPAN&gt;arcpy.env.workspace = &lt;SPAN style="color: #6a8759;"&gt;r"D:\APRX, MXDS\Geo_Engine_Zoning_Project\Austin_Geo_Engine.gdb"
&lt;/SPAN&gt;arcpy.env.overwriteOutput = &lt;SPAN style="color: #cc7832;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# List of fields in Merged_Ovelays FC
&lt;/SPAN&gt;fields = [&lt;SPAN style="color: #6a8759;"&gt;"OBJECTID"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"zoning_ove"&lt;/SPAN&gt;]

&lt;SPAN style="color: #808080;"&gt;# Convert austin_parcels feature class to feature layer
&lt;/SPAN&gt;arcpy.MakeFeatureLayer_management(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;# Convert Merged_Overlays feature class to feature layer
&lt;/SPAN&gt;arcpy.MakeFeatureLayer_management(&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;# arcpy.da.SearchCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;fields) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select = &lt;SPAN style="color: #6a8759;"&gt;"OBJECTID = {}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;])
&lt;SPAN style="color: #808080;"&gt;# SelectLayerByAttribute(in_layer_or_view, {selection_type}, {where_clause}, {invert_where_clause})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.SelectLayerByAttribute(&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;select)
&lt;SPAN style="color: #808080;"&gt;# SelectLayerByLocation(in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}, {invert_spatial_relationship})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.SelectLayerByLocation(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"HAVE_THEIR_CENTER_IN"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;# Syntax: AddField(in_table, field_name, field_type, {field_precision}, {field_scale}, {field_length}, {field_alias}, {field_is_nullable}, {field_is_required}, {field_domain})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.AddField(&lt;SPAN style="color: #6a8759;"&gt;'austin_parcels_layer'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Overlay_{}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"TEXT"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;# CalculateField(in_table, field, expression, {expression_type}, {code_block}, {field_type})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.CalculateField(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Overlay_{}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'"Overlay_{}".format(row[1])'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;I am getting the following error and I am not sure how to fix it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 24, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 4230, in CalculateField&lt;BR /&gt;raise e&lt;BR /&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 4227, in CalculateField&lt;BR /&gt;retval = convertArcObjectToPythonObject(gp.CalculateField_management(*gp_fixargs((in_table, field, expression, expression_type, code_block), True)))&lt;BR /&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in &amp;lt;lambda&amp;gt;&lt;BR /&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;BR /&gt;arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (&lt;A href="http://esriurl.com/support" target="_blank"&gt;http://esriurl.com/support&lt;/A&gt;) to Report a Bug, and refer to the error help for potential solutions or workarounds.&lt;BR /&gt;Invalid pointer&lt;BR /&gt;Failed to execute (CalculateField).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it something with my line of code that is not working?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.management.CalculateField(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Overlay_{}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'"Overlay_{}".format(row[1])'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;My goal is to:&lt;/P&gt;&lt;P&gt;Copy the text from the selected feature below:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="197" src="https://community.esri.com/legacyfs/online/484218_pastedImage_1.jpg" style="border: 0px; margin: 2px 20px 0px;" width="397" /&gt;&lt;/P&gt;&lt;P&gt;and put it into the newly created field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" height="163" src="https://community.esri.com/legacyfs/online/484219_pastedImage_2.jpg" style="border: 0px; margin: 2px 20px 0px;" width="453" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate your help,&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;Natalia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 05:17:43 GMT</pubDate>
    <dc:creator>NataliaGutierrez1</dc:creator>
    <dc:date>2021-12-12T05:17:43Z</dc:date>
    <item>
      <title>Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695906#M53929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;I have a layer with Zoning Overlays. I have a layer with parcels. I need to iterate through zoning Overlay, select the parcels falling inside, add a new field to the parcels Feature class and add some text to the selected fields, then repeat for the next zoning overlay. The loop works, insofar but it stops with a particular error that is not specific enough.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;The code runs until it has to assign the values to the second field.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: 0pt; margin-bottom: 0pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d; background-color: #ffffff; font-weight: 400; text-decoration: none;"&gt;Please see below for more details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Import arcpy

&lt;SPAN style="color: #808080;"&gt;# Set two geoprocessing environments
&lt;/SPAN&gt;arcpy.env.workspace = &lt;SPAN style="color: #6a8759;"&gt;r"D:\APRX, MXDS\Geo_Engine_Zoning_Project\Austin_Geo_Engine.gdb"
&lt;/SPAN&gt;arcpy.env.overwriteOutput = &lt;SPAN style="color: #cc7832;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# List of fields in Merged_Ovelays FC
&lt;/SPAN&gt;fields = [&lt;SPAN style="color: #6a8759;"&gt;"OBJECTID"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"zoning_ove"&lt;/SPAN&gt;]

&lt;SPAN style="color: #808080;"&gt;# Convert austin_parcels feature class to feature layer
&lt;/SPAN&gt;arcpy.MakeFeatureLayer_management(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;# Convert Merged_Overlays feature class to feature layer
&lt;/SPAN&gt;arcpy.MakeFeatureLayer_management(&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;# arcpy.da.SearchCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;fields) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select = &lt;SPAN style="color: #6a8759;"&gt;"OBJECTID = {}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;])
&lt;SPAN style="color: #808080;"&gt;# SelectLayerByAttribute(in_layer_or_view, {selection_type}, {where_clause}, {invert_where_clause})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.SelectLayerByAttribute(&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;select)
&lt;SPAN style="color: #808080;"&gt;# SelectLayerByLocation(in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}, {invert_spatial_relationship})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.SelectLayerByLocation(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"HAVE_THEIR_CENTER_IN"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;# Syntax: AddField(in_table, field_name, field_type, {field_precision}, {field_scale}, {field_length}, {field_alias}, {field_is_nullable}, {field_is_required}, {field_domain})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.AddField(&lt;SPAN style="color: #6a8759;"&gt;'austin_parcels_layer'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Overlay_{}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"TEXT"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;# CalculateField(in_table, field, expression, {expression_type}, {code_block}, {field_type})
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.management.CalculateField(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Overlay_{}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'"Overlay_{}".format(row[1])'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;I am getting the following error and I am not sure how to fix it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 24, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 4230, in CalculateField&lt;BR /&gt;raise e&lt;BR /&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 4227, in CalculateField&lt;BR /&gt;retval = convertArcObjectToPythonObject(gp.CalculateField_management(*gp_fixargs((in_table, field, expression, expression_type, code_block), True)))&lt;BR /&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in &amp;lt;lambda&amp;gt;&lt;BR /&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;BR /&gt;arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (&lt;A href="http://esriurl.com/support" target="_blank"&gt;http://esriurl.com/support&lt;/A&gt;) to Report a Bug, and refer to the error help for potential solutions or workarounds.&lt;BR /&gt;Invalid pointer&lt;BR /&gt;Failed to execute (CalculateField).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it something with my line of code that is not working?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.management.CalculateField(&lt;SPAN style="color: #6a8759;"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"Overlay_{}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'"Overlay_{}".format(row[1])'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;My goal is to:&lt;/P&gt;&lt;P&gt;Copy the text from the selected feature below:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="197" src="https://community.esri.com/legacyfs/online/484218_pastedImage_1.jpg" style="border: 0px; margin: 2px 20px 0px;" width="397" /&gt;&lt;/P&gt;&lt;P&gt;and put it into the newly created field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" height="163" src="https://community.esri.com/legacyfs/online/484219_pastedImage_2.jpg" style="border: 0px; margin: 2px 20px 0px;" width="453" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate your help,&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;Natalia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:17:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695906#M53929</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2021-12-12T05:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695907#M53930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For your select query I think OBJECTID should be enclosed in quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select = ' " ' + "OBJECTID" + ' " '&amp;nbsp; + " = " + str(row[0])&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2020 23:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695907#M53930</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-03-05T23:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695908#M53931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think arcpy.env.workspace can take "two geoprocessing environments".&amp;nbsp; Perhaps the comma in the workspace variable is causing the "something unexpected" error.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Set two geoprocessing environments&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\APRX, MXDS\Geo_Engine_Zoning_Project\Austin_Geo_Engine.gdb"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:17:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695908#M53931</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T05:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695909#M53932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I took another look at your code and was wondering if you intended to create a new field in your parcels layer for each feature in the Merged_Overlays_Layer? This could be a lot of fields to add.&amp;nbsp; Or did you intend to create a field and populate it with the name/ID of the overlay feature the parcel was located in?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the CalculateField, I believe the single quotes should be inside the double quotes for the third parameter.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;'"Overlay_{}".format(row[1])'
# try instead:
"'Overlay_{}'".format(row[1])&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I was experimenting in Desktop and needed to add a 4th parameter "PYTHON_9.3" which is supposed to be optional, but without it I was getting an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For my testing I was using the following code in ArcMap's Python window.&amp;nbsp; Changes are probably required, but it may give you some ideas.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;parcels &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'austin_parcels_layer'&lt;/SPAN&gt;
pField &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Overlay'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# new field for overlay feature name/ID&lt;/SPAN&gt;

overlay &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Merged_Overlays_layer'&lt;/SPAN&gt;
oFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'OBJECTID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'zoning_ove'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddField&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parcels&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; pField&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'TEXT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;100&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# add text field with length of 100&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;overlay&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;oFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        select &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"OBJECTID = {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;overlay&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;select&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByLocation&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parcels&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"HAVE_THEIR_CENTER_IN"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; overlay&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parcels&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; pField&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'{}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PYTHON_9.3"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;overlay&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CLEAR_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# clear any selections&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parcels&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CLEAR_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:17:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695909#M53932</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T05:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695910#M53933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/functions/addfielddelimiters.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/functions/addfielddelimiters.htm"&gt;AddFieldDelimiters—ArcPy Functions | ArcGIS Desktop&lt;/A&gt; will still add double quotes around file geodatabase and shape file field names, they haven't been necessary for a while.&amp;nbsp; The ArcMap &lt;A class="link-titled" href="https://desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm" title="https://desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm"&gt;SQL reference for query expressions used in ArcGIS—Help | ArcGIS for Desktop (ArcMap)&lt;/A&gt; documentation states:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;For File geodatabase data you can enclose your field names in double quotes, but it's generally not needed.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The ArcGIS Pro &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm" title="https://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm"&gt;SQL reference for query expressions used in ArcGIS—ArcGIS Pro | ArcGIS Desktop (Pro)&lt;/A&gt; documentation has gone one step further and completely removed the Fields section so there are no references to field delimiters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2020 14:43:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695910#M53933</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-03-06T14:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695911#M53934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Randy, I don't think the OP is trying to pass two values, the comma is in the name of the folder!&amp;nbsp; Although allowed by Windows and ArcGIS, I think most would argue commas are a bad idea in file paths.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2020 14:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695911#M53934</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-03-06T14:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695912#M53935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your first Select Layer by Attribute is unnecessary and may cause issues if you are changing the selection of a layer while iterating over the layer with a Search Cursor.&amp;nbsp; Just add "SHAPE@" to your list of field names to get the shape you are interested in and drop the first Select Layer By Attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you really want to add a new field for each loop in the Search Cursor?&amp;nbsp; Assuming austin_parcel_layer geometries can only have their center in one merged_overlays_layer, you will be creating an unnecessarily sparse matrix of columns and rows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2020 14:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695912#M53935</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-03-06T14:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695913#M53936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do what all those guys suggest....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2020 15:03:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695913#M53936</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-03-06T15:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695914#M53937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joshua, Randy and David,&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did need to add a new field for each loop in the Search Cursor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code that ended up working. I am sharing it just in case anyone needs it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had to fix some of the raw data for it to work correctly. I had to modify the names of the cell values to have underscores instead of spaces.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Import arcpy

&lt;SPAN class="comment token"&gt;# Set two geoprocessing environments&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\APRX_MXDS\Geo_Engine_Zoning_Project\Austin_Geo_Engine.gdb"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# List of fields in Merged_Ovelays FC&lt;/SPAN&gt;
fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"OBJECTID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"zoning_ove"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Convert austin_parcels feature class to feature layer&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"austin_parcels"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Convert Merged_Overlays feature class to feature layer&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Merged_Overlays"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# arcpy.da.SearchCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        select &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"OBJECTID = {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# SelectLayerByAttribute(in_layer_or_view, {selection_type}, {where_clause}, {invert_where_clause})&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; select&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# SelectLayerByLocation(in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}, {invert_spatial_relationship})&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByLocation&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"HAVE_THEIR_CENTER_IN"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Syntax: AddField(in_table, field_name, field_type, {field_precision}, {field_scale}, {field_length}, {field_alias}, {field_is_nullable}, {field_is_required}, {field_domain})&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddField&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'austin_parcels_layer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Overlay_{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TEXT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# CalculateField(in_table, field, expression, {expression_type}, {code_block}, {field_type})&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Overlay_{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'Overlay_{}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PYTHON_3"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Merged_Overlays_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CLEAR_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# clear any selections&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"austin_parcels_layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CLEAR_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695914#M53937</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2021-12-12T05:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695915#M53938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2020 17:19:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695915#M53938</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-03-06T17:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695916#M53939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These guys are my go-to python&amp;nbsp;compradres (along with &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;‌) and all of them have younger eyes and could read your code better than I could!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2020 17:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695916#M53939</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-03-06T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through features and select by location</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695917#M53940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/3420" target="_blank"&gt;Joshua Bixby&lt;/A&gt; for the comment about using "SHAPE@".&amp;nbsp;&amp;nbsp; The &lt;CODE&gt;SelectLayerByAttribute &lt;/CODE&gt;step is not necessary.&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;oFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'OBJECTID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'zoning_ove'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SHAPE@'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
 
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;overlay&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;oFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Processing feature {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByLocation&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parcels&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"HAVE_THEIR_CENTER_IN"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# row[2] is SHAPE@&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parcels&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; pField&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'{}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PYTHON_9.3"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:17:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-features-and-select-by-location/m-p/695917#M53940</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T05:17:54Z</dc:date>
    </item>
  </channel>
</rss>

