<?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   SHAPE_length and SHAPE_Area fields are shown as zero in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97392#M7534</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This thread is fairly old, so it is hard to say how it got marked as "Assumed Answered" instead of "Answered."&amp;nbsp; That said, even if it was "Answered" Jose's final post would not be marked as the answer.&amp;nbsp; Jose's final post explains what he did with the answer to get his script working, Jose didn't identify the root cause and solution, which was how the SHAPE token was being used with the cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Dec 2019 15:24:48 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-12-16T15:24:48Z</dc:date>
    <item>
      <title>arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97381#M7523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal is to find all the records that were deleted&amp;nbsp; comparing yesterday and today versions of the same feature class.&lt;/P&gt;&lt;P&gt;I am running a python script that uses cursors. With the curosr I am able to identigy the record that was deleted because it was in the featuer class yesterday but not today.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I insert a new record using "arcpy.da.InsertCursor", "curAppend.insertRow( rowYesterday)",&amp;nbsp; two fields SHAPE_length and SHAPE_Area are equal to 0. ArcCatalog does not show any shape information in the preview, but shows only attributes in the Table view. It looks like features were created witout spatial data,&amp;nbsp; only attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dsc = arcpy.Describe(Layer_DEFAULT)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = dsc.fields
&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all field names except the OID field
&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldnames = [field.name for field in fields if field.name != dsc.OIDFieldName]


&amp;nbsp;&amp;nbsp;&amp;nbsp; curYesterday = arcpy.da.SearchCursor(Layer_DEFAULT, fieldnames)
&amp;nbsp;&amp;nbsp;&amp;nbsp; curToday = arcpy.da.SearchCursor(Layer_PREPROD, fieldnames)
&amp;nbsp;&amp;nbsp;&amp;nbsp; curAppend = arcpy.da.InsertCursor(Layer_D,fieldnames)


&amp;nbsp;&amp;nbsp;&amp;nbsp; for&amp;nbsp; rowYesterday in curYesterday:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # layerID&amp;nbsp; = layerID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # datetimeVal&amp;nbsp; = CRTDATE
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerID = rowYesterday[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datetimeVal = rowYesterday[4]


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print rowYesterday[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print rowYesterday[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print rowYesterday[3]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print rowYesterday[4]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print rowYesterday[5]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print rowYesterday[0]






&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if datetimeVal is not None:


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = '"AGMID" = %s' % (layerID)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; srcToday = arcpy.da.SearchCursor(Layer_PREPROD, fieldnames, whereClause)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = 0


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&amp;nbsp; rowToday in srcToday:


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; rowToday[4] == rowYesterday[4]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + 1


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if count == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Record for Delete :", layerID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.info('Delete ' + whereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curAppend.insertRow( rowYesterday)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:06:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97381#M7523</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2021-12-11T06:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97382#M7524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The thing that jumps out to me is that you start several cursors, never use one of them, and never delete them. You should use 'with' syntax, which cleans up your cursors even if they error out, and avoid seemingly random errors - which you seem to be experiencing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2016 21:09:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97382#M7524</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-08-04T21:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97383#M7525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;get the shapefieldName explicitly from the featureclass describe object&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/featureclass-properties.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/featureclass-properties.htm"&gt;FeatureClass properties—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2016 21:09:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97383#M7525</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-04T21:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97384#M7526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are running into a couple different issues:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Your list comprehension for building a list of field names excludes the OID field, but it still includes the SHAPE_Length and SHAPE_Area fields.&amp;nbsp; The user doesn't directly populate these fields, they are automatically calculated on the backend, except with in-memory workspaces.&amp;nbsp; It is fine to retrieve the fields and use the values, but you should not try to populate the values for new records.&lt;/LI&gt;&lt;LI&gt;Although the shape field's name may be, "SHAPE," passing "SHAPE" to a cursor doesn't actually retrieve the geometry, it retrieves a tuple of the feature's centroid.&amp;nbsp; Passing "SHAPE" is the same as passing "SHAPE@XY".&amp;nbsp;&amp;nbsp; When you pass "SHAPE" to the insert cursor, you are creating a point, which has no area nor length.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 02:38:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97384#M7526</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-05T02:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97385#M7527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua you can use Shape@ to return the shape, then get its area/perimeter/length for poly* features. The advantage of retrieving the shape field directly, is that it works wih shapefile which have no auto-calculated shape properties.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 02:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97385#M7527</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-05T02:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97386#M7528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, I agree.&amp;nbsp; My comments to the OP were to point out that he is likely not retrieving what he thinks he is in terms of geometry.&amp;nbsp; The OP used arcpy.Describe to retrieve the name of the shape field, but he did not add the @ symbol.&amp;nbsp; I may be incorrect, but the code and description of the problem made me think he wanted to retrieve the actual geometry and not a tuple of a feature's centroid. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 02:58:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97386#M7528</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-05T02:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97387#M7529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-userid="19932" data-username="dkwiens" href="https://community.esri.com/people/dkwiens"&gt;dkwiens&lt;/A&gt;,&amp;nbsp; this is a piece of the code not the whole script. I delete the cursors at the end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 11:57:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97387#M7529</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2016-08-05T11:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97388#M7530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan, if I understand correctly I need to use "Shape@" to populate all shape fields when creating a polygon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 12:08:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97388#M7530</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2016-08-05T12:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97389#M7531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;writing geometries&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/insertcursor-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/insertcursor-class.htm"&gt;InsertCursor—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/writing-geometries.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/writing-geometries.htm"&gt;Writing geometries—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;require special attention.&amp;nbsp; The area and length (for polygons) will be populated once the geometry is created and the editing is done.&amp;nbsp; If you want a point representation of the polygon, then use the appropriate option in the first link. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 12:13:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97389#M7531</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-05T12:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97390#M7532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just harcoded the list of fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; fieldnames = ['AGMID', 'MODBY', 'MODDATE', 'CRTBY', 'CRTDATE', 'SHAPE@']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and it works&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 13:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97390#M7532</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2016-08-05T13:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97391#M7533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why isn't this marked as the correct answer? I understand that hardcoding is not ideal but it solved the issue that shown here.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2019 02:25:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97391#M7533</guid>
      <dc:creator>JacobHelfman1</dc:creator>
      <dc:date>2019-12-15T02:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.InsertCursor   SHAPE_length and SHAPE_Area fields are shown as zero</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97392#M7534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This thread is fairly old, so it is hard to say how it got marked as "Assumed Answered" instead of "Answered."&amp;nbsp; That said, even if it was "Answered" Jose's final post would not be marked as the answer.&amp;nbsp; Jose's final post explains what he did with the answer to get his script working, Jose didn't identify the root cause and solution, which was how the SHAPE token was being used with the cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Dec 2019 15:24:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-shape-length-and-shape-area/m-p/97392#M7534</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-12-16T15:24:48Z</dc:date>
    </item>
  </channel>
</rss>

