Creating 2D Matrix from latitude/longitude values

조회 수: 4 (최근 30일)
John Cruce
John Cruce 2021년 10월 2일
댓글: John Cruce 2021년 10월 3일
I have three 1D arrays of the same dimensions (14114 x 1): latitude, longitude, and radar reflectivity. The 1D arrays are not sorted in any particular way (i.e., by latitude or longitude). Here are sample values for the first three elements:
latitude (1,1): 29.28
longitude (1,1): -92.5
radar (1,1): 25
latitude (2,1): 29.5
longitude (2,1): -88.48
radar (2,1): 22.5
latitude (3,1): 29.5
longitude (3,1): -88.06
radar (3,1): 20.5
I need to create a 2D lat/lon matrix containing the radar values from the 1D array that spans from longitude [-92.5:0.02:-87.5] in the X and latitude [27.2:0.02:32] in the Y, but has the appropriate radar reflectivity value from the 1D radar array. Lat/lon pairs not in the 1D radar array should be stored as 0 in the 2D matrix.
Appreciate any help you can provide.

답변 (1개)

KSSV
KSSV 2021년 10월 2일
Let (x,y,r) be your lon,lat, radar reflectivity values in column.
xi = -92.5:0.02:-87.5 ;
yi = 27.2:0.02:32 ;
[X,Y] = meshgrid(xi,yi) ;
F = scatteredInterpolant(x,y,r) ;
R = F(X,Y) ;
pcolor(X,Y,R) ;
shading interp ;
colorbar
  댓글 수: 3
KSSV
KSSV 2021년 10월 3일
You can use knnsearch to find the nearest points, assign values to these and rest to zeros.
John Cruce
John Cruce 2021년 10월 3일
I did a help on knnsearch. I'm still unsure how to reflect those reflectivity values on to the meshgrid. What should I be looking to for my values of X and Y with knnsearch?

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

카테고리

Help CenterFile Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by