Re: Duplicate lat/long points [message #64680] |
Wed, 14 January 2009 07:19  |
hethomas
Messages: 19 Registered: December 2008
|
Junior Member |
|
|
Thank you both for your responses, they are definitely making me think
about alternative ways to tackle this.
However, Brian - I am struggling to see how you use histogram to do
this. Do you have an example of this that you wouldn't mind sharing so
that I can see more clearly what you mean?
Thanks again.
Helen
|
|
|
|
Re: Duplicate lat/long points [message #64688 is a reply to message #64685] |
Wed, 14 January 2009 05:10   |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Jan 14, 5:21 am, hethomas <het...@googlemail.com> wrote:
> From searching this forum for "duplicate points" I found that a while
> back, under the thread entitled "duplicates - a new twist" my problem
> was posted (almost exactly identically) by Martin Doyle.
> [ http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/
> thread/470ca560db41c58a/df9dba74d5788f6c?lnk=gst&q=dupli cate
> +points#df9dba74d5788f6c ]
>
> In short, I have a list of latitude, longitude and data and need to
> combine any duplicate lat longs by summing the data value.
>
> Despite the many follow up answers to this I am still having problems
> with using the UNIQ function on both latitude and longtude as they
> each need to be sorted numerically for IDL to work. Is anyone able to
> shed any light on this?! Or indeed, know of a quicker/easier method.
> There is a function in R called "aggregate" which appears to do
> exactly what I need, but I am unable to find an IDL equivalent.
>
> Any help is greatly appreciated!
>
> Helen
As I understand it I see the following solution although there could
be numerous faster more elegant ones this is my back of the hand
approach.
Arbitrary values...although they could be floating point, etc...
lats1 = [20,25,30,35,40,45,50,55]
lats2 = [15,25,35,35,40,42,32,28]
lons1 = [1,2,3,4,5,6,7,8]
lons2 = [0,2,6,2,5,9,7,8]
data1 = [1,2,3,4,5,6,7,8]
data2 = [10,11,12,13,14,15,16,17]
latIndices = where(abs(lats1-lats2) LT 1e-5)
IDL> print, latIndices
1 3 4
lonIndices = where(abs(lons1-lons2) LT 1e-5)
IDL> print, lonIndices
1 4 6 7
Now that you've found matching indices into both lat and lon space you
figure out where they're equal and use that to index your data for
summing
A description of setintersection can be found at
http://www.dfanning.com/tips/set_operations.html
inds = setintersection(latIndices, lonIndices)
IDL> print, inds
1 4
total = data1[inds] + data2[inds]
IDL> print, total
13 19
Which yields the correct answer as I see it. If this helps then
excellent...if not...not so much excellence. But keep poking for an
answer.
Best of Luck,
Bennett
|
|
|
|