array_d=arcpy.RasterToNumPyArray(raster_d) array_v=arcpy.RasterToNumPyArray(raster_v) (height_d, width_d)=array_d.shape (height_v, width_v)=array_v.shape # create empty array to store the "D" parameter newarr = np.zeros((5,4)) for row1 in range (0,height_d): row2=row1 for col1 in range (0,width_d): col2=col1 h=array_d.item(row1,col1) v=array_v.item(row2,col2) # calculate the "D" parameter expr = h+v newarr[row1,col1] = expr # write the new array to an ascii file np.savetxt("e:/out.txt", newarr, fmt="%.2f", delimiter= " ")
There are also arcpy functions to convert numpy Arrays to rasters and the other way around.http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000130000000
import numpy as np a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] a = np.array(a) a = np.reshape(a, (4,5))
[[ 1 2 3 4 5] [ 6 7 8 9 10] [11 12 13 14 15] [16 17 18 19 20]]
i = range(20) cols = 4 f = open('D:\\tmp.csv', 'w') for r in range(len(i)/cols): f.write(';'.join([str(v) for v in i[r*cols:(r+1)*cols]]) + '\n')
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.