Previous Getting Started with IDL: Surfaces and Contours Next

Accessing Binary Surface Data

For this example we will use the binary dataset of the Maroon Bells Mountains. We will use the BINARY_TEMPLATE and READ_BINARY functions to read this data set. Once you have read the file into IDL, you are ready to move on to visualizing the data set three-dimensionally.

To import binary data directly into IDL, use the BINARY_TEMPLATE function in conjunction with the READ_BINARY function. To import a binary data file into IDL, you must first describe the format of the data using the Binary Template.

The binary file that we will read in the following example is stored as an integer array and contains an image of the Maroon Bells mountains, a group of mountains located among the Rocky Mountains of Colorado.

  1. At the IDL Command Line, enter the following:
  2. MARBELLSTEMPLATE=BINARY_TEMPLATE(FILEPATH('surface.dat', $
       SUBDIR = ['examples', 'data']))  
    

     

    The binary template dialog box appears.

     

  3. In the Template Name field, enter "marbellstemplate" for the name of the new template.
  4.  

  5. In the File's byte ordering pull-down field, select "Little Endian" since we know that this file was created on an Intel processor-based machine.
  6.  

  7. Click the New Field button in the lower left corner of the dialog box.
  8.  

  9. When the New Field dialog appears, enter "MARBELLS" as the field name. Verify the box in the upper right corner marked Returned in the result since we will want our data set returned at the time it is read.
  10.  

  11. At the Number of Dimensions pull-down menu, be sure to specify that we are dealing with a two-dimensional data set here. These data are contained in a 350 by 450 array, so we will enter these values in the two boxes marked Size.
  12.  

  13. Specifying Integer (16 bits) at the Type pull-down menu. Click OK.
  14.  

  15. Click OK when the binary template dialog reappears.
  16.  

  17. Use the READ_BINARY function to read the template we have just created. At the IDL Command Line, enter:
  18. MARBELLS_BINARY=READ_BINARY (FILEPATH('surface.dat', $
       SUBDIR=['examples', 'data']),TEMPLATE=MARBELLSTEMPLATE)  
    

  IDL Online Help (March 06, 2007)