So briefly the points which are not supposed to be interpolated along large distances should assigned as NaN. is there a possibility to give a distance limit within points are allowed to be interpolated?
Set Tolerance Distance when Interpolating with Nearest Value
8 ビュー (過去 30 日間)
古いコメントを表示
Hello everybody, I have latitude(100x1) longitude(100x1) and height(100x1) of a river. I need to create a grid out of it therefore i have used meshgrid with min(lat), min(lon), max(lat), max(lon) and have latitude, longitude in a square matrix(100x100) form . As a second stage i need to interpolate the heights for each grid and have heights in matrix(100x100). However every interpolation method fills the grids even if they are not even correlated according to distance. It interpolates the edges which I don't want. I would like to interpolate only the values in river(or around it). I m also okay if it just takes nearest value but not larger than 10meters for example griddata(latitude, longitude, height, MESH_lat, MESH_lon, distance=10.0) or F = scatteredInterpolant(latitude, longitude, height,'linear','nearest',radius,1.0) then I can do MESH_H = F(MESH_lat,MESH_lon);
Hope I am clear what intended to do. Thank you for the support.
3 件のコメント
William Rose
2022 年 11 月 23 日
It is not clear to me what you want to do. Can you provide a small representative set of sample data? Instead of arrays with 82 million values in each, provide arrays with 30x40 points in each. Are the known heights located on a regular grid, and the locations where you want to interpolate irregularly spaced? Or vice versa? Do you want to create a set of points that are within a specified radius of a given point? If so, what is the location of the central point? Perhaps I will understand your question if you provide specific examples of each variable and array, of known heights and locaitons, and of desired query point locaitons. But don't let them be enormous, please.
回答 (1 件)
William Rose
2022 年 11 月 24 日
編集済み: William Rose
2022 年 11 月 24 日
I assume you know the heights at scattered points, and you want to interpolate the heights to points on a grid, but you only want the grid to include points that are within radius R of a specified central point, c.
N=1000; %number of randomly scattered points
x=4*rand(N,1)-2; %N random x values in (-2,+2)
y=4*rand(N,1)-2; %N random y values in (-2,+2)
z=peaks(x,y); %height at each random point
F=scatteredInterpolant(x,y,z); %F=interpolant
xg=-2:.1:2; yg=-2:.1:2; %grid vectors
[X,Y]=meshgrid(xg,yg);
Zint=F(X,Y); %interpolated heights on the grid
c=[.35,.15]; %center point
R=0.5; %radius around c
xr=X(((X-c(1)).^2+(Y-c(2)).^2)<=R^2); %x values in region
yr=Y(((X-c(1)).^2+(Y-c(2)).^2)<=R^2); %y values in region
zr=F(xr,yr); %interpolated heights in the region
surf(X,Y,Zint,'EdgeColor','none'); %plot interpolated surface
xlabel('X'); ylabel('Y'); zlabel('Z'); hold on;
plot3(xr,yr,zr,'r*')
figure
surf(X,Y,Zint,'EdgeColor','none'); %plot interpolated surface
xlabel('X'); ylabel('Y'); zlabel('Z'); hold on;
plot3(xr,yr,zr,'r*')
axis equal; view(0,90) %view from above
Try it.
2 件のコメント
William Rose
2022 年 11 月 24 日
I think the GIS community, or GIS experts on this site, will have ideas for yhow to do this efficiently, but I do not.
It makes me thinkk of the 12 nautical mile and 234 nautical mile limits on charts, as seen below for the Florida Keys.
The GIS people have figured out waysa to do this efficiently.
参考
カテゴリ
Help Center および File Exchange で Interpolating Gridded Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!