在设置地图限制时如何在Matlab中正确绘制数据线

问题描述 投票:0回答:1

我有一些数据(纬度,经度)数据(很抱歉,较长的数据,我似乎无法用其他人工数据来复制问题):

data1lat = [40.47 40.4697 40.4692 40.4686 40.4682 40.4681 40.4679 40.4673 40.4667 40.4663 40.4662 40.4662 40.4651 40.4628 40.4603 40.4584 40.4579 40.4567 40.4542 40.4514 40.4494 40.4488 40.4488 40.4474 40.4451 40.4432 40.4424 40.4422 40.4421 40.4424 40.4432 40.4436 40.4437 40.4437 40.4423 40.4318 40.4143 40.4009 40.3974 40.3887 40.3724 40.3591 40.3573 40.3586 40.3586 40.3592 40.3606 40.3626 40.3642 40.3646 40.3658 40.3682 40.3711 40.3734 40.374 40.374 40.403 40.4692 40.5426 40.5987 40.614 40.6494 40.7179 40.7959 40.845 40.8539 40.8539 40.8667 40.8798 40.8924 40.9017 40.9042 40.9107 40.9236 40.9411 40.9684 40.9803 40.9803 41.0379 41.141 41.2482 41.3271 41.3467 41.3965 41.4967 41.6082 41.6871 41.7076 41.7076 41.7288 41.772 41.8213 41.8574 41.8669 41.8903 41.9372 41.9901 42.0286 42.0387 42.0634 42.1129 42.1685 42.2087 42.2192 42.2192 42.297 42.4439 42.6065 42.7258 42.7556 42.8304 42.9787 43.1451 43.2622 43.2917 43.2917 43.6271 44.3092 45.0827 45.6413 45.7867 46.1424 46.8452 47.619 48.1667 48.3081 48.6529 49.3285 50.0663 50.5872 50.7215 50.7215 50.746 50.7914 50.8382 50.8706 50.8791 50.8993 50.9384 50.9816 51.0118 51.0194 51.0194 51.0824 51.1984 51.327 51.4164 51.4348 51.4931 51.5993 51.7135 51.7926 51.8088 51.8614 51.9583 52.0663 52.1414 52.1565 52.1565 52.1585 52.1624 52.1666 52.1697 52.1704 52.1723 52.176 52.18 52.1829 52.1836 52.1836 52.1943 52.2151 52.238 52.254 52.2582 52.2686 52.2892 52.3101 52.3227 52.3254 52.3254 52.327 52.3301 52.3337 52.3364 52.337 52.3387 52.3422 52.346 52.3488 52.3496 52.3514 52.355 52.3591 52.362 52.3628 52.3628 52.3641 52.3666 52.3693 52.3712 52.3717 52.3729 52.3752 52.3777 52.3795 52.38 ];
data1lon = [-3.56 -3.55975 -3.55926 -3.55871 -3.55831 -3.5582 -3.55795 -3.55744 -3.55688 -3.55647 -3.55636 -3.55636 -3.5553 -3.55316 -3.55072 -3.54893 -3.54846 -3.54729 -3.54494 -3.54227 -3.54032 -3.5398 -3.5398 -3.5383 -3.53469 -3.52985 -3.52599 -3.52495 -3.52237 -3.51716 -3.51133 -3.50704 -3.5059 -3.5059 -3.49303 -3.4691 -3.4455 -3.42924 -3.42513 -3.41461 -3.39231 -3.36246 -3.33767 -3.33126 -3.33126 -3.32913 -3.32504 -3.32076 -3.31788 -3.31717 -3.31546 -3.3123 -3.30913 -3.30706 -3.30655 -3.30655 -3.29261 -3.28538 -3.28419 -3.28449 -3.28433 -3.28432 -3.28351 -3.27667 -3.25625 -3.24639 -3.24639 -3.21722 -3.14381 -3.05229 -2.98004 -2.96079 -2.91217 -2.8119 -2.69525 -2.61655 -2.59917 -2.59917 -2.53326 -2.41521 -2.29221 -2.20155 -2.17898 -2.12174 -2.00631 -1.87763 -1.78647 -1.76274 -1.76274 -1.73877 -1.69135 -1.63792 -1.59891 -1.58867 -1.56342 -1.51269 -1.45533 -1.41357 -1.40263 -1.3757 -1.32179 -1.26116 -1.21719 -1.2057 -1.2057 -1.12035 -0.958374 -0.777941 -0.644867 -0.611425 -0.52747 -0.360201 -0.171298 -0.037439 -0.00360537 -0.00360537 0.384042 1.19078 2.13726 2.84325 3.03023 3.49348 4.43435 5.51183 6.30323 6.51151 7.02682 8.0678 9.25572 10.1292 10.3594 10.3594 10.4016 10.4801 10.5611 10.6175 10.6322 10.6675 10.7357 10.8114 10.8649 10.8785 10.8785 10.9925 11.2028 11.4363 11.5992 11.6326 11.7391 11.9333 12.1426 12.2878 12.3177 12.4144 12.5929 12.7924 12.9315 12.9594 12.9594 12.9631 12.9705 12.9785 12.9842 12.9857 12.9893 12.9963 13.004 13.0094 13.0108 13.0108 13.0313 13.0711 13.115 13.1457 13.1538 13.1738 13.2138 13.2535 13.2799 13.2872 13.2872 13.2938 13.3073 13.3226 13.3338 13.3368 13.344 13.3586 13.3751 13.387 13.3902 13.3979 13.4134 13.4307 13.4433 13.4466 13.4466 13.4521 13.4628 13.4744 13.4825 13.4845 13.4896 13.4995 13.5103 13.518 13.52 ];

data2lat = [40.47 40.4697 40.4692 40.4687 40.4683 40.4682 40.4679 40.4674 40.4668 40.4664 40.4663 40.4663 40.4633 40.4572 40.4499 40.4445 40.4431 40.4396 40.4327 40.425 40.4194 40.418 40.418 40.4137 40.4097 40.4139 40.421 40.4233 40.4289 40.4392 40.4441 40.4436 40.4437 40.4437 40.4507 40.475 40.4768 40.4546 40.4493 40.4361 40.4078 40.377 40.3606 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3586 40.3712 40.4356 40.5156 40.5756 40.5919 40.6302 40.7038 40.7892 40.844 40.8539 40.8539 40.8672 40.8808 40.8935 40.9028 40.9054 40.9118 40.925 40.9426 40.9689 40.9803 40.9803 41.0328 41.1273 41.2256 41.2976 41.3156 41.3611 41.4527 41.5542 41.6262 41.6448 41.6448 41.6649 41.7061 41.7534 41.788 41.7971 41.8196 41.8646 41.9154 41.9523 41.962 41.9858 42.0333 42.0868 42.1254 42.1355 42.1355 42.2113 42.3543 42.5128 42.6292 42.6584 42.7315 42.8768 43.04 43.1551 43.1841 43.1841 43.4942 44.1285 44.8548 45.3845 45.523 45.8634 46.5416 47.2971 47.838 47.9785 48.3228 49.0043 49.76 50.3013 50.442 50.442 50.4702 50.5225 50.5764 50.6139 50.6237 50.6471 50.6924 50.7424 50.7776 50.7865 50.7865 50.8596 50.9941 51.1431 51.2467 51.2679 51.3356 51.4587 51.5912 51.6829 51.7018 51.7627 51.8751 52.0004 52.0876 52.1051 52.1051 52.1074 52.112 52.1169 52.1204 52.1213 52.1235 52.1279 52.1326 52.1359 52.1368 52.1368 52.15 52.1756 52.2036 52.2231 52.2281 52.2404 52.2649 52.2897 52.3045 52.3076 52.3076 52.31 52.3146 52.3196 52.3233 52.3242 52.3265 52.3311 52.3362 52.3398 52.3407 52.343 52.3476 52.3527 52.3563 52.3572 52.3572 52.3588 52.3621 52.3656 52.3681 52.3687 52.3703 52.3735 52.3769 52.3794 52.38 ];
data2lon = [-3.56 -3.55976 -3.55927 -3.55873 -3.55834 -3.55824 -3.55799 -3.5575 -3.55694 -3.55654 -3.55644 -3.55644 -3.55362 -3.54776 -3.54081 -3.53564 -3.53429 -3.53097 -3.52438 -3.51703 -3.51173 -3.51035 -3.51035 -3.50552 -3.49249 -3.47719 -3.47056 -3.46973 -3.46941 -3.47565 -3.4902 -3.50262 -3.5059 -3.5059 -3.52045 -3.51815 -3.48237 -3.45914 -3.45386 -3.4372 -3.4066 -3.37169 -3.34106 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.33126 -3.29273 -3.26425 -3.27133 -3.26808 -3.27221 -3.2738 -3.2767 -3.27487 -3.25659 -3.24639 -3.24639 -3.21732 -3.1437 -3.05221 -2.98009 -2.96091 -2.91245 -2.81257 -2.69637 -2.61708 -2.59917 -2.59917 -2.53537 -2.42036 -2.30041 -2.21227 -2.19024 -2.13435 -2.02174 -1.89658 -1.8076 -1.7845 -1.7845 -1.75983 -1.71108 -1.65647 -1.61647 -1.60605 -1.58022 -1.52835 -1.46972 -1.42702 -1.41584 -1.38832 -1.33322 -1.27125 -1.22632 -1.21457 -1.21457 -1.12638 -0.959245 -0.773123 -0.635784 -0.601312 -0.514657 -0.34197 -0.146967 -0.00875848 0.0261648 0.0261648 0.401416 1.18159 2.0965 2.779 2.95976 3.40765 4.3175 5.35962 6.12514 6.3267 6.82561 7.83448 8.98784 9.83771 10.0619 10.0619 10.1071 10.191 10.2775 10.338 10.3537 10.3915 10.4646 10.5456 10.6027 10.617 10.617 10.736 10.9559 11.2009 11.3724 11.4076 11.5201 11.7257 11.9483 12.1033 12.1352 12.2387 12.4301 12.6448 12.795 12.8251 12.8251 12.8291 12.8369 12.8455 12.8516 12.8531 12.857 12.8644 12.8726 12.8784 12.8799 12.8799 12.9028 12.947 12.9957 13.0294 13.0381 13.0593 13.1022 13.1451 13.175 13.1838 13.1838 13.1945 13.2158 13.2394 13.2563 13.2607 13.2714 13.2926 13.3162 13.333 13.3374 13.3481 13.3693 13.3928 13.4096 13.414 13.414 13.4216 13.4365 13.4529 13.4646 13.4676 13.475 13.4896 13.5056 13.517 13.52 ];

data3lat = [40.4445 40.4068 40.3821 40.4999 40.6366 40.7646 40.864 40.8981 40.9192 40.9475 41.0238 41.1424 41.2621 41.3843 41.5114 41.6413 41.7708 41.9047 42.038 42.1733 42.3049 42.3726 42.4996 43.1581 44.0556 44.9538 45.8378 46.7104 47.5636 48.4018 49.2305 50.0365 50.8447 50.9526 51.0409 51.189 51.3055 51.4236 51.536 51.6463 51.7478 51.8506 51.9502 52.0401 52.1571 52.2184 52.2793 52.3245 52.3535];
data3lon = [-3.54407 -3.4369 -3.3272 -3.29316 -3.27929 -3.26542 -3.20742 -3.05612 -2.88716 -2.71947 -2.55178 -2.42317 -2.28952 -2.15083 -2.01718 -1.87218 -1.72844 -1.5784 -1.42836 -1.27706 -1.12449 -1.06019 -0.949237 -0.183648 0.859328 1.94669 3.05901 4.21294 5.38906 6.60956 7.86705 9.15875 10.5195 10.701 10.852 11.1148 11.339 11.5447 11.7495 11.9409 12.1323 12.321 12.504 12.6843 12.8886 13.0071 13.1282 13.2467 13.376];

我想在Matlab中绘制地图。数据包含在以下范围内:

latlim = [40, 50];
lonlim = [-5, 15];

首先,我使用以下方法构造轴:

figure
mapax = axesm('mercator', 'Frame', 'on', 'MapLatLimit', latlim, 'MapLonLimit', lonlim); % Limit the map 
framem
gridm
mlabel 
plabel

然后,我绘制了一些地理特征,例如土地块,河流等:

geoshow(mapax, 'landareas.shp')
setm(gca,'ffacecolor', rgb('ocean blue'))
geoshow(mapax, 'worldlakes.shp', 'FaceColor', 'cyan')
geoshow(mapax, 'worldrivers.shp', 'Color', 'blue')
geoshow(mapax, 'worldcities.shp', 'Marker', 'o', 'MarkerEdgeColor', 'magenta', 'MarkerFaceColor', 'white')

我打开网格:

grid on
grid minor

并且我绘制了数据:

h1 = plotm(data1lat, data1long, 'LineWidth', 2.5, 'Color', [ 0.16,     0.44,    1.00 ]);
h2 = plotm(data2lat, data2long, 'LineWidth', 2.5, 'Color', [ 0.93,     0.00,    0.00 ]); 
h3 = plotm(data3lat, data3long, 'LineWidth', 2.5, 'Color', [ 0.00,     0.57,    0.00 ]);

最后,我使用MLineLocation, MLabelLocation, PLineLocation, PLabelLocation将刻度设置为所需的5度间隔:

setm(gca, 'MLineLocation', 5, 'PLineLocation', 5)
setm(gca,'MLabelLocation',5, 'PLabelLocation', 5)
legend([h1, h2, h3], {'Original', 'Replicate', 'Adapted'})
tightmap
f = gcf;

正如您从数据中看到的,所有数据集的起点和终点应该(大致)相同。但是,在我的情节中,这些线有很大的不同:Plot with (incorrectly) diverging lines, but with the correct map layout.

即使它们应在同一点开始,也不会在应有的同一点结束。

奇怪的是,我无法使用具有相同起点和终点的其他人工数据来复制该问题。此外,在构造Map轴时未设置'MapLatLimit', latlim, 'MapLonLimit', lonlim时,该问题消失了。但是,然后我没有得到所需的地图布局:

Plot with the correct line representation, but with the incorrect map layout.

任何解决方法都可以使用纬度和经度标签以及5度间隔的网格正确地绘制数据,这对我很有帮助。

此外,问题不在于我的Matlab安装已损坏,因为我正在Matlab在线中进行此操作。

谢谢。

matlab plot map-projections
1个回答
1
投票

我找到了这个问题的答案。基于this post,我尝试使用geoshow()函数而不是plotm函数绘制线条。也就是说,我更改了:

© www.soinside.com 2019 - 2024. All rights reserved.