Why is the mapping toolbox not drawing this line?

2 ビュー (過去 30 日間)
Justace Clutter
Justace Clutter 2013 年 7 月 11 日
I have drawn two lines in the mapping toolbox, the problem is that one of the lines is not visible... Is this a bug?
-----BEGIN CODE SNIP-----
latlim = [32 33];
lonlim = [-118 -117];
map = usamap(latlim, lonlim);
setm(map, 'MapProjection', 'Mercator');
setm(map, 'Grid', 'off');
setm(map, 'FLineWidth', 5);
plotm(([1 1]*mean(latlim))+0.2, lonlim, '-r', 'LineWidth', 5);
plotm(([1 1]*mean(latlim))-0.2, lonlim + [0.000001 0], '-b', 'LineWidth', 5);
% Just to show where the red line was supposed to be
plotm(([1 1]*mean(latlim))+0.2, lonlim + [0.000001 0], ':r', 'LineWidth', 1);
-----END CODE SNIP-----
There should be a thick red line where the thin dashed on is. The blue line draws because I do not plot at the map limits exactly...
An image of the problem is at: <http://s24.postimg.org/il153bbdh/Map_Error2.png>
  1 件のコメント
Rob Comer
Rob Comer 2013 年 7 月 16 日
Try this instead of the first plotm call:
geoshow(([1 1]*mean(latlim))+0.2, lonlim,'Color','r','LineWidth',5)
It appears that roundoff is causing one of the end points to be removed during the steps that plotm takes to trim the line to fit the map frame. The geoshow function takes a more robust approach to this problem. However, geoshow doesn't decode linespecs ('-r', for example), so the 'Color' property should be set explicitly. (Likewise, the LineStyle property could be set also, but there's no need for that because '-' is the default.)

サインインしてコメントする。

採用された回答

Rob Comer
Rob Comer 2013 年 7 月 17 日
As indicated in my earlier comment, the answer is to use the geoshow function. Its method for clipping lines is far more sophisticated than the one used by the older plotm function.
If you use geoshow, you should get the behavior you are looking for. Even if you move both end points outside the map limits, for example, the part of the connecting segment that falls within the map will be shown.
  1 件のコメント
Justace Clutter
Justace Clutter 2013 年 7 月 17 日
編集済み: Justace Clutter 2013 年 7 月 17 日
Ohh, I see, I just mis-understood how geoshow works. I will look into this as an option. I thought that you had indicated that geoshow somehow does not support different line styles. But now I see that I was wrong in that understanding. Thanks for the feedback.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by