Re: Tell me more


I have been at and found exactly
what I am looking for. From the refering page from Visad "See the
visad/examples/ program for an example of how to use this
capability." I haven't had the time yet, I admit.

What I would like to do is a "best resolution" real time global cloud cover
with Java3D. I can't use the Global Montage since the projection
system seems difficult to use in Java3D and resolution as well as
continental contour don't fit my needs. But it appears you are using the
kind of data I am looking for.

The globe.gif image is from an application I wrote a long time
ago so I guess I'm best qualified to answer.

The latest_moll.gif image is generated from a satellite composite
in McIDAS AREA file format with a Mollweide projection that has
been displayed in McIDAS. The globe.gif image is a display in VisAD
of an AREA file similar to the one in latest_moll.gif.  VisAD supports
most of the McIDAS navigation modules, so if your data were stored
in a McIDAS AREA file, you could use SatDisplay to map it to a globe.

If all you have is a GIF or JPEG, mapping to a sphere is going to
be a little difficult.  If your image is rectillinear and you
know the upper left corner of the image, you could use something
like the attached program to do this. This image will add a
CoordinateSystem to the domain of the image that will transform
image coordinates to lat/lon.  You can test this program by compiling
it and running:

java -Xmx128m WorldImageAdapter

(you'll need visad.jar and . in your classpath to compile and run)

The image is a global topography image that covers -180 to 180 lon
and 90 to -90 lat.  You could adjust the code accordingly if your
domain is smaller.

Any non-rectillinear image would require a different CoordinateSystem.

Good luck.

Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307

import java.awt.event.*;
import javax.swing.*;
import visad.*;
import visad.georef.*;
import visad.java2d.*;
import visad.java3d.*;
import visad.jmet.GRIBCoordinateSystem;

public class WorldImageAdapter {

    FlatField newField = null;

    public WorldImageAdapter(String source) 
      throws Exception {

       DefaultFamily df = new DefaultFamily("images", true);
       FlatField image = (FlatField);
       FunctionType fType = (FunctionType) image.getType();
       Linear2DSet domainSet = (Linear2DSet) image.getDomainSet();
       int neles =  domainSet.getLengths()[0];
       int nlines = domainSet.getLengths()[1];
       double nlat = 180./(nlines-1);
       double nlon = 360./(neles-1);
       MapProjection mp = 
           new GRIBCoordinateSystem(0, 
       RealTupleType domainType = fType.getDomain();
       RealTupleType rangeType = fType.getFlatRange();
       RealTupleType newDomainType = 
           new RealTupleType((RealType)domainType.getComponent(0),
                             (RealType)domainType.getComponent(1), mp, null);
       Linear2DSet newDomain = 
           new Linear2DSet(newDomainType, 0, neles-1, neles,
                                          nlines - 1, 0.0, nlines);
       FunctionType newFieldType = 
           new FunctionType(newDomainType, rangeType);
       newField = new FlatField(newFieldType, newDomain);
       newField.setSamples(image.getFloats(false), false);

    public FlatField getData() {
        return newField;

    public static void main(String[] args) 
      throws Exception {

        if (args.length == 0) {
            System.out.println("Must supply a filename");
        WorldImageAdapter wia = new WorldImageAdapter(args[0]);
        final FlatField data = wia.getData();
        RealTupleType rangeType = 
        DisplayImpl display = 
            new DisplayImplJ2D("display");
            new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D());
            new DisplayImplJ3D("display");
        GraphicsModeControl gmc = display.getGraphicsModeControl();
        //display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
        //display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
        display.addMap(new ScalarMap(RealType.Latitude, Display.Latitude));
        display.addMap(new ScalarMap(RealType.Longitude, Display.Longitude));
            new ScalarMap((RealType)rangeType.getComponent(0), Display.Red));
            new ScalarMap((RealType)rangeType.getComponent(1), Display.Green));
            new ScalarMap((RealType)rangeType.getComponent(2), Display.Blue));
        DataReference ref = new DataReferenceImpl("ref");
        try {
            BaseMapAdapter bma = new BaseMapAdapter("OUTLSUPW");
            DataReference mapRef = new DataReferenceImpl("map");
        } catch (Exception e) { 
            System.out.println("Map OUTLSUPW not available");
        JFrame frame = new JFrame("adapter test");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
        JButton save = new JButton("Save");
        save.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                  new Plain().save("", data, true);
                } catch (Exception exp) {
                  System.out.println("couldn't save image");
        frame.getContentPane().add("South", save);
  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: