<?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.da.InsertCursor geometry in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292577#M22638</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry that was just a typo (had cleaned up my code sample for the post, but missed that).&amp;nbsp; I am aware of the examples.&amp;nbsp; My code sample works if I remove SHAPE@ and row[1], i.e.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;input = arcpy.da.SearchCursor(fc, "*", where_clause=(expression))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="border: 0px;"&gt;output = arcpy.da.InsertCursor(tc,['risk'])&lt;/P&gt;&lt;P style="border: 0px;"&gt;for row in input:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;risk_factor = row[5]&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if risk_factor == "423123fasq":&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;output.insertRow(["high risk"])&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;... the above works, but produces output with no geometries of course.&amp;nbsp; When I try to add the geometries I get the crash.&amp;nbsp; Therefore I believe I am handling geometries incorrectly in some way.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Oct 2020 10:59:45 GMT</pubDate>
    <dc:creator>johnbrosowsky</dc:creator>
    <dc:date>2020-10-27T10:59:45Z</dc:date>
    <item>
      <title>arcpy.da.InsertCursor geometry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292574#M22635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to insert a feature into feature class based on feature in another feature class (both have identical structure) like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input = arcpy.da.SearchCursor(fc, "*", where_clause=(expression))&lt;BR /&gt;output = arcpy.da.InsertCursor(tc,['risk','SHAPE@'])&lt;/P&gt;&lt;P&gt;for row in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;risk_factor = row[5]&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if risk_factor == "423123fasq":&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;updateRows.insertRow([["high risk",row[1]])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... but I think I am not handling geometry correctly in insertRow as I get error "TypeError: cannot alter multipart geometry type".&amp;nbsp; They are polyline features.&amp;nbsp; Any ideas how to handle geometry correctly in this case?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2020 01:03:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292574#M22635</guid>
      <dc:creator>johnbrosowsky</dc:creator>
      <dc:date>2020-10-27T01:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor geometry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292575#M22636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;cursor isn't defined. (row 3).&amp;nbsp; There are code examples here&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/data-access/insertcursor-class.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/data-access/insertcursor-class.htm"&gt;InsertCursor—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2020 01:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292575#M22636</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-10-27T01:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor geometry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292576#M22637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I noticed you are using a wildcard for your fields.&amp;nbsp; I would avoid this as the fields may be in a different order from what you are expecting.&amp;nbsp; Also, when you say the features both have the identical structure, you mean both field names/types match along with the geometry type and spatial reference?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are only interested in the geometry and risk field, you might try something like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'inputFeature'&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# feature for SearchCursor&lt;/SPAN&gt;
tc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'outputFeature'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# feature for InsertCursor&lt;/SPAN&gt;

expression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'some expression'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# you should specify the fields for your search cursor (don't use wildcard)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# this way, you can be sure what they are when you reference them&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# also, assuming that fc and tc use the same field 'risk'&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;'SHAPE@'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'risk'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; 

&lt;SPAN class="comment token"&gt;# start an insert cursor&lt;/SPAN&gt;
insertCursor &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;InsertCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tc&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;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;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; where_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;expression&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;
        risk_factor &lt;SPAN class="operator 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="keyword token"&gt;if&lt;/SPAN&gt; risk_factor &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"423123fasq"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            &lt;SPAN class="comment token"&gt;# insert feature only if risk_factor is "423123fasq"&lt;/SPAN&gt;
            insertCursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insertRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:04:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292576#M22637</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T14:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor geometry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292577#M22638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry that was just a typo (had cleaned up my code sample for the post, but missed that).&amp;nbsp; I am aware of the examples.&amp;nbsp; My code sample works if I remove SHAPE@ and row[1], i.e.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;input = arcpy.da.SearchCursor(fc, "*", where_clause=(expression))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="border: 0px;"&gt;output = arcpy.da.InsertCursor(tc,['risk'])&lt;/P&gt;&lt;P style="border: 0px;"&gt;for row in input:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;risk_factor = row[5]&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if risk_factor == "423123fasq":&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;output.insertRow(["high risk"])&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;... the above works, but produces output with no geometries of course.&amp;nbsp; When I try to add the geometries I get the crash.&amp;nbsp; Therefore I believe I am handling geometries incorrectly in some way.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2020 10:59:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292577#M22638</guid>
      <dc:creator>johnbrosowsky</dc:creator>
      <dc:date>2020-10-27T10:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor geometry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292578#M22639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Randy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes input fc and output tc&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;field names/types match along with the geometry type and spatial reference.&amp;nbsp; My tc geodatabase is a file copy of my fc geodatabse so they are identical.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;The example you provided only copies the field contents, whereas I need to alter field contents in the target based on some algorithm.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;JB&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2020 11:05:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292578#M22639</guid>
      <dc:creator>johnbrosowsky</dc:creator>
      <dc:date>2020-10-27T11:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor geometry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292579#M22640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Randy -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Explicitly settings the "fields" property for both cursors did the trick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;JB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2020 13:29:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-geometry/m-p/292579#M22640</guid>
      <dc:creator>johnbrosowsky</dc:creator>
      <dc:date>2020-10-27T13:29:28Z</dc:date>
    </item>
  </channel>
</rss>

