Why scaleruler and northarrow functions cannot be used in mapshow figures
13 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
I just want to simply show scalebar and northarrow on my maps using the scaleruler and northarrow functions.
I tried the official help codes of MATLAB R2022a on mapshow as follows:
figure
mapshow boston.tif
S = shaperead('boston_roads.shp');
surveyFeetPerMeter = unitsratio('sf','meter');
x = surveyFeetPerMeter * [S.X];
y = surveyFeetPerMeter * [S.Y];
mapshow(x,y)
scaleruler on
northarrow
Then, I got the following errors:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1190103/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1190108/image.png)
Could you please tell me why and how to use scaleruler and northarrow on a mapshow figure?
Thanks a lot.
0 件のコメント
回答 (1 件)
Walter Roberson
2022 年 11 月 12 日
When there is no existing axes then mapshow creates a standard numeric axes. mapshow is for displaying maps without projection, which is done on standard axes.
If, however, the existing axes is a mapping axes then mapshow can draw on it, but you need to avoid changing the map properties.
So you could axesm() mapshow() scaleruler... but you should consider using a function to display the map in a map axes instead of mapshow
7 件のコメント
Walter Roberson
2022 年 11 月 18 日
scaleruler on
scaleruler('units', 'meter');
That is creating two scale rulers, one on the first call and one on the second call. Then handlem() is retrieving both of them, and setm() is giving an error because setm() is giving an error because it expects a scalar.
Remove the first of the calls to remove the error message.
参考
カテゴリ
Help Center および File Exchange で Map Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!