Strange values of map axes limits (axesm).
3 views (last 30 days)
Show older comments
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/835505/image.png)
0 Comments
Answers (1)
Jan Studnicka
on 16 Dec 2021
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
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!