Getting Started with IDL: Mapping |
Image data can also be displayed on maps. 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.
WORLDTEMPLATE=BINARY_TEMPLATE(FILEPATH('worldelv.dat', $ SUBDIR=['examples', 'data']))
WORLDELV_BINARY=READ_BINARY(FILEPATH('worldelv.dat', $ SUBDIR=['examples', 'data']),TEMPLATE=WORLDTEMPLATE)
loadct, 26
TV, WORLDELV_BINARY.W
The first column of data in this image corresponds to 0 degrees longitude. Because MAP_IMAGE assumes that the first column of the image being warped corresponds to -180 degrees, we'll use the SHIFT function on the dataset before proceeding.
WORLDELV_BINARY.W=SHIFT(WORLDELV_BINARY.W, 180, 0)
TV, WORLDELV_BINARY.W
From the image contained in the data, we can create a warped image to fit any of the available map projections. A map projection must be defined before using MAP_IMAGE, because MAP_IMAGE uses the currently defined map parameters.
MAP_SET,/MOLLWEIDE,/CONT,/GRID,COLOR=100
NEW=MAP_IMAGE(WORLDELV_BINARY.W,SX,SY,/BILIN)
The SX and SY in the command above are output variables that contain the X and Y position at which the image should be displayed. Setting the BILIN keyword causes bilinear interpolation to be used, resulting in a smoother warped image.
TV,NEW,SX,SY
The SX and SY variables provide TV with the proper starting coordinates for the warped image. TV usually displays images starting at position (0, 0). See the map in the previous figure. Note that the warped image gets displayed over the existing continent and grid lines.
IDL Online Help (March 06, 2007)