ROI's and geographical data! [message #35269] |
Thu, 05 June 2003 07:53  |
einare
Messages: 1 Registered: June 2003
|
Junior Member |
|
|
Hi.
I've been usind IDL now for a whole two weeks now!
My problem is that i have two data sets. One defining a ROI (in
latitude-longitude)
and another one evenly, but broadly spaced data set, combined of
lat-lon-value.
I've defined the ROI and i want a simple, non gui, procedure of
picking all the values which are inside the ROI. And because they are
broadly spaced I used the rebin function to narrow it down, making
huge data sets.
The only solution I see is making a loop testing each point, something
like:
IF roi->ContainsPoints(lon_fin[j], lat_fin[j]) GT 0 THEN BEGIN
dat_end[i]=dat_exp[j]
lon_end[i]=lon_fin[j]
lat_end[i]=lat_fin[j]
i = i+1
ENDIF
wich is not very good inside a loop with huge data sets.
I would be verry happy if somone has solved, or can solve, this
problem for me!!
|
|
|
Re: ROI's and geographical data! [message #35368 is a reply to message #35269] |
Thu, 05 June 2003 08:08  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Einar Einarsson (einare@hi.is) writes:
> The only solution I see is making a loop testing each point, something
> like:
>
> IF roi->ContainsPoints(lon_fin[j], lat_fin[j]) GT 0 THEN BEGIN
> dat_end[i]=dat_exp[j]
> lon_end[i]=lon_fin[j]
> lat_end[i]=lat_fin[j]
> i = i+1
> ENDIF
>
> wich is not very good inside a loop with huge data sets.
There is no reason to do this in a loop (unless you
are consciously trying to slow everything down). The
ContainsPoints function has already been vectorized.
I would try something like this:
pts= roi->ContainsPoints(lon_fin, lat_fin)
inside_pts = Where(pts GT 0, count)
IF count GT 0 THEN BEGIN
lon_end = lon_fin[inside_pts]
lat_end = lat_fin[inside_pts]
ENDIF
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
|
|
|