Re: replace missing values with nearest neighbor

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 16 Oct 2006 11:54:20 -0600 (MDT)

>
>Is there a way to replace missing values in a var (lat x lon) with
>values from the nearest location where there is data?
>
___________________________________

Yes, I think the following would work.

Assuming you have X(lat,lon) which has missing
values [X@_FillValue] and one dimensional
coordinate arrays: lat(*), lon(*)

   nMsg = num( ismissing(X) ) ; count the number of missing
   
   if (nMsg.gt.0) then ; only enter if missing present
       z = grid2triple (lon,lat,X)
       opt= True/False ; user specified
       X = triple2grid(z(0,:),z(1,:),z(2,:), lon,lat, opt)
       delete(z)
   end if

http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/grid2triple.shtml

good luck
D

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 16 2006 - 11:54:20 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 16 2006 - 22:16:12 MDT