Re: Overplot on eastern US [message #7453] |
Tue, 19 November 1996 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Scott Applequist <applequi@leyla.gfdi.fsu.edu> writes:
> I'm trying to plot contours of some irregularly spaced data
> on a map of the eastern US. The values themselves are not a
> problem, getting the grid to /overplot on the map is. All of
> the following plots a map with + marks at each city.
>
> [good program stuff deleted ...]
>
> r= sph_scat(x, y, c, bounds=[-115., 24., -67., 49.],gs=[0.5,0.5])
>
> Now I can contour the array r, or even make a surface plot of it,
> but I cannot get it to lay on top of the previously drawn map.
> I have a feeling that the array coordinates must be shifted, but
> I don't see how. I'm using IDL. Version 4.0.1 (vms alpha).
The problem with gridding irregular data and then trying to
contour the resulting gridded array on a map is almost always
getting the vectors that go with the gridded data formed
properly. (Remember that on a map projection the CONTOUR
command will need to be called with all three of its
positional parameters.)
I don't have Scott's data, but here is a little program that
creates some random data in Scott's map projection space
and shows how I can grid it and lay it on top of the map
projection. The trick here is using the BOUT keyword to
get the output bounds of the gridded data (actually
the same as the input bounds in this case, but not--I
think--generally), and using the bounds to make the
appropriate xlon and ylat vectors for the CONTOUR
command.
*************************************************
PRO EXAMPLE
; Pick a seed, so you see what I see. Create data.
seed = -1L
lat = RANDOMU(seed, 40) * (24./1.0) + 24
lon = RANDOMU(seed, 40) * 40.0/1.0 - 112
data = RANDOMU(seed, 40) * 1000
; Colors for plot.
TVLCT, [255, 0], [255, 255], [0,0], 1
; Set up Scott's map projection.
MAP_SET, 15, -87, 0, LIMIT=[24,-115,49,-67], $
/CONTINENTS, /USA, /MERCATOR
; Plot the random locations.
PLOTS, lon, lat, PSYM=4, COLOR=2
; Grid the irregularly spaced data.
gridData= SPH_SCAT(lon, lat, data, $
BOUNDS=[-115., 24., -67., 49.], GS=[0.5,0.5], BOUT=bout)
; Calculate xlon and ylat vectors corresponding to gridded data.
s = SIZE(gridData)
xlon = FINDGEN(s(1))*((bout(2) - bout(0))/(s(1)-1)) + bout(0)
ylat = FINDGEN(s(2))*((bout(3) - bout(1))/(s(2)-1)) + bout(1)
; Put the contours on the map.
CONTOUR, gridData, xlon, ylat, /OVERPLOT, NLEVELS=10, C_COLOR=1
END
*************************************************
Hope this sheds some light.
David
*************************************************
* David Fanning, Ph.D.
* 2642 Bradbury Court, Fort Collins, CO 80521
* Phone: 970-221-0438 Fax: 970-221-4762
* E-Mail: davidf@dfanning.com
*
* Sometimes I go about pitying myself, and all along my
* soul is being blown by great winds across the sky.
* -- Ojibway saying
************************************************
|
|
|