X
33 Rate this article:
No rating

Internal: Programmatic Approach to Incorporating Map Projections in iContour

Anonym

This article outlines the steps required to programmatically display georeferenced contour data as an iContour in iMap. The example code, as seen below, and sample data used are available here.
  • Set the original color decomposition to a variable,then turn decomposition off and get a color table and add it to the display
  • Create a data holder array (flux) into which the data from the text file will be read and create sample lon and lat values (xx,yy)
  • Open the file and read its contents into 'flux'
  • Any contour specific data that needs to go directly into iMap does so via the /CONTOUR keyword in iMap
  • Set up the iMap Hammer projection parameters and add the continents to the iMap
  • Set up the iMap Mercator projection parameters and add the continents to the iMap
  • Now overplot the iContour data onto each projection
  • Restore the original color decomposition value
PRO Projections_w_iContour
;+
;NAME:
; Projections_w_iContour.pro
;
; PURPOSE:
; The purpose of this program is to demonstrate how to overlay geographically 
; referenced contour data onto different map projections. This example uses the  
; Hammer and Mercator projections. 
;
;-

; Set the original color decomposition to a variable,then turn decomposition
; off and get a color table and add it to the display
device, GET_DECOMPOSED=olddc
device, DECOMPOSED=0
loadct, 39, /SILENT
tvlct, r, g, b, /GET
rgbtable = [[r],[g],[b]]

; Create a data holder array (flux) into which the data from the 
; text file will be read and create sample lon and lat values (xx,yy)
flux = fltarr(72,36)
xx = findgen(72) * 5 - 177.5
yy = findgen(36) * 5 - 87.5

;Open the file and read its contents into 'flux'
openr, lun, 'C:\Temp\fluxL.txt', /GET_LUN
readf, lun, flux
free_lun, lun

; Any contour specific data that needs to go directly into iMap does so via
; the /CONTOUR keyword in iMap
;
; ****************  HAMMER PROJECTION  ****************
iMap, flux, xx, yy, $
    MAP_PROJECTION= 'Hammer', $
    RGB_TABLE=rgbtable, $
    LEVELS=5*indgen(32),  $
    LIMIT= [-25, -177.5, 25, 177.5], $
    /CONTOUR, $
    GRID_UNITS= 2, $
    VIEW_GRID=[1, 2], $
    VIEW_TITLE= 'Hammer Projection'
       
; Add the continents to the iMap...
tool = itgetcurrent(tool=oTool)
void = oTool->DoAction('Operations/Insert/Map/Continents')
oContinents = oTool->GetSelectedItems()
idCont = oContinents->GetFullIdentifier()
success = oTool->DoSetProperty(idCont, 'Transparency', 0)
success = oTool->DoSetProperty(idCont, 'Fill_Color',[192,192,192])


; ****************  MERCATOR PROJECTION  ****************       
iMap, flux, xx, yy, $
    MAP_PROJECTION= 'Mercator', $
    RGB_TABLE=rgbtable, $
    LEVELS= 5*indgen(32),  $
    LIMIT= [-25, -177.5, 25, 177.5], $
    /CONTOUR, $
    GRID_UNITS= 2, $
    /VIEW_NEXT, $
    VIEW_TITLE= 'Mercator Projection'
       
; Again add the continents to the iMap...
tool = itgetcurrent(tool=oTool)
void = oTool->DoAction('Operations/Insert/Map/Continents')
oContinents = oTool->GetSelectedItems()
idCont = oContinents->GetFullIdentifier()
success = oTool->DoSetProperty(idCont, 'Transparency', 0)
success = oTool->DoSetProperty(idCont, 'Fill_Color',[192,192,192])
 
; Now overplot the contour data onto each projection...
iContour, flux, xx, yy, $
    /OVERPLOT, $
    AUTO_COLOR=1, $
    RGB_TABLE=rgbtable

; Restore the original color decomposition value
device, DECOMPOSED=olddc
   
END