<?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: arcpy search/update cursor not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39758#M3165</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Isn't this the spatial overlay? ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1430272741338784 jive_text_macro" data-renderedposition="52.399993896484375_8_912_34" jivemacro_uid="_1430272741338784"&gt;&lt;OL class="dp-py" start="1"&gt;&lt;LI&gt;&lt;SPAN class="comment"&gt;# Make a layer and select soils which fall within the Landuse polygon&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;arcpy.SelectLayerByLocation_management(&lt;SPAN class="string"&gt;'Soils_lyr', 'within', Landuse)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have ArcGIS Advanced, but I would like to do this in python. I have been referring to this website;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.e-education.psu.edu/geog485/node/130" title="https://www.e-education.psu.edu/geog485/node/130"&gt;3.2.4 Retrieving records using a spatial query | GEOG 485: GIS Programming and Automation&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Apr 2015 01:57:14 GMT</pubDate>
    <dc:creator>MarkWisniewski</dc:creator>
    <dc:date>2015-04-29T01:57:14Z</dc:date>
    <item>
      <title>arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39752#M3159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im running my script in ArcGIS 10.2 and the dialog window says completed, but the empty fields in the 'SoilsType' row of the 'mSoils' Feature Class aren't getting populated with the values from the 'SoilsType' field from the 'mLanduse' Feature Class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;cur &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;da&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;mLanduse&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; lField&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; row &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; cur&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
 cur2 &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;da&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;UpdateCursor&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;mSoils&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; sField&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
 &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; row2 &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; cur2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; row2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;==&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;''&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;or&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; row2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;is&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;None&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
&amp;nbsp; row2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; lField
&amp;nbsp; cur2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;updateRow&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;row2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:32:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39752#M3159</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2021-12-10T21:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39753#M3160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ernst,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you are trying to update the Soils feature class that have no value for the SoilType with values from a LandUse polygon.&amp;nbsp; Instead of using an updateCursor, I would recommend using the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/spatial-join.htm"&gt;Spatial Join&lt;/A&gt; tool.&amp;nbsp; You can then join the output from this tool to the Soils feature class, and update the empty rows using the Field Calculator.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 13:48:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39753#M3160</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-04-28T13:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39754#M3161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are correct with my workflow, except the SoilType Field has values in the Landuse Polygon. My query is trying to retrieve just the blank fields in the SoilType Field in the Soils Polygon. Is my workflow wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 23:11:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39754#M3161</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-28T23:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39755#M3162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure your soil types contain blanks or null? (The geodatabase supports null values, unlike shapefiles.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This query would select both blanks and those that have null values:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14302644718199079 jive_text_macro" data-renderedposition="71_8_912_16" jivemacro_uid="_14302644718199079"&gt;&lt;P&gt;query = &lt;SPAN class="string"&gt;"SoilType = '' or SoilType IS NULL"&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I think your workflow is wrong, including your use of arcpy.UpdateCursor, the construct you are using with row[0] etc. is what you would use with arcpy.da.UpdateCursor, not the old (10.0) arcpy.UpdateCursor method. Where is the variable LandUse being populated?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would go with Jake's suggestion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 23:42:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39755#M3162</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-04-28T23:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39756#M3163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curtis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not seeing any NULL values, and when I do a Definition Query and select Get Unique values '' is the first option, so only blank fields are present. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not currently populating the LandUse variable, do I need another MakeFeatureLayer for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 01:43:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39756#M3163</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-29T01:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39757#M3164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue I'm seeing here is you seem to be trying to transfer land use variables over to your blank soil polygons, but you're not doing any spatial overlay in your script, unless I'm missing something. That's what Jake was getting at by suggesting the Join By Location tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have an ArcGIS Advanced ("ArcInfo") license you could probably solve this problem best with the Identity tool followed by some field calculations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 01:50:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39757#M3164</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-04-29T01:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39758#M3165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Isn't this the spatial overlay? ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1430272741338784 jive_text_macro" data-renderedposition="52.399993896484375_8_912_34" jivemacro_uid="_1430272741338784"&gt;&lt;OL class="dp-py" start="1"&gt;&lt;LI&gt;&lt;SPAN class="comment"&gt;# Make a layer and select soils which fall within the Landuse polygon&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;arcpy.SelectLayerByLocation_management(&lt;SPAN class="string"&gt;'Soils_lyr', 'within', Landuse)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have ArcGIS Advanced, but I would like to do this in python. I have been referring to this website;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.e-education.psu.edu/geog485/node/130" title="https://www.e-education.psu.edu/geog485/node/130"&gt;3.2.4 Retrieving records using a spatial query | GEOG 485: GIS Programming and Automation&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 01:57:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39758#M3165</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-29T01:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39759#M3166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is just a spatial &lt;EM&gt;selection&lt;/EM&gt;, you are trying to copy attribute data over. To do that you need to do a "real" spatial overlay to create a link between the soil and land use polygon features (ie a "join").&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Identity (and related tools Intersect, Erase, etc) are tools you can run interactively or access from arcpy, see the examples in the help. (They require an ArcInfo license to run.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 02:01:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39759#M3166</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-04-29T02:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39760#M3167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But can't I use updateCursor to update existing fields in the table?;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.e-education.psu.edu/geog485/node/136" title="https://www.e-education.psu.edu/geog485/node/136"&gt;3.3.1 Updating existing records | GEOG 485: GIS Programming and Automation&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 02:11:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39760#M3167</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-29T02:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39761#M3168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, but where are you going to get the land use data value to update the soil polygon field? You need to somehow relate your blank soil polygons to the land use polygons that overlap it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 02:13:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39761#M3168</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-04-29T02:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39762#M3169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, I see what you are saying Curtis, but I thought that was all achieved with the SelectLayerByLocation. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 02:21:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39762#M3169</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-29T02:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy search/update cursor not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39763#M3170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ernst, select layer by location will simply select all the soil layer polygons that are within all your land use polygons. You could use this in your for loop, so that you select each feature, and then select by location the feature in the other class that is within your selected feature.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 02:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-search-update-cursor-not-working/m-p/39763#M3170</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-04-29T02:47:02Z</dc:date>
    </item>
  </channel>
</rss>

