2nd try : Nearest defined neighbor function

Pablo Romero romero619 at HOTMAIL.COM
Tue Jan 6 12:05:56 EST 2009


it would be very cool if grads included "nearest neighbor" functions.
maybe a UDF? how hard/complicated would it be to setup the math for each case: max, min, average? would a cause plotting to be somewhat slower/processor intensive?



Date: Tue, 6 Jan 2009 10:45:28 -0600From: smcmillan at PLANALYTICS.COMSubject: Re: 2nd try : Nearest defined neighbor functionTo: GRADSUSR at LIST.CINECA.ITPatrick,What if an undefined point has more than one "nearest neighbor" and are of different values?  Do you want to assign an average of these, the highest, lowest, etc.?  I'm assuming each gridpoint has up to eight nearest neighbors in complex coastal areas.  For example, you could get the max nearest neighbor using something like this:'define newvar= max(max(var,x=-152,x=-150),y=262,y=264)'Then assign result to point (in this case, x=-151, y=263) using the 'set defval var...' command.Similarly, you could use 'define var= min(min...' to get min value of nearest 8-neighbor or the "aave" command to get average of nearest neighbor.Hope this helps....Stephen McMillan



Patrick Reuter <preuter at LABRI.FR>Sent by: GRADSUSR at LIST.CINECA.IT
01/06/2009 07:39 AM




Please respond toGRADSUSR at LIST.CINECA.IT





To
GRADSUSR at LIST.CINECA.IT


cc



Subject
2nd try : Nearest defined neighbor function




Sorry for multiples, message was somehow rejected ..Dear all,I have a variable which is only defined over the sea, elsewhere thereare undefined values. Is there a function in Grads that can draw me amap where at locations of undefined values, instead of leaving itblank, draws me the value of the nearest defined value of the8-neighborhood ? I know about the existence of 'smth9', but it doesnot exactly what I want, since it smoothes out, and 'const', since youhave to specify a default value which I don't know since it should tobe determined from the nearest neighbor !Can anybody help?Thanks in advancePatrick***************************************************The information contained in this e-mail message is intended only for the use of the recipient(s) named above and may contain information that is privileged, confidential, and/or proprietary. If you are not the intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the sender immediately by e-mail, and delete the original message.***************************************************
_________________________________________________________________
It’s the same Hotmail®. If by “same” you mean up to 70% faster.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090106/29d5a093/attachment.html 


More information about the gradsusr mailing list