<?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: Multiple Field calculations in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735177#M56956</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you, I didn't want to update it I was just want to take the value, I will just pass it to a txt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jan 2016 18:55:03 GMT</pubDate>
    <dc:creator>KONPETROV</dc:creator>
    <dc:date>2016-01-12T18:55:03Z</dc:date>
    <item>
      <title>Multiple Field calculations</title>
      <link>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735173#M56952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have severous viewsheds (view1, view2, view3 etc) and I want to calculate the percent of visible areas per viewshed. I have the following code but I always get zero "0" at the second for loop and i have been trying that for hours, any help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os
from arcpy import env
from arcpy.sa import *


#workspace = arcpy.GetParameterAsText(0)
arcpy.env.workspace = "C:Visibility/Calc_View/View"
ras = arcpy.ListRasters("view*", "GRID")
#cellsize = arcpy.GetParameterAsText(1)
fields = ["VALUE", "COUNT"]
for r in ras:
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor(r, fields) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; total = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; total = total + row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print r, total
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C = arcpy.da.UpdateCursor(r, fields, """"VALUE" = 1""")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in C:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent = row[1] / total
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print r, percent&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:20:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735173#M56952</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2021-12-12T07:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Mulitple Field calculations</title>
      <link>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735174#M56953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; percent = row[&lt;SPAN class="number"&gt;1&lt;/SPAN&gt;] /&amp;nbsp; float(total)&amp;nbsp; maybe or row[1] is zero...print them before your percent calc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jan 2016 16:31:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735174#M56953</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-12T16:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Mulitple Field calculations</title>
      <link>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735175#M56954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A view comments.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;row 8: C:Visibility/Calc_View/View is missing a forward slash (should be C:/Visibility/Calc_View/View)&lt;/LI&gt;&lt;LI&gt;I assume the rasters are of type integer, otherwise the raster will not have a value attribute table&lt;/LI&gt;&lt;LI&gt;When updating an attribute table of a raster, you need to use the old arcpy.UpdateCursor. arcpy.da.UpdateCursor does not support value attribute tables.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jan 2016 17:24:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735175#M56954</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-12T17:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Field calculations</title>
      <link>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735176#M56955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;aaa close, thank you a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jan 2016 18:53:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735176#M56955</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2016-01-12T18:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Field calculations</title>
      <link>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735177#M56956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you, I didn't want to update it I was just want to take the value, I will just pass it to a txt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jan 2016 18:55:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-field-calculations/m-p/735177#M56956</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2016-01-12T18:55:03Z</dc:date>
    </item>
  </channel>
</rss>

