Plotting geographic data not oriented on a grid

I have a column vector of data (23038 x 1), which corresponds to a column vector of the same length for latitude and another for longitude. I am attempting to plot this data (I have used surfm, surfacem, pcolorm), but it always causes MATLAB to slow down to the point of crashing. I assume that this is because matlab prefers the data to be oriented at a 2D matrix (grid). Is this correct, and if so how would I convert the data for plotting? Thanks!

 Accepted Answer

Hey Collin,
First of all, really neat looking map when you just plot the points at which the data was taken:
Using griddata, you can mesh out your current dataset into a grid:
latmin = min(lat_piomas);
latmax = max(lat_piomas);
lonmin = min(lon_piomas);
lonmax = max(lon_piomas);
gridSize = [100 200];
latvec = linspace(latmin, latmax, gridSize(1));
lonvec = linspace(lonmin, lonmax, gridSize(2));
[LatQ LonQ] = ndgrid(latvec, lonvec);
ThickQ = griddata(lon_piomas, lat_piomas, thickness, LonQ, LatQ);
From there, it's a simple matter to show the data in whichever format you like:
figure
axesm('mercator', 'MapLonLimit', [0 360])
geoshow(LatQ, LonQ, ThickQ, 'DisplayType', 'surface')
And if you want to get real fancy, you can use topological data to show the elevation of the surface, while using the color to show the "thickness" data. Here's an example using built-in example topography data:
% Get example topography data
load topo topo topolatlim topolonlim
Rtopo = georefcells(topolatlim, topolonlim, size(topo));
ElevQ = geointerp(topo, Rtopo, LatQ, LonQ, 'cubic');
% Display the surface
figure
axesm('mercator', 'MapLonLimit', [0 360])
geoshow(LatQ, LonQ, ElevQ, 'DisplayType', 'surface', 'CData', ThickQ)
daspectm('m', 1000) % To exaggerate the height of the topography
Hope this is helpful and interesting.
-Cam

More Answers (1)

For scattered data which is what the column vectors are, use:
scatterm
If those data represent a grid but are oriented as single column vectors, then use geointerp to interpolate to a 2d grid and then call surfm or meshm.

4 Comments

Okay, I think this is getting me closer. The data represents sea ice thickness (so should be plotted continuously), and I think the geointerp method is what I'm looking for. But I'm not quite sure how to tranform three column vectors into three matrices with it, thanks again!
Assuming that your datapoints are not already in a nice grid layout, you would likely have the best luck either using griddata or constructing a scatteredInterpolant to take the vector data. You can use the regular grid latitude and longitude values as the query points. Once you have your grid data, you can use surfm or similar functions.
Though griddata and scatteredInterpolant don't handle latitude and longitude specifically, they should work so long as you're not running into edge artifacts (points at the poles or wrap-arounds of the Earth).
You could also look into the code for geointerp to see how it does the interpolation using intrinsic coordinates. This helps deal with some of those edge artifacts, and can simplify the intermediary interpolation grids. But it's probably not necessary, and it's usually easier to think in geographic coordinates.
Can you provide a small set of data?
Yes, thank you! This is the entire geographic span. One vector for thickness, one for lat, and one for lon.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!