comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: 2D to 3D Array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: 2D to 3D Array [message #48321 is a reply to message #48320] Fri, 07 April 2006 13:19 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rafaloos@gmail.com writes:

> I have a Band Interleaved Image (BIL):
> samples = 300
> lines = 316
> bands = 481
>
> I can read this image as a 2D array of (144300, 316) Where 144300 will
> be the product of samples by bands.
> I would like to reformat the image so that I can put the data into an
> array such as (300, 316, 481).
>
> For example: I have this array (6,2)
>
> array[*,0] = [1, 2, 1, 2, 1, 2]
> array[*,1] = [3, 4, 3, 4, 3, 4]
>
> What I want is a result as:
>
> array[*,*,0] = 1, 2
> 3, 4
>
> array[*,*,1] = 1, 2
> 3 ,4
>
> array[*,*,2] = 1, 2
> 3, 4
>
> so that my array will be (2,2,3)

First reform your array into a [2,3,2] array:

array = Reform(array, 2, 3, 2)

Then, transpose the dimensions the way you want them:

array = Transpose(array, [0,2,1])

IDL> print, array[*,*,2]
1 2
3 4
IDL> print, array[*,*,1]
1 2
3 4
IDL> print, array[*,*,0]
1 2
3 4

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: 2D to 3D Array
Next Topic: Re: Day/Night Terminator on Map Projection

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:20:34 PDT 2025

Total time taken to generate the page: 0.00627 seconds