Plotting non-gridded vectorial data on a map

Hello,
I would like to plot the evolution of wind velocity along the trajectory of a drifting buoy. I have the following variables:
lon [N x 1] vector: longitude at the N locations transmitted by the buoy [degrees east]
lat [N x 1] vector: latitude at the N locations transmitted by the buoy [degrees north]
uwind [N x 1] vector: u-component of the wind velocity at the N locations transmitted by the buoy [m/s]
vwind [N x 1] vector: v-component of the wind velocity at the N locations transmitted by the buoy [m/s]
I have tried the following:
figure; hold on;
plot (lon, lat, 'k.'); % Plot buoy trajectory
axis equal; axis([min(lon)-.02, max(lon)+.02, min(lat)-.02, max(lat)+.02]); % Set axis limits
quiverwcolorbar(lon, lat, uwind, vwind, 0.0025, 'bounds', [3 12]); % Arrow plot
title('Wind speed (m/s)');
I could have used "quiver" instead of "quiverwcolorbar". This figure (attached) is fine, but I am not using any specific map projection and I am not sure about whether the vectors are pointing to the right direction. For example, if I use "axis equal", both the longitude and the latitude axis will share the same scaling, but I feel this is not correct since a change of 1º in the east-west direction does not involve the same displacement (e.g. in miles or kilometers) as a change of 1º in the north-south direction.
So, I moved to the MATLAB Mapping Toolbox and tried the following code:
figure; hold on; H = worldmap([min(lat)-.02, max(lat)+.02], [min(lon)-.02, max(lon)+.02]);
setm(H, 'MapProjection', 'mercator'); % Using a conformal, angle-preserving projection
quiverwcolorbar(lon, lat, uwind, vwind, 0.0025, 'bounds', [3 12]); % Arrow plot
However, it doesn't work, no matter I use the "quiver" function or the "quiverwcolorbar" function. No error is returned, but I can't see the arrows on the map. So, I tried using quivermc:
figure; hold on; H = worldmap([min(lat)-.02, max(lat)+.02], [min(lon)-.02, max(lon)+.02]);
setm(H, 'MapProjection', 'mercator'); % Using a conformal, angle-preserving projection
quivermc(lat, lon, uwind, vwind);
But the following error is returned:
??? Error using ==> quivermc at 145 Input lat, lon, u, and v must be a grid.
I'm working with non-gridded data, since my data don't come from an eulerian field, but from positions along the path of a drifing buoy. Perhaps I can write my data into a grid, with:
slon = sort(lon, ‘ascend’); slat = sort(lat, ‘ascend’);
[LON, LAT] = meshgrid(slon,slat); % Creates LON [N x N] and LAT [N x N] arrays
UWIND = nan(size(LON)); VWIND = nan(size(LAT));
for i=1:N
lon_i = lon(i); lat_i = lat(i); % longitude and latitude in this iteration
uwind_i = uwind(i); vwind_i = vwind(i); % u-wind and v-wind in this iteration
lonIdx = find(slon == lon_i); latIdx = find(slat == lat_i); % find longitude and latitude indexes
UWIND(lonIdx, latIdx) = uwind_i; VWIND(lonIdx, latIdx) = vwind_i; % write wind data into a gridded format
end
figure; hold on; H = worldmap([min(lat)-.02, max(lat)+.02], [min(lon)-.02, max(lon)+.02]);
setm(H, 'MapProjection', 'mercator'); % Using a conformal, angle-preserving projection
quivermc(LAT, LON, UWIND, VWIND);
No error is returned. However, although I'm working with gridded data now, I can't see the arrows on the map, just a few scattered points. What am I doing wrong? Is there any MATLAB function to plot non-gridded vectorial data using a Map Projection?
Thank you.

1 Comment

I am having the exact same issue. Did you find a solution?

Sign in to comment.

Answers (0)

Asked:

on 6 Feb 2017

Commented:

on 29 Jul 2019

Community Treasure Hunt

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

Start Hunting!