필터 지우기
필터 지우기

"griddata" results in much smaller values than original data

조회 수: 1 (최근 30일)
jie hu
jie hu 2023년 4월 18일
댓글: jie hu 2023년 4월 20일
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
KSSV
KSSV 2023년 4월 18일
편집: KSSV 2023년 4월 18일
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
jie hu 2023년 4월 18일
Yes, when I run 'IC_plot.m' matlab reports the duplicate points and removed them. averaged value is taken. My idea is to detect the duplicate points and take the biggest value on each point. Is that realizable?

댓글을 달려면 로그인하십시오.

채택된 답변

Chunru
Chunru 2023년 4월 18일
편집: Chunru 2023년 4월 18일
It is due to the duplicate points in data. Griddata is averaging over the duplicate points to have a smaller value than peak. If you remove the duplicate points, then the result will be similar.
websave("manila.zip","https://www.mathworks.com/matlabcentral/answers/uploaded_files/1359608/manila.zip")
ans = '/users/mss.system.Ktq2V0/manila.zip'
unzip("manila.zip")
% plot x y z vector
data=importdata('manila.dat');
lon=data(:,2);
lat=data(:,3);
elev=data(:,4);
% Remove duplicate points
% [~, I, ~] = unique([lon lat], 'first', 'rows');
% lon = lon(I);
% lat = lat(I);
% elev = elev(I);
% Use peak for duplicated points
c = unique([lon lat], 'first', 'rows');
n = size(c,1)
n = 48256
lon1 = zeros(n, 1);
lat1 = zeros(n, 1);
elev1 = zeros(n, 1);
for i=1:size(c, 1)
idx = lon==c(i, 1) & lat==c(i,2);
lon1(i) = c(i, 1); lat1(i) = c(i, 2);
elev1(i) = max(elev(idx));
end
max(elev(:))
ans = 20.8693
plot3(lon,lat,elev,'.');
% xlin = linspace(min(lon)+0.2,max(lon)-0.2, 51);
% ylin = linspace(min(lat)+0.2,max(lat)-0.2, 201);
xr = (min(lon1):0.01:max(lon1));
yr = (min(lat1):0.01:max(lat1));
[X, Y]= meshgrid(xr,yr);
Z = griddata(lon1,lat1,elev1,X,Y,'natural');
max(Z(:))
ans = 20.8693
mesh(X,Y,Z)
% jump_grid = 1;
%
% figure
% surf(X(1:jump_grid:end,1:jump_grid:end), ...
% Y(1:jump_grid:end,1:jump_grid:end), ...
% Z(1:jump_grid:end,1:jump_grid:end));
% shading interp;
% whos

추가 답변 (1개)

KSSV
KSSV 2023년 4월 18일
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)

카테고리

Help CenterFile Exchange에서 Geometric Geodesy에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by