"griddata" results in much smaller values than original data
Show older comments
I am using "griddata" function to interpolate original data on query points. However, the interpolation value on the query points are much smaller than the original data. Is there any way to improve the interpolation?
2 Comments
I suspect your lon, lat values are not exactly corresponding to elev. While running the code did you see the warning?
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
I suspect the high values correspond to diplicate lon, lat and have been removed.
When you check
nx = length(unique(lon)) ;
ny = length(unique(lat)) ;
nx*ny is not equal to 579072.
jie hu
on 18 Apr 2023
Accepted Answer
More Answers (1)
KSSV
on 18 Apr 2023
data=importdata('manila.dat');
lon=data(:,2);
lat=data(:,3);
elev=data(:,4);
xr = 118.7:0.2:121;
yr = 12.4:0.2:20.7;
[X, Y]= meshgrid(xr,yr);
idx = knnsearch([lon lat],[X(:) Y(:)],'k',10) ;
Z = reshape(max(elev(idx),[],2),size(X)) ;
plot3(lon(1:100:end),lat(1:100:end),elev(1:100:end),'o');
hold on
surf(X,Y,Z)
Categories
Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
