[no subject]

we are working on a DTM (Digital Terrain Model) using Java and VisAD.
Our data set consists of X x Y height values, including missing values, which 
have set to -9999.
We want to draw the surface as a continuous one (that is, no individual 
and have set the missing data values to NaN. But that plots the surface as 
points, whereas we want the programm to draw lines between them (thus creatoing 
a continuous surface).
We had set value of missing data to 0, but that obviously generates a 
undesirable surface at height=0, which get conected to the actual DTM, at 
How can we "delete" this surface, so that we only plot the surface, and that 
missing data doesn't get plotted (or gets plotted in black)?
I have tried to set the missing data to NaN and "force" the plotting in line 
mode (that is, with setPointMode(false))
Here is our code:

import visad.*;
import visad.java3d.DisplayImplJ3D;
import visad.util.VisADSlider;
import visad.data.netcdf.Plain;
import java.rmi.RemoteException;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;

public class tv {

  public static void main(String args[])
         throws VisADException, RemoteException, IOException {

        ArcGridReader dgm = new ArcGridReader(args[0]);

// Reads dimensions of raster

        int LengthX = dgm.getRasterSize().width;
        int LengthY = dgm.getRasterSize().height;
        double missing = dgm.getMissingValue();
        double min = dgm.getMinimum();

        RealType x_axis = new RealType( "X-Axis", SI.meter, null );
        RealType y_axis = new RealType( "Y-Axis", SI.meter, null );
        MathType Domain = (MathType) new RealTupleType( x_axis, y_axis );

        RealType rangeElev =  new RealType( "Elevation", SI.meter, null );
        RealType rangeTemp =  new RealType( "Temperature", SI.kelvin, null );
        Set domainSet = (Set) new Linear2DSet( Domain, 0.d, 1000.d, LengthX,
                                              0.d, 1000.d, LengthY );

        RealType[] types2 = { rangeElev, rangeTemp };
        RealTupleType overl = new RealTupleType(types2);
        FunctionType overfunc = new FunctionType(Domain, overl);
        FlatField ff = new FlatField( overfunc, domainSet );
        double[][] samples = new double[2][LengthX*LengthY];

        int index = 0;
        double wave_number = 2;
        double PI = Math.PI;
        for ( int ii = 0; ii < LengthY; ii++ ) {
          for ( int jj = 0; jj < LengthX; jj++ ) {

            // this is the DEM data

            double val = (double ) dgm.getFPDataAt(jj,ii);

// if we do (val==missing) NaN : val-min;
// we get points only plotted

            samples[0][index] = (val == missing) ? 0 : val-min;

            // the layer for coloring the dem - a sine function overlay

            double v = (50)*Math.sin( ((wave_number*2d*PI)/1000)*5*jj )* 
Math.sin( ((wave_number*2*PI)/1000)*5*ii );     
            samples[1][index] =  v;
        ff.setSamples( samples );

        DisplayImpl display1 = new DisplayImplJ3D("display1");
        display1.addMap( new ScalarMap( (RealType) x_axis, Display.XAxis ));
        display1.addMap( new ScalarMap( (RealType) y_axis, Display.YAxis ));
        display1.addMap( new ScalarMap( (RealType) rangeElev, Display.ZAxis));
        display1.addMap( new ScalarMap( (RealType) rangeTemp, Display.Red));
        display1.addMap( new ConstantMap( 0.5, Display.Green));
        display1.addMap( new ConstantMap( 0.5, Display.Blue));
        GraphicsModeControl mode = display1.getGraphicsModeControl();

        JFrame jframe = new JFrame("Test");
        jframe.addWindowListener( new WindowAdapter() {
          public void windowClosing(WindowEvent e) {System.exit(0);}
        DataReferenceImpl ref_imaget1 = new DataReferenceImpl("ref_imaget1");
        ref_imaget1.setData( ff );        
        display1.addReference( ref_imaget1, null);
        JPanel big_panel = new JPanel(new BorderLayout());
        jframe.setSize(600, 600);

Help on our little problem is appreciated, and overall sugestions too!



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