I have spent over an hour now trying to figure out what I thought would be a really basic conditional array assignment. I am very new to python and am in need of help.

I have a 2D integer array of land cover classes and a 1D array with a roughness value for each class. I am trying to create a new 2D array containing a map of the roughness values.

I am trying the following code:

roughness = np.array(landcover.shape,dtype='f')
for i in range(np.min(landcover),np.max(landcover)):
    roughness[landcover == i] = z0_legend[i]

Alas it tells me that I can only have a 1D boolean array index. What is the easiest way around this without having to loop through each row of the 2D array. I need to keep this vectorized as much as possible as these arrays are very large.

Thanks,
Bryan

<<attachment: bwoods.vcf>>

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to