How to create a spherical graph with points that are latitude and longitude?
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Sarah Weatherly
il 26 Lug 2017
Commentato: Hari Hablani
il 13 Ago 2024 alle 19:24
I have a list of locations given in lat and long. How can I graph them in a sphere so that it looks like a globe?
0 Commenti
Risposta accettata
Santa Raghavan
il 26 Lug 2017
MathWorks provides a Mapping Toolbox to analyze and visualize geographic information.
1 Commento
Hari Hablani
il 13 Ago 2024 alle 19:24
But my latitude-longitude pairs are not on the Earth. Instead, they are in the inertial space. So, how do I draw the lat-lon plot on an inertial sphere without referring to the Earth?
Più risposte (1)
Chad Greene
il 2 Ago 2017
If you don't have the Mapping Toolbox, you can always use the standard Matlab function sph2cart to represent the Earth as a sphere of radius 6371 km like this:
lat = 180*rand(500,1)-90;
lon = 360*rand(500,1);
T = 15+10*cosd(lat);
[x,y,z] = sph2cart(deg2rad(lon),deg2rad(lat),6371);
scatter3(x,y,z,40,T,'filled');
axis tight equal
cmocean thermal
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177654/image.png)
Above I used the cmocean thermal colormap, but you can skip that line if you prefer. To put those data points in context, I'll use border data from my borders function, convert the borders to cartesian coordinates the same way as above, and plot with the scattered points:
hold on
C = load('borderdata.mat');
for k = 1:246
[xtmp,ytmp,ztmp] = sph2cart(deg2rad(C.lon{k}),deg2rad(C.lat{k}),6371);
plot3(xtmp,ytmp,ztmp,'k')
end
axis off
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177655/image.png)
1 Commento
Chad Greene
il 2 Ago 2017
I answered a similar question here, where I also made the globe opaque and included lines of latitude and longitude.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!