Assigning values from small grid into larger grid using nearest coordinates
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
KSSV
el 16 de Abr. de 2019
Read about knnsearch. This will give you indices and you can easily replace the values.
1 comentario
Charlotte Findlay
el 16 de Abr. de 2019
Editada: Charlotte Findlay
el 16 de Abr. de 2019
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!