Not a map axes. How to plot quiver and geobasemap in one figure?

28 views (last 30 days)
Hi everyone! I want to plot current vectors along a line (coordinates given by lat and lon) and corresponding map in the background. Here's my code:
geoplot([44.392186 44.393524],[8.930812 8.931615],'w:')
geolimits([44.390 44.396],[8.928 8.934])
geobasemap satellite
x = table2array(FData(:,4)); % x - longitudes stored in the table 'FData', column 4
y = table2array(FData(:,3)); % y - latitudes stored in the table, column 3
u = table2array(FData(:,7)); % u - horizontal extend (delta longitude), column 7
v = table2array(FData(:,6)); % y - vertical extend (delta latitude), column 6
quiverm(x, y, u, v,'.');
And here's the error: Not a map axes.
(Error using gcm (line 25) Not a map axes.)
(Error in quiverm (line 88) mstruct = gcm;)
I am very new to MATLAB and simply getting lost in this. Wasted quite a lot of time on trying things, but didn't work out. I'd appreciate any practical advice to solve this! Thanks much!
PS. Matlab version R2020a

Accepted Answer

Kevin Holly
Kevin Holly on 21 Jan 2022
geoplot([44.392186 44.393524],[8.930812 8.931615],'w:')
geolimits([44.390 44.396],[8.928 8.934])
geobasemap satellite
load('FData.mat')
x = table2array(FData(:,4)); % x - longitudes stored in the table 'FData', column 4
y = table2array(FData(:,3)); % y - latitudes stored in the table, column 3
u = table2array(FData(:,7)); % u - horizontal extend (delta longitude), column 7
v = table2array(FData(:,6)); % y - vertical extend (delta latitude), column 6
gca
ans =
GeographicAxes with properties: Basemap: 'satellite' Position: [0.1813 0.1100 0.7237 0.8150] Units: 'normalized' Show all properties
The axes is a GeographicAxes and the quiverm command only works on map axes. I could not find an equivalent quiver command for geoaxes, so I decided to use geoplot instead.
hold on
geoplot(y,x)
quiver only works on cartesian axes.
figure
quiver(y, x, v, u,'.');% quiverm(x, y, u, v,'.');
  1 Comment
Gaziza Konyssova
Gaziza Konyssova on 23 Jan 2022
Thanks so much Kevin! Yes, I had the same thing.
Apparently, I should have used something other than geobasemap, which works only on geoaxes and can't work together with quiver or quiverm (which in turn work only on Cartesian or map axes respectively).
So, I found a plot_google_map file exchange, which gives pretty nice results combining plots you need and google map on the same axes. So far I tried using it only with plot and quiver commands, but I belive it goes well with other plot types too. (Read the documentation for more details.)
And, here is the code, that worked out:
u = table2array(FData(:,9))'; % u - horizontal extend (in mm/sec), column 9
v = table2array(FData(:,8))'; % v - vertical extend (in mm/sec), column 8
% Note, in the question above I used deltalat and deltalon (columns 7 and 6)
lt = table2array(FData(:,3))';
ln = table2array(FData(:,4))';
lonRange=max(ln)-min(ln); latRange=max(lt)-min(lt);
xmin=min(ln)-lonRange*.1; xmax=max(ln)+lonRange*.1;
ymin=min(lt)-latRange*.2; ymax=max(lt)+latRange*.2;
% set the scale parameters
scalex=(xmax-xmin)/10; scaley=(ymax-ymin)/10;
scale=min(scalex,scaley);
plot(ln,lt,'-b', 'MarkerSize', 5); hold on % plotting the base line (optional)
quiver(ln, lt,0.1*scale*u,0.1*scale*v,0,'b');
% set axis you need
axis([xmin-0.0005 xmax-0.0005 ymin-0.0005 ymax+0.0005]);
plot_google_map()

Sign in to comment.

More Answers (0)

Categories

Find more on Geographic Plots in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!