comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: contouring into continents only
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: contouring into continents only [message #31811 is a reply to message #31810] Mon, 19 August 2002 07:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David (losiento@peromefrienaspam.com) writes:

> I'm desperately trying to draw contour lines inside continental boundaries
> only (I have irregularly gridded precipitation data). I have test several
> 'brute force' methods (as creating a mask of 1 over land and 0 over seas)
> but none seems to work properly.
>
> Is there any easy (as any esoteric keyword unknown to me) method to do that?

No esoteric keywords, unfortunately. :-(

But here is a modified example from my web page that uses
a mask to only draw the portion of the contours that are
over land:

************************************************************ ***
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.

LOADCT, 0
TVLCT, [255, 0], [255, 255], [0,0], 1

thisDevice = !D.Name
Set_Plot, 'Z'
Device, Set_Resolution=[800, 600]

; Set up the map projection of the Eastern US.

MAP_SET, 15, -87, 0, LIMIT=[24,-115,49,-67], $
/CONTINENTS, /USA, /MERCATOR, Position=[0.1,0.1,.9,.9]

; Plot the random data 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=20, C_COLOR=1
map = TVRD()

; Now draw the mask.

ERASE
MAP_SET, 15, -87, 0, LIMIT=[24,-115,49,-67], $
/MERCATOR, Position=[0.1,0.1,.9,.9]
Map_Continents, /FILL, /USA, /HIRES, /CONTINENTS
mask = TVRD()

; Display both the upclipped and clipped contours.

Set_Plot, thisDevice
Window, XSize=800, YSize=600, Title='Unclipped contours'
TV, map
Window, 1, XSize=800, YSize=600, Title='Clipped contours'
screen = Where(mask EQ 0)
map[screen] = 0
TV, map
END
************************************************************ *******

It seems to do a reasonably good job.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Read/format mixed int/flt/strng ascii files
Next Topic: Weighting Function

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 00:54:28 PDT 2025

Total time taken to generate the page: 1.04052 seconds