I am an beginner in Python programming but I would like to write in only a file .csv (or .txt) the values contained in several rasters.
For example, I built several rasters by using a loop. The rasters are like this:
outCostPath.save('P_' + str(int(ID_patch_1)) + '_' + str(int(ID_patch_2)) + ".tif")
For each raster, I would to save the value that is situated at the second line and the column "PATHCOST" in a file .csv. In the end, this file .csv should contain all values contained in all created rasters. Here is my algorithm:
i = 1 for ID_patch_1 = 1 to 100 for ID_patch_1 = ID_patch_1 + 1 to 100 ## Building a raster fileRaster = outCostPath.save('P_' + str(int(ID_patch_1)) + '_' + str(int(ID_patch_2)) + ".tif") ## Writing in a file .csv fileCsv(i,1) = ID_patch_1 ## put value of ID_patch_1 in fileCsv at line i and first column fileCsv(i,2) = ID_patch_2 ## put value of ID_patch_2 in fileCsv at line i and second column fileCsv(i,3) = fileRaster(2,3) ## put value situated at line 2 and third column in the created raster i = i + 1 end end
The problem is that I don't know to code this algorithm in Arcpy.