<?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: Problem with If , For statements in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108445#M8374</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think I fully understand you,&lt;/P&gt;&lt;P&gt;I am seeing many errors in&amp;nbsp; the code, it would be better if you could put it in Python context.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;outViewshed.save(mypath&lt;/SPAN&gt;&lt;EM style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;"view"&lt;/EM&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; str(count)) here it should be (mypath + "view" + str(count))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;count = count + int(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;point = Pnta + str(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Unfortunately my code isn't right as well I can get only one Viewshed&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Nov 2015 18:35:41 GMT</pubDate>
    <dc:creator>KONPETROV</dc:creator>
    <dc:date>2015-11-23T18:35:41Z</dc:date>
    <item>
      <title>Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108431#M8360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello I have created this code to run a number of viewsheds for a group of points shp Pnt1, Pnt2... and a group of&amp;nbsp; Dems, dem1, dem2 etc. For some reason I don't have any results but I don't know why. This is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True 

env.workspace = arcpy.GetParameterAsText(0)
out = arcpy.GetParameterAsText(1)
fc = arcpy.ListFeatureClasses("Pnt*", "Point")
ras = arcpy.ListRasters("dem*", "GRID")
point = "Pntclip_pol1"
dem = "dempol1"
i = 1
for shp in fc:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for raster in ras:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (shp == point and raster == dem):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inRaster = raster
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inObserverFeatures = shp
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed = Viewshed(inRaster, inObserverFeatures, "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed.save(out + "\\" + "view" + str(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = int(i) + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = "Pntclip_pol" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dem = "clippol" + str(i)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:32:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108431#M8360</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2021-12-11T06:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108432#M8361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you throw in some print statements to record the names of the source files and destination files to make sure there is anything to generate...especially OutViewshed.&amp;nbsp; Also line 23 doesn't appear to be indented properly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 11:25:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108432#M8361</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-11-23T11:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108433#M8362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are right about 23 line I didn't cope paste it well.&lt;/P&gt;&lt;P&gt;This is the form of my files &lt;/P&gt;&lt;P&gt;env.workspace = "c:/A/Calc_view"&lt;/P&gt;&lt;P&gt;out = "c:/A/Calc_view/Results"&lt;/P&gt;&lt;P&gt;my points is in the form of Pntclip_pol1, Pointclip_pol2...&lt;/P&gt;&lt;P&gt;and rasters in the form of dempol1, dempol2...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 11:38:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108433#M8362</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T11:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108434#M8363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually when&amp;nbsp; i want to print for example&lt;/P&gt;&lt;P&gt;print shp or &lt;/P&gt;&lt;P&gt;print raster I don't get anything back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 12:48:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108434#M8363</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T12:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108435#M8364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is because there is nothing... for example, the works...it just doesn't do what you want because the list of objects in the ras list is empty and it printed exactly that... for each 'nothing' print nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; ras = []
&amp;gt;&amp;gt;&amp;gt; for raster in ras:
...&amp;nbsp; print(ras)
... 
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:32:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108435#M8364</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T06:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108436#M8365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan is right, when I run lists I always check counts to make sure it has data and matches what I think it should be..&lt;/P&gt;&lt;P&gt;Basic run. put in print statements for debugging, you can watch the progress and later comment or remove them when it works. Add text to help follow it, use the AddMessage option if you want to see the message in the results window.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace =&amp;nbsp; r"\\gis01\GISTemp\temp.gdb"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fcList = arcpy.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;theCount = len(fcList)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print theCount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for fc in fcList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ordinary least squares USE&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(" Features in my list "+ theCount)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 14:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108436#M8365</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2015-11-23T14:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108437#M8366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did that but print works only after the first loop. If I put the second for loop I don't have any result. My task is to use for the viewsheds first the Pnt1 with Dem1 then Pnt2 with Dem2 etc. If you have any other suggestion that would be welcomed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 16:11:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108437#M8366</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T16:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108438#M8367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok first of all I must have my data in a folder and not in a folder inside the other folder* of course&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 16:41:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108438#M8367</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T16:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108439#M8368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thoughts were if either your FC or ras list were empty it would fail, so I check those first.. I’d put a print with a count first. This confirms the data is there..  If you put a print after&lt;/P&gt;&lt;P&gt;for shp in fc:&lt;/P&gt;&lt;P&gt;    print shp  you could watch for errors as you would know the file being processes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;for raster in ras:&lt;/P&gt;&lt;P&gt;     print ras would tell you which raster is being processed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both of these help rule out data issues, as everyone always looks at the code when it might be a simple data issue. No use troubleshooting code if this is the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For grins, comment out lines 6 + 7,  just write the variables in as text until you get it and running  This takes out dumb input errors, like did they use the backslash or forwardslash, python is funny about that..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My next though is why are you checking :     if (shp == point and raster == dem):&lt;/P&gt;&lt;P&gt;You already defined them in the above code. Your loops would stop if you ran out of shapes or rasters..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On line 22, dem = ____ should line up under point = ____&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok, now for the logic error..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why do you need lines 21 and 22?  They are not part of your naming of the output and it will step though all the rasters and shapes in the list..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bill&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 16:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108439#M8368</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2015-11-23T16:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108440#M8369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I corrected the code as much as I could in that form. But unfortunately i cannot get the 1st pair for the 1st point (&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;Pntclip_pol1&lt;/SPAN&gt;) and 1st dem (dempol1) and then rest of them 2,3,4 for some reason. I get only one viewshed &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="dp-highlighter"&gt;&lt;P&gt;import arcpy, os&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#env.workspace = "c:/DEFENCE_DATA/Results/ArcMap/Visibility/Calc_View"&lt;/P&gt;&lt;P&gt;env.workspace = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;out = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;fc = arcpy.ListFeatureClasses("Pnt*", "Point")&lt;/P&gt;&lt;P&gt;ras = arcpy.ListRasters("dem*", "GRID")&lt;/P&gt;&lt;P&gt;point = "Pntdempol1.shp"&lt;/P&gt;&lt;P&gt;dem = "dempol1"&lt;/P&gt;&lt;P&gt;i = 1&lt;/P&gt;&lt;P&gt;for seip in fc:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for rakster in ras:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (seip == point and rakster == dem):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inRaster = rakster&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inObserverFeatures = seip&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed = Viewshed(inRaster, inObserverFeatures, "")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed.save(out + "\\" + "view" + str(i))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = int(i) + 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = "Pntdempol" + str(i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dem = "dempol" + str(i)&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 17:22:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108440#M8369</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T17:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108441#M8370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because after the first pair of Point (&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;Pntclip_pol1&lt;/SPAN&gt;) and Dem (dempol1) I want to do the viewshed for &lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;Pntclip_pol2 &lt;STRONG&gt;and &lt;/STRONG&gt;dempol2 etc 3,4,5..&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 17:25:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108441#M8370</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T17:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108442#M8371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To break it down:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fclist( PntA, pntB, pntC, pntD)  &amp;lt;&amp;lt;&amp;lt; an example list of point features&lt;/P&gt;&lt;P&gt;demlist (dema, demb, demc, demd)   &amp;lt;&amp;lt;example list of dems…&lt;/P&gt;&lt;P&gt;count = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i in fclist               #PntA  first shape in list&lt;/P&gt;&lt;P&gt;    for rak in demlist       #dema first dem in list&lt;/P&gt;&lt;P&gt;        if i == Pnta and rak == dema&lt;/P&gt;&lt;P&gt;            outViewshed =Viewshed(rak, i)&lt;/P&gt;&lt;P&gt;            outViewshed.save(mypath&lt;BR /&gt;&lt;EM&gt;"view"&lt;/EM&gt; str(count))   #view1&lt;/P&gt;&lt;P&gt;            count = count + 1&lt;/P&gt;&lt;P&gt;            point = Pnta + 1   # Pnta1     #last indented code, last line of if statement&lt;/P&gt;&lt;P&gt;         dem = dema+1    #dema1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: in green Pnta1, if not found your code will bomb here, after first view is run.&lt;/P&gt;&lt;P&gt;Did you want to run everything in the fclist against your first dem?&lt;/P&gt;&lt;P&gt;Then run it all over again against your second dem?&lt;/P&gt;&lt;P&gt;For i in fclist&lt;/P&gt;&lt;P&gt;                For x in demlist&lt;/P&gt;&lt;P&gt;                     Outview =viewshed(I,x)&lt;/P&gt;&lt;P&gt;                     Save it here&lt;/P&gt;&lt;P&gt;                     &lt;/P&gt;&lt;OL&gt;&lt;LI level="1" type="ol"&gt;&lt;P&gt;running again will use the first  i and the second x and so on&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI level="1" type="ol"&gt;&lt;P&gt;next i will run through (second i) and first x in xlist, then second x in xlist, etc..&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Until you finish the I list..&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 18:09:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108442#M8371</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2015-11-23T18:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108443#M8372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Forgot in a list (pnta, pntb, pntc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the second item  list[1] , you would have to remember the index or make count start at zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example you could have it just process one right after the other and not worry about the list index number..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 18:14:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108443#M8372</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2015-11-23T18:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108444#M8373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your nested if statements seems to be the problem.&amp;nbsp; In such cases, you would be advised to make a list containing just the pairs that you want to process.&amp;nbsp; You formulate the pairs&lt;/P&gt;&lt;P&gt;[ [ A with rastA],&lt;/P&gt;&lt;P&gt;&amp;nbsp; [ B with rastA],&lt;/P&gt;&lt;P&gt;&amp;nbsp; [B with rastB]&lt;/P&gt;&lt;P&gt;etc ]&lt;/P&gt;&lt;P&gt;then run throught list of pairs.&amp;nbsp; It is the difference between combinations and permutations? which do you want? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 18:29:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108444#M8373</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-11-23T18:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108445#M8374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think I fully understand you,&lt;/P&gt;&lt;P&gt;I am seeing many errors in&amp;nbsp; the code, it would be better if you could put it in Python context.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;outViewshed.save(mypath&lt;/SPAN&gt;&lt;EM style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;"view"&lt;/EM&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; str(count)) here it should be (mypath + "view" + str(count))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;count = count + int(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;point = Pnta + str(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Unfortunately my code isn't right as well I can get only one Viewshed&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 18:35:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108445#M8374</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-23T18:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108446#M8375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It’s your logic that’s tripping you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;•  import arcpy, os&lt;/P&gt;&lt;P&gt;•  from arcpy import env&lt;/P&gt;&lt;P&gt;•  from arcpy.sa import *&lt;/P&gt;&lt;P&gt;•  arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;•&lt;/P&gt;&lt;P&gt;•  env.workspace = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;•  out = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;•  fc = arcpy.ListFeatureClasses("Pnt*", "Point")&lt;/P&gt;&lt;P&gt;•  ras = arcpy.ListRasters("dem*", "GRID")&lt;/P&gt;&lt;P&gt;•  point = "Pntclip_pol1"&lt;/P&gt;&lt;P&gt;•  dem = "dempol1"&lt;/P&gt;&lt;P&gt;•  i = 1&lt;/P&gt;&lt;P&gt;•  for shp in fc:    &amp;lt;&amp;lt;&amp;lt; First time in loop this is Pntclip_pol1????   2nd time it’s  Pntclip_pol2    ??&lt;/P&gt;&lt;P&gt;            If it’s Pntclip_pol1 why did you define it?? It’s the first item in your fc list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;•      for raster in ras:   first time it’s dempol1?? Is that also the first item in your dem list?&lt;/P&gt;&lt;P&gt;•         # if (shp == point and raster == dem):   ???WHY???  Not needed..&lt;/P&gt;&lt;P&gt;•              #inRaster = raster    # not needed&lt;/P&gt;&lt;P&gt;•             # inObserverFeatures = shp   #not needed&lt;/P&gt;&lt;P&gt;•              #outViewshed = Viewshed(inRaster, inObserverFeatures, "")&lt;/P&gt;&lt;P&gt;            outViewshed = Viewshed(raster, shp)&lt;/P&gt;&lt;P&gt;•          outViewshed.save(out + "&lt;BR /&gt;" + "view" + str(i))&lt;/P&gt;&lt;P&gt;•              i = i + 1  #already an int as declared above..&lt;/P&gt;&lt;P&gt;•              #point = "Pntclip_pol" + str(i)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;•        # dem = "clippol" + str(i)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just say you have 3 points and 5 dems&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For i in pointlist:&lt;/P&gt;&lt;P&gt;                For dem in demlist:&lt;/P&gt;&lt;P&gt;                theViewshed  = viewshed(dem, i)&lt;/P&gt;&lt;P&gt;                the Viewshed.save (xxxxxx+ str(1))&lt;/P&gt;&lt;P&gt;                Here the loop would use the same i and run through the next dem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once finished it would loop the next i and toss you back into the dem loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 pt&lt;/P&gt;&lt;P&gt;                1 dem&lt;/P&gt;&lt;P&gt;                Viewshed (1 dem, 1 pt)&lt;/P&gt;&lt;P&gt;                Now loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                2 dem&lt;/P&gt;&lt;P&gt;                Viewshed( 2 dem, 1 pnt)&lt;/P&gt;&lt;P&gt;                Now loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                3 dem&lt;/P&gt;&lt;P&gt;                Viewshed( 3 dem, 1 pt)&lt;/P&gt;&lt;P&gt;                Now loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                Etc.. until finished with dems then kick to 2nd point&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 pt&lt;/P&gt;&lt;P&gt;                1 dem&lt;/P&gt;&lt;P&gt;                Viewshed (1 dem, 2 pt)&lt;/P&gt;&lt;P&gt;                Now loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                2 dem&lt;/P&gt;&lt;P&gt;                Viewshed( 2 dem, 2 pnt)&lt;/P&gt;&lt;P&gt;                Now loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                3 dem&lt;/P&gt;&lt;P&gt;                Viewshed( 3 dem, 2 pt)&lt;/P&gt;&lt;P&gt;                Now loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don’t need to name the items in each list as they will always advance to the next item in each list.&lt;/P&gt;&lt;P&gt;Leave i =1 and have I = i+1 inside the dem loop so your new views are numbered..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 19:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108446#M8375</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2015-11-23T19:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108447#M8376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a very analytic answer Mr Chappell, thank you very much.&amp;nbsp; I will study the code and I will reply you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2015 00:06:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108447#M8376</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-24T00:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108448#M8377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I understand you now. Well at your question,&amp;nbsp; I define point and dem because each dem has only one specific point. Dem 1 has only point 1, dem2 has only poi&lt;SPAN style="background-color: #f6f6f6;"&gt;nt 2 etc.. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 09:53:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108448#M8377</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-11-25T09:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108449#M8378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I developed the code at that form but I have an error of ERROR 010004: All cells in Raster clippol1 have the NODATA value. Stop execution. ERROR 010067: Error in executing grid expression. Failed to execute (Viewshed).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code where I tried to define extent also but I get back only one viewshed and not with the coding I want (line 11). And these errrors keep appear, I extracted these rasters from Modelbuilder I haven't set anything to NODATA so as to have problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
from arcpy.sa import *
ink = "C:/DEFENCE_DATA/Results/ArcMap/Visibility/Calc_View"
fc = arcpy.ListFeatureClasses("Pnt*", "Point")
demi = "clippol1"
i = 1
for seip in fc:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.extent = ink + "/clippol" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed = Viewshed(demi, seip)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed.save(ink + "/view" + str(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dem = "clippol" + str(i)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that I am very close to finally make it run but I have to solve that with NODATA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:32:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108449#M8378</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2021-12-11T06:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If , For statements</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108450#M8379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You had DEMi and DEM below, as written it would always just use the first dem, your next dem is not used..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your second viewshed may not have a point1 in it.&lt;/P&gt;&lt;P&gt; If your running this from the IDLE or pythonwin,  I’d use print commands to see what your variables are, so if it errors off you have a better clue.&lt;/P&gt;&lt;P&gt;I wrote what I’d use in blue below. I also shortened your output string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One big potential problem is if your typing in the workspace path, it’s so easy to confuse the forward and back slash.&lt;/P&gt;&lt;P&gt;Are the points and dems in the same projection?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I had some time, I rewrote the code, see below in green. It works,  my e-mail is William.Chappell@its.ny.gov&amp;lt;mailto:William.Chappell@its.ny.gov&amp;gt; if you want the script I used, in case copy/paste messes with the indent formats.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,  Bill&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 14:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-if-for-statements/m-p/108450#M8379</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2015-11-25T14:07:56Z</dc:date>
    </item>
  </channel>
</rss>

