필터 지우기
필터 지우기

How to plot coastlines on 3D earth

조회 수: 40 (최근 30일)
Cielo Martos
Cielo Martos 2021년 2월 11일
댓글: Cielo Martos 2021년 2월 14일
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.

채택된 답변

Ryan Klots
Ryan Klots 2021년 2월 12일
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
Cielo Martos
Cielo Martos 2021년 2월 13일
Thank you so much! the first set of code did the trick! However, the onl problem is that the coast lines don't line up with the actual coasts. As you can see the Australia coastline is over South America.
Cielo Martos
Cielo Martos 2021년 2월 14일
Nevermind I see the problem now!
plot3(-X, -Y, Z, "Color", "red", "LineWidth", 5);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by