How to grid data based on distance, rather than longitude and latitude?
5 views (last 30 days)
Show older comments
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
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.
Answers (1)
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
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!