Previous Getting Started with IDL: Mapping Next

Plotting Data on Maps

You can annotate plots easily in IDL. To plot the location of selected cities in North America, as shown in the following figure, you need to create three arrays: one to hold latitudes, one to hold longitudes, and one to hold the names of the cities being plotted.

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

     

  3. Create a 5-element array of floating-point values representing latitudes in degrees North of zero.
  4. LATS=[40.02,34.00,38.55,48.25,17.29]  
    

     

  5. The values in LONS are negative because they represent degrees West of zero longitude.
  6. LONS=[-105.16,-119.40,-77.00,-114.21,-88.10]  
    

     

  7. Create a five-element array of string values. Text strings can be enclosed in either single quotes ('text') or double quotes ("text").
  8. CITIES=['Boulder, CO','Santa Cruz, CA',$  
       'Washington, DC','Whitefish, MT','Belize, Belize']  
    

     

  9. Draw a Mercator projection featuring the United States and Mexico.
  10. MAP_SET,/MERCATOR,/GRID,/CONTINENT,LIMIT=[10,-130,60,-70]  
    

     

  11. Place a plotting symbol at the location of each city.
  12. PLOTS,LONS,LATS,PSYM=4,SYMSIZE=1.4,COLOR=220  
    

     

  13. Place the names of the cities near their respective symbols.
  14. XYOUTS,LONS,LATS,CITIES,COLOR=80, $
       CHARTHICK=2,CHARSIZE=1.25,ALIGN=0.5  
    

     

    Figure 9-6: Annotating a Map Projection

    Figure 9-6: Annotating a Map Projection

The PSYM keyword makes PLOTS use diamond-shaped plotting symbols instead of connecting lines. The SYMSIZE keyword controls the size of the plotting symbols. XYOUTS draws the characters for each element of the array CITIES at the corresponding location specified by the array elements of LONS and LATS. The CHARTHICK keyword controls the thickness of the text characters and the CHARSIZE keyword controls their size (1.0 is the default size). Setting the ALIGN keyword to 0.5 centers the city names over their corresponding data points.

  IDL Online Help (March 06, 2007)