Hello Idl Users,
I tried to interpolate the following scattered data using 2 -D griddata function
lat=[32.05, 30.43,29.02,25.48, 24.13,32.49, 32.47,32.06,29.40]
lon=[20.16,20.10, 21.34, 21.08, 23.18, 21.51, 22.35, 23.55, 24.32]
w=[9.80,4.95,5.20, 5.60, 5.20, 11.65, 11.75, 8.75, 7.40]
and use this gridded data to create a contour plot on the map using the following code:-
:___________________________________________________________ _____
pro test
lat=[32.05, 30.43,29.02,25.48, 24.13,32.49, 32.47,32.06,29.40]
lon=[20.16,20.10, 21.34, 21.08, 23.18, 21.51, 22.35, 23.55, 24.32]
w=[9.80,4.95,5.20, 5.60, 5.20, 11.65, 11.75, 8.75, 7.40]
scaled = BYTSCL(w, TOP = !D.TABLE_SIZE - 4) + 1B
; display the data values with respect to the color table.
FOR i = 0L, (N_ELEMENTS(Lat) - 1) DO PLOTS, Lat[i], Lon[i],$
PSYM = -1, SYMSIZE = 2., COLOR = scaled[i]
; Preprocess and sort the data.
GRID_INPUT, lat_data, lon_data, scaled, xSorted, ySorted, dataSorted
; Initialize the grid parameters.
gridSize = [51, 51]
; Use the equation of a straight line and the grid parameters to
; determine the x of the resulting grid.
slope = (MAX(xSorted) - MIN(xSorted))/(gridSize[0] - 1)
intercept = MIN(xSorted)
xGrid = (slope*FINDGEN(gridSize[0])) + intercept
; Use the equation of a straight line and the grid parameters to
; determine the y of the resulting grid.
slope = (MAX(ySorted) - MIN(ySorted))/(gridSize[1] - 1)
intercept = MIN(ySorted)
yGrid = (slope*FINDGEN(gridSize[1])) + intercept
; Grid the data with the Radial Basis Function method.
grid = GRIDDATA(xSorted, ySorted, dataSorted, $
DIMENSION = gridSize, METHOD = 'RadialBasisFunction')
; Plot Structure using Fanning subroutines
psObject = Obj_New("FSC_PSConfig")
psObject->GUI
thisDevice = !D.Name
Set_Plot, "PS"
Device, _Extra=psObject->GetKeywords(FontType=fonttype)
;?????????????????????????
TVLCT, FSC_Color(soil_colors, /Triple), 1
Erase, Color=FSC_Color('white')
map_set, /cylindrical, 0,0, limit=[19,08,38,28],/continent,/grid, $
/NoErase, Position=[0.1, 0.1, 0.8, 0.9], MLINESTYLE =0, $
MLINETHICK =2,GLINETHICK=2 ; mercator ; cylindrical
cgText,14000,5250,/device, 'Egypt', CHARSIZE=1.5,font=1,ORIENTATION=90.0
cgText, 7400,6700,/device, 'Libya', CHARSIZE=1.5,font=1,ORIENTATION=0.0
cgText, 13500,2000,/device, 'Sudan', CHARSIZE=1.5,font=1,ORIENTATION=45.0
cgText,8000,2500,/device, 'Chad', CHARSIZE=1.5,font=1,ORIENTATION=0.0
cgText, 4500,2500,/device, 'Niger', CHARSIZE=1.5,font=1,ORIENTATION=0.0
cgText,2500,5500,/device, 'Algeria', CHARSIZE=1.5,font=1,ORIENTATION=90.0
cgText, 2500,11000,/device, 'Tunisia', CHARSIZE=1.5,font=1,ORIENTATION=45.0
cgText, 6000,12000,/device, 'The Mediterranean Sea', $
CHARSIZE=1.5,font=1,ORIENTATION=0.0
cgText, 7000,400,/device, 'Longitude', CHARSIZE=1.5,font=1,ORIENTATION=0.0
cgText, 1000,5500,/device, ' Latitude', CHARSIZE=1.5,font=1,ORIENTATION=90.0
soil_colors = ['purple', 'dodger blue', 'dark green', 'lime green', $
'green yellow', 'yellow', 'hot pink', 'crimson']
SOILC = fltarr(n_elements(lat_data))
TVLCT, FSC_Color(soil_colors, /Triple), 1
soilc_colors = BytScl(soilc, Top=7) + 1B
Plots,lon, lat, PSym=4, COLOR=FSC_Color('red'), SymSize=0.45
map_continents, /coasts,/countries, color=0, /hires, /bold, linestyle=0,
background=50,thick=5
Map_Grid,/box, CHARSIZE=1.0,font=1,thick=1.5;, Color=FSC_Color('black')
CONTOUR,grid, xGrid,yGrid, /XSTYLE, /YSTYLE, /FILL, $
LEVELS = BYTSCL(INDGEN(18), TOP = !D.TABLE_SIZE - 4) + 1B, $
C_COLORS = BYTSCL(INDGEN(18), TOP = !D.TABLE_SIZE - 4) + 1B,$
TITLE = 'The Resulting Grid with Radial Basis Function', $
XTITLE = 'Lat', YTITLE = 'lon'
Device, /Close_File
Set_Plot, thisDevice
Obj_Destroy, psObject
end
:____________________________ the contour lines aren't projected on the right
map.
Can any IDL experts help me
my Best wishes
Mohamoud
|