フィルターのクリア

Using scatterm to plot points on Globe Projection of world map (spherical)

5 ビュー (過去 30 日間)
Amir
Amir 2017 年 2 月 27 日
コメント済み: Amir 2017 年 3 月 6 日
Hi all,
I am trying to plot points on the map using the Mapping toolbox. I am using the "Globe Projection", which gives me a 3D spherical map, however the "scatterm" function does not work. I have tried this on other map projections and it works fine.
A sample code for the 2-D case (which works) is below:
lat = rand(1,100)*100;
lon = rand(1,100)*100;
temp = rand(1,100)*20;
load coastlines;
worldmap world
plot3m(coastlat,coastlon,.01,'k','LineWidth', 1.5)
gridm('GLineStyle','-','Gcolor',[.7 .7 .7],'Galtitude',.02)
hold on
scatterm(lat, lon,10, temp, 'filled');
colorbar
Now if i try to do the same using the globe projection, i get the error " Not enough input arguments"
lat = rand(1,100)*100;
lon = rand(1,100)*100;
temp = rand(1,100)*20;
load coastlines;
ax = axesm('globe');
gridm('GLineStyle','-','Gcolor',[.7 .7 .7],'Galtitude',.02)
plot3m(coastlat,coastlon,.01,'k','LineWidth', 1.5)
hold on
scatterm(lat, lon,10, temp, 'filled');
colorbar
the "plotm" function seems to work on the globe projection, but i cannot specify the color for each point based on the value of "temp", the same way as scatterm.
Any thoughts on this?

採用された回答

Chad Greene
Chad Greene 2017 年 3 月 1 日
You pose the question well. I was able to replicate the problem. Here's a fix:
mstruct = gcm;
[x,y,z] = mfwdtran(mstruct,lat,lon,zeros(size(lat)));
scatter3(x,y,z,20,temp,'filled')
  3 件のコメント
Chad Greene
Chad Greene 2017 年 3 月 2 日
編集済み: Chad Greene 2017 年 3 月 2 日
Excellent, I'm glad it helped. I occasionally run into issues with Mapping Toolbox plotting functions, but often the problem can be circumvented by performing the coordinate transformation myself with mfwdtran, then plot using standard plotting functions.
Amir
Amir 2017 年 3 月 6 日
I actually received an email from Matlab Support, there developers have been notified of this limitation and are working on it. They have proposed the following alternative solution, which works fine, but is very slow for high number of points.
lat = rand(1,100)*100;
lon = rand(1,100)*100;
temp = rand(1,100)*20;
p = geopoint(lat,lon,'Temp',temp);
load coastlines;
ax = axesm('globe');
gridm('GLineStyle','-','Gcolor',[.7 .7 .7],'Galtitude',.02)
plot3m(coastlat,coastlon,.01,'k','LineWidth', 1.5)
hold on
colorbar
colorRange = makesymbolspec('Point',...
{'Temp',[0 20],'MarkerFaceColor',parula(21),'Marker','o','MarkerEdgeColor','none'});
geoshow(p,'SymbolSpec',colorRange);
is still prefer your solution though, it is very fast. thanks again

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by