Search code examples
pythonwhile-looparcgisarcpy

While-Loop does not work correctly


I am a little bit confused, I'm trying to write a script to modify cell values in a raster. The following loop should list all coordinates of this Raster (249x249 cells). Unfortunately, the variable i does not change.

i = xminf
j = yminf
zaehler = 0

while(i < xmaxf):

    while(j < ymaxf):
        arcpy.AddMessage("Check in-While, Klappe Nr: " + str(zaehler))
        zaehler += 1
        arcpy.AddMessage(str(i) + " " +str(j))
        j += cellsizef
    i += cellsizef

This is my Output:

Check in-While, Klappe Nr: 0
33322321.35 6011434.28
Check in-While, Klappe Nr: 1
33322321.35 6011436.07602
Check in-While, Klappe Nr: 2
33322321.35 6011437.87205
.
.
.
Check in-While, Klappe Nr: 248
33322321.35 6011879.69398
Check in-While, Klappe Nr: 249
33322321.35 6011881.49

So I only get 249 Positions which is in fact one column of the raster. Does anyone know why this code does not work?

Thanks for help!


Solution

  • i = xminf
    
    zaehler = 0
    
    while(i < xmaxf):
        j = yminf
        while(j < ymaxf):
            arcpy.AddMessage("Check in-While, Klappe Nr: " + str(zaehler))
            zaehler += 1
            arcpy.AddMessage(str(i) + " " +str(j))
            j += cellsizef
        i += cellsizef
    

    Try this.