[Numpy-discussion] conditional array indexing

Bryan Woods bwoods at aer.com
Mon Feb 14 17:39:15 EST 2011

Thanks for your reply. Unfortunately it is not working that simply.

This tells me that "only integer arrays with one element can be 
converted to an index"

roughness and landcover are identically shaped 2D arrays. z0_legend in a 
1D look-up table. I assume the error here comes from trying to index a 
1D array with a 2D array.

On 2/14/11 5:24 PM, Robert Kern wrote:
> On Mon, Feb 14, 2011 at 16:21, Bryan Woods<bwoods at aer.com>  wrote:
>> 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.
> roughness = z0_legend[landcover]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bwoods.vcf
Type: text/x-vcard
Size: 341 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110214/20cbd6e5/attachment.vcf>

More information about the NumPy-Discussion mailing list