Re: Gridded2DSet

Hi Desiree,

Desiree Hilbring wrote:
> 
> > The x-values are in samples[0] and the y-values are in samples[1];
> >
> > Let you DEM be
> >
> >       3.3   x                x
> > north   2.7       x
> >
> >       1.3   x          x     x
> >             0.2  0.3    1.1   1.2
> >                    east
> >
> > Sampled points are represented bx "x".
> >
> > You've got lenX = 3, lenY = 2, and, thus, must input 6 pairs of
> > coordinates.
> > So, samples is (something like): samples[0]={0.2,1.1,1.2, 0.2,0.3,1.2};
> > // east, or x values
> >                           and  samples[1]={1.3,1.3,1.3, 3.3,2.7,3.3}; // 
> > north, or y values
> >
> 
> Hi Ugo, I am getting confused, I tried to implement the above,
> 
>         //double[][] coords = new double[2][east.length];
>         coords[0] = new double[east.length];
>         coords[1] = new double[north.length];
>         for (int i=0;i<coords[0].length;i++) {
>             coords[0][i]=east[i];
>             coords[1][i]=north[i];
>         }
> 
>         for (int j=0;j<coords[0].length;j++) {
>             System.out.println("e "+coords[0][j]);
>         }
>         for (int j=0;j<coords[1].length;j++) {
>             System.out.println("n "+coords[1][j]);
>         }
> 
>         and they look like your samples[0] and samples[1]
> 
> now you are saying i have an array double[2][east*north], that would be
> 3*4 in your example?

No, I'm not saying that. The values on the (imaginary) axes above DO NOT
mean that there's necessarily more than one value sampled at that point.

> How would I fill this array?


Picture this (a line - or path - joining 3 points):

        5|        x
        4|       /
north   3|      /
        2|  x---x
        1|____________
        001234567890 
           east

How'd you describe this with a VisAD Data object? I'd say, the domain is
2D, and you'd hopefully agree with me. Then I'd say, it could be
described with a Gridded2DSet with manifold dimension = 1. For that use
a 

Gridded2DSet(MathType type, float[][] samples, int lengthX)

where MathType is as usual, lengthX = 3 and samples is

samples = new float[2][lengthX]

which is 

samples = new float[][]{ {3, 7, 9}, // east
                         {2, 2, 5}}; // north

Is this clear?

Now suppose you have a grid, which represents your DEM. Say, every point
is 2 meters away from the next point in the x-direction and 3 meters
away in the y-direction. That is in text mode ;-)


        5|   x-x-x
        4|   | | |  
north   3|   | | |   
        2|   x-x-x
        1|____________
        001234567890 
           east

This is obviously a Linear2DSet( domainType, 4, 8, 3, 2, 5, 2) 

X starts at 4, ends at 8 and has 3 samples in this direction. Y starts
at 2, ends at 5 and has 2 samples. In total, 3 times 2 equals 6 samples.
Yes, 6 points. You sould provide 6 values for x and 6 values for y.
That's what you do in a Gridded set. Here, however, the Linear set does
that for you.

The same could be described by a 

Gridded2DSet( domainType, new float[][]{{4,4,6,6,8,8},{2,5,2,5,2,5}}, 3,
2);

And this is no linear, but only a gridded set:


        5|   x-x--- x
        4|   | |   /
north   3|   | |  /  
        2|   x-x-x
        1|____________
        001234567890123 
           east

Gridded2DSet( domainType, new float[][]{{4,4,6,6,8,11},{2,5,2,5,2,5}},
3, 2);


What about this?

                    --x
        5|   x- ---|  |
        4|   | x     /
north   3|   | |   /  
        2|   x-x---x
        1|_______________
        00123456789012345 
           east

This is obviously a Gridded2DSet( domainType, new
float[][]{{4,4,6,7,10,3},{2,5,2,4,2,6}}, 3, 2);
(Please, note that the x's are connected forming a grid of rectangular
topology but not geometry.)
 
And this is an irregular 2d set

                    x
        5|   x      x
        4|    x   x     x x
north   3|       x  
        2|   x x   x
        1|_______________
        00123456789012345 
           east


> Sorry, I am just feeling stupid, I do not get that!
> 
> Thanks Desiree

I never claimed this is straight forward. 
Again, I hope it'll become clear to you. If still not, you should go out
and enjoy this marvellous sunshine. Take a linear grill with you and
while your barbecue isn't ready, think of what would happen if you were
to warp the grid. You'd still have as many intersections (compare the
lengthX and lengthY parameters in the gridded and linear set
constructors), i.e. "number of points".

Cheers,

Ugo



  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: