; docformat = 'rst' ;+ ; This is an example program to demonstrate how to create a map with point source data ; with Coyote Graphics routines. The data we use is soil carbon data with associated ; latitude and longitude value. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "point_source_plot.pro" and run it like this:: ; IDL> .RUN point_source_plot ; ; :Author: ; FANNING SOFTWARE CONSULTING:: ; David W. Fanning ; 1645 Sheely Drive ; Fort Collins, CO 80526 USA ; Phone: 970-221-0438 ; E-mail: david@idlcoyote.com ; Coyote's Guide to IDL Programming: http://www.idlcoyote.com ; ; :History: ; Change History:: ; Written, 29 January 2013 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2013, Fanning Software Consulting, Inc. ;- PRO Point_Source_Plot ; Set up variables for the plot. Normally, these values would be ; passed into the program as positional and keyword parameters. ; In this case we are restoring an IDL save file containing ; soil carbon data with associated latitude and longitude values. ; Each of the three vectors (lat, lon, and soilc) are 67420 elements ; in length. Restore, File='ptsource_carbon.sav' ; Open a display window. cgDisplay, 600, 400, Title='Point Source Overlay on Map' ; Set up the soil carbon colors based on standard published map. soil_colors = ['purple', 'dodger blue', 'dark green', 'lime green', $ 'green yellow', 'yellow', 'hot pink', 'crimson'] TVLCT, cgColor(soil_colors, /Triple), 1 soilc_colors = BytScl(soilc, Top=7) + 1B ; Set up the map projecton data space. cgMap_Set, /Cylindrical, /NoBorder, /NoErase, $ Limit=[-60, -180, 90, 180], Position=[0.1, 0.1, 0.75, 0.85] ; Create a land mask in the Z-graphics buffer for PostScript compatibility. thisDevice = !D.Name Set_Plot, 'Z' ; Set the device up as an 8-bit device. Device, Set_Resolution=[600, 400], Z_Buffer=0, Set_Pixel_Depth=8 cgErase cgMap_Continents, Color=0B, /Fill mask = TVRD() ; Plot only those points that are over "land". Convert to device ; coordinates here in the Z-buffer, so you can identify the correct ; points in the mask. dc = Convert_Coord(lon, lat, /Data, /To_Device) indices = Where(mask[dc[0,*],dc[1,*]] EQ 0) ; Leave the Z-buffer. Set_Plot, thisDevice ; Draw the point data as small filled squares. symbol = cgSymCat(15) cgPlotS, lon[indices], lat[indices], PSym=symbol, $ Color=soilc_colors[indices], SymSize=0.5 ; Pretty everything up. cgMap_Continents, Color='charcoal' cgMap_Grid, /Box, Color='charcoal' cgColorbar, /Vertical, Position=[0.84, 0.1, 0.87, 0.85], Bottom=1, NColors=8, $ Divisions=8, Minor=0, YTicklen=1, Range=[0,Max(soilc)], AnnotateColor='charcoal', $ /Right, Title='Ton/ha', Format='(F5.3)' ; Add a title. cgText, 0.425, 0.925, /Normal, Alignment=0.5, 'Carbon Soil Map', Charsize=cgDefCharsize()*1.25 END ;***************************************************************** ; This main program shows how to call the program and produce ; various types of output. ; Display the plot in a graphics window. Point_Source_Plot ; Display the plot in a resizeable graphics window. cgWindow, 'Point_Source_Plot', WBackground='white', $ WXSize=600, WYSize=400, WAspect=2./3., $ WTitle='Point Source Map in a Resizeable Graphics Window' ; Create a PostScript file. cgPS_Open, 'point_source_plot.ps' Point_Source_Plot cgPS_Close ; Create a PNG file with a width of 600 pixels. cgPS2Raster, 'point_source_plot.ps', /PNG, Width=600 END