I have the following code:
import arcpy from arcpy.sa import * arcpy.env.workspace="D:/..." sp="StartPoint.shp" #Dataset that defines the zones zone_field="FID" #Field that holds the values that define each zone. value_raster="UDEM.tif" #Raster that contains the values on which to calculate a statistic x_shift = 1 #increment of x coordinate of the point TableName = "ZStT" #Name of output table arcpy.env.overwriteOutput = True outTable = ZonalStatisticsAsTable(sp, zone_field, value_raster, TableName, "NODATA", "MEAN") arcpy.AddField_management(TableName, "parameter", "FLOAT", 3, "", "", "", "NON_NULLABLE", "NON_REQUIRED", "") cursor=arcpy.da.SearchCursor(outTable, ["MEAN"]) for row in cursor: i = 0 value = row #Create a cursor to query value in position of the start point while (value == 0): cursor2 = arcpy.da.UpdateCursor(sp, ["SHAPE@XY"]) #Move the point 1 meter to right for row in cursor2: cursor2.updateRow([[row+(x_shift), row]]) i += 1 #"Moved step" plus one outTable = ZonalStatisticsAsTable(sp, zone_field, value_raster, TableName, "NODATA", "MEAN") cursor = arcpy.da.SearchCursor(outTable, ["MEAN"]) #query the raster value in the point's location for row in cursor: value = row if value != 0: #if(True)break the loop cursor3=arcpy.da.UpdateCursor(outTable, ["parameter"]) #parameter=i/value for row in cursor3: row = (i/value) cursor3.updateRow(row)
The purpose of function is to iterate over coordinate change until the raster value in one single point's location meet the need (!=0),then put the parameter (moved step/raster value) in table output"ZStT".
Part of this question utilizes code in other question posted by me, but previous one accentuate how to change coordinate and this one focus on how to loop element. They're asking different stuff and I'm specifically told if there's new question post another one.
How to execute this function to element (point) of input layer separately since process to whole layers lead to change of all element simultaneously.