Re: Contour plot from Irregular Data Set

Hi Antonio,

> I'm newbie on visad programing, and I´m not know how to draw a contour 
> plot from a set of irregular data set. I have a some meteorological 
> stations in (lat,lon) format and i need to plot a contour of Maximum 
> temperature.

First you should study Ugo's tutorial, linked from the
VisAD web page.  For your specific problem you would  do
something like this:

  float[] x_locs = ... // location x coordinates
  float[] y_locs = ... // location y coordinates
  float[] temps = ... // temperatures at locations

  RealType x = new RealType("x");
  RealType y = new RealType("y");
  RealType t = new RealType("t");
  RealTupleType xy = new RealTupleType(x, y);
  FunctionType xy_t = new FunctionType(xy, t);
  float[][] locs = {x_locs, y_locs};
  Irregular2DSet set = new Irregular2DSet(xy, locs);
  FlatField field = new FlatField(xy_value, set);
  field.setSamples(temps);

  DisplayImplJ3D display = new DisplayImplJ3D("display");
  display.addMap(new ScalarMap(x, Display.XAxis));
  display.addMap(new ScalarMap(y, Display.YAxis));
  ScalarMap cmap = new ScalarMap(t, Display.IsoContour);
  display.addMap(cmap);
  DataReference ref = new DataReferenceImpl("ref");
  ref.setData(field);
  display.addReference(ref);
  // add display.getComponent() to your GUI

  ContourWidget cw = new ContourWidget(cmap);
  // add this to your GUI

However, VisAD currently does not support labels for contour
curves from IrregularSets.  If you want labels, resample your
temperature field to a Gridded2DSet, as:

  double minx = Float.MAX_VALUE;
  double maxx = - minx;
  double miny = minx;
  double maxy = maxx;
  for (int i=0; i<x_locs.length; i++) {
    if (x_locs[i] < minx) minx = x_locs[i];
    if (x_locs[i] > maxx) maxx = x_locs[i];
    if (y_locs[i] < miny) miny = y_locs[i];
    if (y_locs[i] > maxy) maxy = y_locs[i];
  }
  int N = 100; // or whatever resolution you like
  Linear2DSet lset = new Linear2DSet(xy, miny, maxy, N, minx, maxx, N);
  FlatField lfield = (FlatField)
    field.resample(lset); // default is weighted average interpolation
  . . .
  // ref.setData(field);
  ref.setData(lfield);

And please remember to study Ugo's tutorial.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html