Re: Gridded2DSet

Hi Desiree,

I'm not sure where your NullPointerExeption arises, but I want to make a

I see you're using a Gridded2DDoubleSet, but with "manifold dimension
1". That really means a line in 2D and samples in double precision. I
know you have a DEM, and this means a surface in 2D (forget for a moment
that it is 3D, i.e. that you might want to depict your data in 3D; the
height values will be given by the FlatField, as you know).

You should use a Gridded2DSet, with manifold dim = 2. That is,

Gridded2DSet(MathType type,  float[][] samples, int lengthX, int
lengthY)
a 2-D set whose topology is a lengthX x lengthY
grid, with null errors, CoordinateSystem and Units are
defaults from type

(I'm supposing your x,y coords are floats; if not, stick to a
Gridded2DDoubleSet, but use the constructor
Gridded2DDoubleSet(MathType type, double[][] samples, int lengthX, int
lengthY)

and not

Gridded2DDoubleSet(MathType type, double[][] samples, int lengthX)
)

That is, your DEM is organized in a grid, but the interval between
adjacent points is not necessarily constant (if it were, than you could
use a Linear2DSet. Your grid has LengthX samples in the x direction and
LengthY samples in the y direction, i.e., those are the dimensions of

The MathType is composed of your eastValues and northValues; just make
sure you've got them in the right order one constructing the

domain_tuple = new RealTupleType(northValues,eastValues);

I'd personally do the other way around, first east (= x) then north (
y) but this is arbitrary.

The "tricky" bit comes in the definition of float[][] samples. In this
case, it is a float[ nCols * nRows ] array. (Remember, when manifold
dim = 1, you have float[ lengthX ], which gives you enough values for
a line, i.e. a path in 2D space.)

However, you want a DEM, a surface in 2d space. So you need to input
LengthX * lengthY (= nRows * nCols) values. These are the
(northValues,eastValues) coordinates of your DEM and are given by the
array described above.

The x-values are in samples and the y-values are in samples;

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.2,1.1,1.2, 0.2,0.3,1.2};
// east, or x values
and  samples={1.3,1.3,1.3, 3.3,2.7,3.3}; //
north, or y values

Well, to be honest I might have got confused with the ordering of the
coords. This has not only to do with choosing whether EastValues comes
before northValues in the RealTupleType, but also to do with the way
VisAD organises the samples (it is the Fortran way). I'd have to hack a
bit to get it right (sorry, I'm a mere mortal and errare humanun est ;-)
so i'll leave that for you to do :-)=)

The basic ideas here are to choose a Gridded2DSet with lenX and lenY
parameters, as this will construct the right topology (your DEM surface)
and to get the samples with the x-values and samples with the
y-values (or just the other way around ;-)

Final point is, your gridded set must correspond with a valid grid. Not
something like you'd find in triangulated irregular network (TIN). For
that you'd use an Irregular2DSet (and all those Delaunay objects), but I
reckon, from the list, you know that.

I truly hope I managed help to clarify the issue a bit.

Cheers,

Ugo

• 2001 messages navigation, sorted by: