Strange values of map axes limits (axesm).

조회 수: 2(최근 30일)
Peter Valent
Peter Valent 2021년 12월 15일
답변: Jan Studnicka 2021년 12월 16일
I am building an app that will display various geographic data - vector (points, lines, polygons) and raster. Because of this I would like to plot the data on map axes which can be created using the axesm function. Let's say that all the data I would like to plot will have geographic coordinates (lat,lon). I have problems with understanding the limits (both horizontal and vertical) of the axes. What do the numbers mean?
Les't have a look at this simple example which plots a polyline in geographic coordinates on map axes.
s = geoshape([42 45],[10 15]);
a = axesm('mercator');
geoshow(a,s)
It produces a very simple plot, where the limits of the horizontal axis should be for sure somewhere between 40 and 50. However, when I try to get the limits of the horizontal axis I get strange values that are nowhere what I would expect (see the code below).
a.XLim % this gives me [0.16,0.28]
getm(a,'FLatLimits') % this gives me [-86,86]
I need to know the limits of both the horizontal and the vertical axes in correct geographic coordinates due to resizing function in the app.
SIMPLE EXAMPLE:

답변(1개)

Jan Studnicka
Jan Studnicka 2021년 12월 16일
Hello,
The default setting for map axes is that the map frame is not visible. You need to toggle the visibility of the map frame by calling:
framem on
s = geoshape([42 45],[10 15]);
figure
a = axesm('mercator');
geoshow(a,s)
framem on
figure
s = geoshape([42 45],[10 15]);
a2 = axesm('mercator','MapLatLimit',[30 60],'MapLonLimit',[0 30]);
geoshow(a2,s)
framem on
mlabel on
plabel on
tightmap
gridm

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by