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

Home » Public Forums » archive » Re: Removing equal elements from an array
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: Removing equal elements from an array [message #49748 is a reply to message #49746] Wed, 16 August 2006 05:55 Go to previous messageGo to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
Mike wrote:
> Julio wrote:
>> I have an array 'A' with two columns, latitudes and longitudes, and
>> several lines. A need to make another array with the elements of A that
>> don't repeat.
>
> Take a look at the uniq function. Here's an example:

[snip]

Which still doesn't take into account the following situation:

A = [[20.4, 40.3, 50.2, 50.2], $
[30.2, 60.2, 32.4, 32.5]]

in which case no items should be removed. Just thinking out aloud here.
With:
lat = A[*,0] & lon = A[*,1]

we have
idx_lat = uniq(lat) & idx_lon = uniq(lon)

At the very least both index arrays should be the same, if you want to
apply this automagically.

If the precision of the coordinates is limited, you can try to combine
the lat and lon in a single number. If the coordinates are floats, the
following ought to work:

I = lat + (2.0D0^23)*lon
idx = uniq(I)
lat = lat[idx] & lon = lon[idx]

Maarten
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: File_COPY
Next Topic: SETENV

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

Current Time: Sat Oct 11 09:20:49 PDT 2025

Total time taken to generate the page: 0.32828 seconds