Previous Getting Started with IDL: Mapping Next

Plotting Contours Over Maps

Contour plots can easily be drawn over map projections by using the OVERPLOT keyword to the CONTOUR routine. See the map in the figure below. Enter the following at the Command Line:

  1. Open a graphics window for viewing:
  2. WINDOW  
    

     

  3. Create a dataset to plot:
  4. A=DIST(91)  
    

     

  5. Create an X value vector containing 91 values that range from -90 to 90 in 2 degree increments:
  6. LAT=FINDGEN(91)*2-90  
    

     

  7. Create a Y value vector containing 91 values that range from -180 to 180 in 4 degree increments:
  8. LON=FINDGEN(91)*4-180  
    

     

  9. Create a new sinusoidal map projection over which to plot the data:
  10. MAP_SET,/GRID,/CONTINENTS,/SINUSOIDAL,/HORIZON  
    

     

  11. Draw a twelve-level contour plot of array A over the map:
  12. CONTOUR,A,LON,LAT,/OVERPLOT,NLEVELS=12  
    

     

    Figure 9-7: Plotting Contours Over Maps

    Figure 9-7: Plotting Contours Over Maps

Since latitudes range from -90 to 90 degrees and longitudes range from -180 to 180 degrees, you created two vectors containing the "X" and "Y" values for CONTOUR to use in displaying the array A. If the X and Y values are not explicitly specified, CONTOUR will plot the array A over only a small portion of the globe.

  1. When you are finished with the map, dismiss the graphics window:
  2. WDELETE  
    

  IDL Online Help (March 06, 2007)