non-rectangular array subset [message #89446] |
Fri, 17 October 2014 04:25  |
jecca.baker
Messages: 12 Registered: October 2014
|
Junior Member |
|
|
Hello,
I have an array of global data (MODIS LAI) and need to select data from the Amazon basin only. Is there a way to do this by selecting a number of rectangular regions and concatenating them if the rectangular regions are different sizes? Eg, is it possible to concatenate the following?
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0
0,0,0
Or for a more sophisticated selection, is there a way to only select data that falls under an amazon basin shapefile?
Any tips would be much appreciated.
Many thanks,
Jess
|
|
|
|
|
|
|
Re: non-rectangular array subset [message #89452 is a reply to message #89450] |
Fri, 17 October 2014 14:49  |
Chris Anderson
Messages: 3 Registered: August 2014
|
Junior Member |
|
|
Jess,
Subsetting your data using the 'where' function will allow you to subset your data from your image arrays into one-dimensional vectors that can then be concatenated together into a single array. I'm sure this can be done in a cleaner fashion, but one potential example, given two images and some sort of threshold could be:
index1=where(image1 gt threshold,cnt)
if (cnt gt 0) then output_data=image1[index1]
index2=where(image2 gt threshold,cnt)
if (cnt gt 0) then output_data=[output_data,image2[index2]]
Your output_data vector then will contain a one-dimensional array of the values you have subset from your original images. All of your LAI values for the regions you are using will be in one array.
On Friday, October 17, 2014 6:42:07 AM UTC-7, Fabien wrote:
> Hi,
>
>
>
> A 2d grid of data is the same as an "image", and third or fourth
>
> dimensions (e.g. time or atmospheric levels) are simply a "pile of images".
>
>
>
> Depending on the size of your array you could do some dimension juggling
>
> (https://www.idlcoyote.com/tips/rebin_magic.html, case study 1) or use a
>
> loop over the other dimensions.
>
>
>
> Fabien
|
|
|