Warping Images to Maps

Image data can also be displayed on maps using Direct graphics. The MAP_IMAGE function returns a warped version of an original image that can be displayed over a map projection. In this example, elevation data for the entire globe is displayed as an image with continent outlines and grid lines overlaid.

  1. Define the map that you want to display, using WORLD as the variable in which to store the map data. Define the data dimensions as a 360 by 360 square array using the DATA_DIMS function. In the IDL command line, enter:
  2. world = READ_BINARY(FILEPATH('worldelv.dat', $
       SUBDIRECTORY=['examples', 'data']), DATA_DIMS=[360,360])

  3. Since we are using Direct graphics, tell IDL to use a maximum of 256 colors and load a color table.
  4. DEVICE, RETAIN=2, DECOMPOSED=0
    LOADCT, 26


    gsmap07.gif

  5. View the data as an image using the variable WORLD that you defined above.
  6. TV, world

    The first column of data in this image corresponds to 0 degrees longitude. Because we'll use MAP_IMAGE later and it assumes that the first column of the image corresponds to -180 degrees, we'll use the SHIFT function on the data set before proceeding.

  7. Shift the array 180 elements in the row direction and 0 elements in the column direction to make -180 degrees the first column in the array.
  8. world = SHIFT(world, 180, 0)

  9. View the data as an image again, noting the difference made by the shift.
    gsmap08.gif
  10. TV, world

    From the image contained in the data, you can create a warped image to fit any of the available map projections. Define a map projection before using MAP_IMAGE, because this routine uses the currently defined map parameters.

  11. Create a Mollweide projection with continents and gridlines.
  12. MAP_SET, /MOLLWEIDE, /CONT, /GRID, COLOR=100

  13. Warp the image using bilinear interpolation using the BLIN command to smooth the warped image and save the result in the variable NEW.
  14. new = MAP_IMAGE(world, sx, sy, /BILINEAR)

    The SX and SY output variables in the command above contain the X and Y starting positions for displaying the image.

  15. Display the new image over the map:
    gsmap09.gif
  16. TV, new, sx, sy

    See the map in the previous figure and note that the warped image now displays over the existing continent and grid lines.

     

     

     

     

  17. The continent outlines and thick grid lines can be displayed, as shown next, by entering:
  18. MAP_CONTINENTS

    MAP_GRID, GLINETHICK=3


    gsmap10.gif