Help with ProjectionControl

Hello All,

I'm having some trouble creating the images that I need and would greatly appreciate a little direction.

My objective is to render an image where the data completely fills the image - no borders, axes, etc.

I have attempted to do this with the ProjectionControl#setMatrix to "zoom-in" so that the data display area fills the image. Problem with this approach is that the matrix values that I'm using are empirically determined and when the desired out image aspect ratio changes, I no longer get the desired results.

Is there a (better) way to avoid getting the background? Or is there a way that I can calculate the matrix values based on desired image size?

listed below is the pertinent section of code. Attached are two images: the first with the setMatrix() call enabled, the second without.

Thanks for your help!


-- john


                // zoom to get rid of black border
                ProjectionControl pc = display.getProjectionControl();
                double[] matrix = pc.getMatrix();

                // this number is empirically derived
double[] mult = display.make_matrix(0.0, 0.0, 0.0, 1.515, 0.0, 0.0, 0.0);
                pc.setMatrix(display.multiply_matrix(mult, matrix));

//set aspect ratio based on image size. Assumes geographic envelope
                //has already been adjusted to accomodate the ratio
                double[] aspect = new double[2];  //width,height
                if (outputWidth > outputHeight) {
                   aspect[0] = outputWidth / outputHeight;
                   aspect[1] = 1.0;
                } else {
                   aspect[0] = 1;
                   aspect[1] = outputHeight / outputWidth;
                }
                log.debug("aspect set to: "+aspect[0]+","+aspect[1]);
                pc.setAspectCartesian(aspect);
            }











====================================================
John Cartwright
Associate Scientist
Geospatial Data Services Group
CIRES, National Geophysical Data Center/NOAA
(303) 497-6284
John.C.Cartwright@xxxxxxxx
====================================================

PNG image

PNG image

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