フィルターのクリア

cannot get a rectangle with linem

4 ビュー (過去 30 日間)
Bayes
Bayes 2015 年 11 月 22 日
回答済み: Chad Greene 2015 年 11 月 22 日
I am trying the draw a rectangle on the world map. The our vertices in (latitude, longitude) are [-60, -140] [-60, 140] [60, 140] [60, -140].
I used the following command:
linem([-60;-60], [-140;140], 'm-');
linem([-60;60], [140;140], 'm-');
linem([60;60], [-140;140], 'm-');
linem([60;-60], [-140;-140], 'm-');
It seems that I can only get two vertical lines. Does anyone have any suggestion?
Thanks!

採用された回答

Chad Greene
Chad Greene 2015 年 11 月 22 日
I get the same problem using Matlab 2012b. I've been finding a number of weird behaviors with Mapping Toolbox plotting functions lately. The first thing I always try as a workaround is to manually perform coordinate transformations, then plot using standard plotting functions. To do this,
  1. Initialize a map,
  2. Transform coordinates, then
  3. plot using standard (non-mapping toolbox) plotting functions. Here's an example:
% Using these coordinates for your bounding box:
lat = [-60 -60 60 60 -60];
lon = [-140 140 140 -140 -140];
% Initialize a map:
worldmap('world')
% Perform coordinate transformation:
[x,y] = mfwdtran(lat,lon);
% Plot using line instead of linem:
line(x,y,'color','m')
However, the bounding box does not follow the curves of the projection, so you might want to densify the lines before doing coordinate transformation:
lat = [-60 -60:60 60:-1:-60];
lon = [-140 140*ones(1,121) -140*ones(1,121)];
worldmap('world')
[x,y] = mfwdtran(lat,lon);
line(x,y,'color','m')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by