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 ( 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)
   end if

good luck

ncl-talk mailing list
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