Assigning values from small grid into larger grid using nearest coordinates
조회 수: 4 (최근 30일)
이전 댓글 표시
I am trying to assign new values of depth from a smaller cropped grid (480 x 480 - lon, lat, depth) into a larger grid (4800 x 5760 - lon, lat, depth) using the nearest coordinates from both grids.
I have so far found the indexes of latitude and longitude which are within the larger grid, but I am struggling to assign the new bathymetry values at these index points, and keep the bathymetry values the same outside of these index points.
Would anyone be able to help me?
lon_new = unique(lon_smallgrid); % unique longitude values from the small grid (1800 x 1)
lat_new = unique(lat_smallgrid); % unique latitude values from the small grid (1800 x 1)
lon_orig = unique(lon.largegrid); % unique longitude values from the large grid (4800 x 1)
lat_orig = unique(lat.largegrid); % unique latitude values from the large grid (5760 x 1)
[ilon] = nearestpoint(lon_new, lon_orig); % value of lon_new which is closest to each value in lon_orig (1800 x 1)
[ilat] = nearestpoint(lat_new, lat_orig); % value of lat_new which is closest to each value in lat_orig (1800 x 1)
댓글 수: 0
답변 (1개)
KSSV
2019년 4월 16일
Read about knnsearch. This will give you indices and you can easily replace the values.
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!