<?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: Calculate geometry leads to KeyError: '#' in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169609#M64453</link>
    <description>&lt;P&gt;the help shows a list of lists, whereas an exported run shows a semi-colon delimited string.&amp;nbsp; maybe they are interchangeable&lt;/P&gt;&lt;P&gt;one field&lt;/P&gt;&lt;P&gt;arcpy.management.CalculateGeometryAttributes("pnts", "xs POINT_X", '', '', None, "SAME_AS_INPUT")&lt;/P&gt;&lt;P&gt;two fields&lt;/P&gt;&lt;P&gt;arcpy.management.CalculateGeometryAttributes("pnts", "xs POINT_X;ys POINT_Y", '', '', None, "SAME_AS_INPUT")&lt;/P&gt;&lt;P&gt;try [["new_field", "AREA_GEODESIC"]] since the help shows a list enclosed in a list for multiple parameters, perhaps it needs the enclosing list even if one is chosen&lt;/P&gt;</description>
    <pubDate>Sun, 01 May 2022 09:08:50 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-05-01T09:08:50Z</dc:date>
    <item>
      <title>Calculate geometry leads to KeyError: '#'</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169586#M64450</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy as a

a.env.overwriteOutput=1
a.env.workspace=r'F:\route\to\database\database.gbd'

a.management.MakeFeatureLayer('feature_class', 'feature_layer')
a.CalculateGeometryAttributes_management('feature_layer', ["new_field", "AREA_GEODESIC"], area_unit="SQUARE_KILOMETERS")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried to calculate it with both arcpy.management.CalculateGeometryAttribute and&amp;nbsp;arcpy.CalculateGeometryAttributes_management as in&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attributes.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attributes.htm&lt;/A&gt;&amp;nbsp;always led to:&lt;/P&gt;&lt;P&gt;KeyError: '#',&amp;nbsp;&lt;/P&gt;&lt;P&gt;Failed to execute (CalculateGeometryAttributes),&amp;nbsp;&lt;/P&gt;&lt;P&gt;geomValue = eval(geomCalcs[calcProp[1].upper()]).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I´m using&amp;nbsp;PythonWin 3.7.11 and ArcGIS Pro 2.9.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read this thread, checked my code again, didn't help. &lt;A href="https://community.esri.com/t5/python-questions/keyerror-when-calculating-geometry-in-arcpy/td-p/1030821" target="_blank"&gt;https://community.esri.com/t5/python-questions/keyerror-when-calculating-geometry-in-arcpy/td-p/1030821&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 06:02:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169586#M64450</guid>
      <dc:creator>kradijaf</dc:creator>
      <dc:date>2022-05-01T06:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate geometry leads to KeyError: '#'</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169594#M64451</link>
      <description>&lt;P&gt;Where are&amp;nbsp;&lt;/P&gt;&lt;P&gt;'feature_class', 'feature_layer'&lt;/P&gt;&lt;P&gt;defined?&lt;/P&gt;&lt;P&gt;CalculateGeometryAttributes(in_features, geometry_property, {Length_Unit}, {Area_Unit}, {Coordinate_System}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The parameters don't include field names&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 00:56:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169594#M64451</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-05-01T00:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate geometry leads to KeyError: '#'</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169605#M64452</link>
      <description>&lt;P&gt;&lt;SPAN&gt;'feature_class', 'feature_layer' are not variables, 'feature_class' exists in .gdb. Not sure I understand what you mean with "The parameters don't include field names", field name should be 1st part of 2nd parameter.a&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 05:53:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169605#M64452</guid>
      <dc:creator>kradijaf</dc:creator>
      <dc:date>2022-05-01T05:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate geometry leads to KeyError: '#'</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169609#M64453</link>
      <description>&lt;P&gt;the help shows a list of lists, whereas an exported run shows a semi-colon delimited string.&amp;nbsp; maybe they are interchangeable&lt;/P&gt;&lt;P&gt;one field&lt;/P&gt;&lt;P&gt;arcpy.management.CalculateGeometryAttributes("pnts", "xs POINT_X", '', '', None, "SAME_AS_INPUT")&lt;/P&gt;&lt;P&gt;two fields&lt;/P&gt;&lt;P&gt;arcpy.management.CalculateGeometryAttributes("pnts", "xs POINT_X;ys POINT_Y", '', '', None, "SAME_AS_INPUT")&lt;/P&gt;&lt;P&gt;try [["new_field", "AREA_GEODESIC"]] since the help shows a list enclosed in a list for multiple parameters, perhaps it needs the enclosing list even if one is chosen&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 09:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169609#M64453</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-05-01T09:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate geometry leads to KeyError: '#'</title>
      <link>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169615#M64454</link>
      <description>&lt;P&gt;&lt;FONT face="courier new,courier"&gt;arcpy.CalculateGeometryAttributes_management&lt;/FONT&gt; is simply an alias for &lt;FONT face="courier new,courier"&gt;arcpy.management.CalculateGeometryAttributes&lt;/FONT&gt;, so you should never get different results between them.&amp;nbsp; If you do get different results, there is a ArcPy defect somewhere.&lt;/P&gt;&lt;P&gt;According to the documentation you reference, the &lt;FONT face="courier new,courier"&gt;geometry_property&lt;/FONT&gt; parameter should be in the form of a Value Table, which is one form of a multi-value input.&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/working-with-multivalue-inputs.htm" target="_blank"&gt;Working with multivalue inputs—ArcGIS Pro | Documentation&lt;/A&gt; .&amp;nbsp; Working with Value Table objects is quite clunky, so there are Python list and string representations of them, which is what you commonly see in documentation examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 15:46:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-geometry-leads-to-keyerror/m-p/1169615#M64454</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2022-05-01T15:46:46Z</dc:date>
    </item>
  </channel>
</rss>

