How to grid data based on distance, rather than longitude and latitude?

5 views (last 30 days)
If I want to grid my data into longitude and latitude grids over the whole planet, I can simply do this:
[X, Y] = meshgrid([20:1:380],[-90:1:90]);
Z = griddata(lon, lat, parameter, X, Y);
The issue is that the earth is a globe. Distance is squeezed towards the poles. How do I do the gridding based on distance?
My advisor has asked me to do the gridding based on 1550km * 740km.
Please help.
  1 Comment
Image Analyst
Image Analyst on 7 May 2015
You can't map rectangles over the spherical planet without gaps or overlapping. I don't see anyway around it. Ask him to show you a picture of where he wants these rectangles placed.

Sign in to comment.

Answers (1)

Kelly Kearney
Kelly Kearney on 7 May 2015
You could calculate the geographic distance from your data points to each point in the grid (using distance.m in the Mapping Toolbox or any one of many 3rd-party toolboxes, like m_map or GSW). But then you need to use a different interpolation algorithm than griddata, since griddata (and scatteredInterpolant) assumes Euclidean distance between points in its calculations. Something like inverse distance weighting might be appropriate.
The other option would be to project your data into x/y space, using a projection that preserves distance pretty well. This is usually my solution when working with regional datasets, but I'm not sure if this could be easily translated to a global scale, since all global projections include some manner of distortion. Perhaps you could break the interpolation into smaller regions?
  8 Comments
Leon
Leon on 11 May 2015
Thank you! It is working now, but when I switch it to my data, my computer just become frozen. I have global data with up 10,000 rows of data, and I want to grid it on a 1*1 grid.
Looks like "invdistweight" is a whole new gridding method. Is there a way I can do distance gridding with the gridding method I prefer, in this case, DIVA?
Thanks.
Kelly Kearney
Kelly Kearney on 11 May 2015
With that many data points, your interpoint distance matrix is going to be huge, so yeah, IDW is probably not your best bet there. (I've thought about adapting IPDM to allow for geopgraphic distances, and therefore allow my function to deal with larger datasets, but I haven't gotten around to it yet).
Do you actually have a Matlab function to do the DIVA gridding? That's a pretty complex algorithm, and the appropriate format for your input coordinates would depend on exactly how that function calculates distance internally. Honestly, you'd probably be much better off using Ocean Data View, or one of the other interfaces specifically designed for that type of gridding; I'm pretty sure those deal with all the geographic distance issues already.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!