How to plot coastlines on 3D earth
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Cielo Martos
le 11 Fév 2021
Commenté : Cielo Martos
le 14 Fév 2021
I'm trying to plot coastlines on a 3D Earth I made
E=wgs84Ellipsoid
[x,y,z] = ellipsoid(0,0,0,E.SemimajorAxis,E.SemimajorAxis,E.SemiminorAxis);
s = surface(x,y,z);
[N,R] = egm96geoid;
s.FaceColor = 'texturemap';
s.CData = N;
So far this is what I have and i want to overlay coastlines from the mapping toolbox but, I don't know how to do that.
0 commentaires
Réponse acceptée
Ryan Klots
le 12 Fév 2021
Currently, you are plotting (x, y, z) data as you would on a Cartesian axes. If you want to combine this with (lat, lon) data, you need to somehow convert between the two.
For example, you could use the geodetic2ecef function from Mapping Toolbox to convert from (lat, lon) coordinates to (x, y, z) coordinates:
% Load coastline data
load coastlines
% Convert from (lat, lon) coordinates to (x, y, z) coordinates
[X, Y, Z] = geodetic2ecef(E, coastlat, coastlon, 0); % E is your reference ellipsoid
% Plot (x, y, z) coastline data on top of existing sphere
hold on
plot3(X, Y, Z, "Color", "red", "LineWidth", 5);
hold off
Alternatively, you could consider sticking with (lat, lon) data exclusively and using something like geoglobe:
% Load coastline data
load coastlines
% Initialize geoglobe
f = uifigure();
g = geoglobe(f);
% Plot coastlines on geoglobe
geoplot3(g, coastlat, coastlon, 0, "Color", "red", "LineWidth", 5);
In either case, it's critical to pay attention to the coordinate system that you are working in.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Mapping Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!