<?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: Layer and calculate in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128124#M9967</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.workspace = r"&amp;lt;some/data/location&amp;gt;"

fc =&amp;nbsp; 'Parcels.shp'
flyr = 'Parcels'
field = 'Acres'
expression = '!shape.area@acres!'

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc, flyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(flyr, 'Acres', 'DOUBLE')
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(flyr, field, expression, 'PYTHON')
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:14:50 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-11T07:14:50Z</dc:date>
    <item>
      <title>Layer and calculate</title>
      <link>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128123#M9966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would basically like to add an "Acres" field to the "selected" layer on the TOC regardless to the layers location on the TOC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am aware on how to do this with VBA but not with Python. I can't seem to find an arcy equivalent to&amp;nbsp; pMxDoc.Selectedlayers to start off with. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be great!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2012 14:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128123#M9966</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2012-08-09T14:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Layer and calculate</title>
      <link>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128124#M9967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.workspace = r"&amp;lt;some/data/location&amp;gt;"

fc =&amp;nbsp; 'Parcels.shp'
flyr = 'Parcels'
field = 'Acres'
expression = '!shape.area@acres!'

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fc, flyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(flyr, 'Acres', 'DOUBLE')
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(flyr, field, expression, 'PYTHON')
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:14:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128124#M9967</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Layer and calculate</title>
      <link>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128125#M9968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This would only work if there was parcels.shp layer correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to do this to any layer that is selected on the TOC?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the reply i really appreciate it!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2012 15:35:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128125#M9968</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2012-08-09T15:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Layer and calculate</title>
      <link>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128126#M9969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am sorry, I completely misunderstood what you meant.&amp;nbsp; I'm sure that is possible, however I do not know how to do that.&amp;nbsp; I'm sure someone will see this thread and can post how to do this.&amp;nbsp; In the meantime you could look at the arcpy.mapping modules information.&amp;nbsp; You could probably find the arcpy solution in there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Introduction_to_arcpy_mapping/00s300000032000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Introduction_to_arcpy_mapping/00s300000032000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2012 16:03:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-and-calculate/m-p/128126#M9969</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-08-09T16:03:39Z</dc:date>
    </item>
  </channel>
</rss>

