Main Content

지형 데이터(Topographic Data) 표시

이 예제에서는 지구의 지형을 나타내는 여러 가지 방법을 보여줍니다. 이 예제에 사용된 데이터는 미국 상무부 NOAA의 국립 지구 물리 데이터 센터(National Geophysical Data Center)에서 발표한 데이터 공고 88-MGG-02에 나와 있습니다.

지형 데이터에 대한 정보

데이터 파일 topo.mat에는 지형 데이터가 들어 있습니다. topo는 고도(Altitude) 데이터이고 topomap1은 고도의 컬러맵입니다.

load topo topo topomap1    % load data 
whos('topo','topomap1')
  Name            Size              Bytes  Class     Attributes

  topo          180x360            518400  double              
  topomap1       64x3                1536  double              

등고선 플롯 생성

지형 데이터를 시각화하는 방법 중 하나는 등고선 플롯을 만드는 것입니다. 지구의 대륙 윤곽을 표시하려면 고도가 0인 점을 플로팅해야 합니다. contour에 대한 처음 세 개의 입력 인수는 등고선 플롯에서의 X, Y, Z 값을 지정합니다. 네 번째 인수는 플로팅할 등고선 레벨을 지정합니다.

x = 0:359;                                % longitude
y = -89:90;                               % latitude

figure
contour(x,y,topo,[0 0])

axis equal                                % set axis units to be the same size
box on                                    % display bounding box

ax = gca;                                 % get current axis               
ax.XLim = [0 360];                        % set x limits
ax.YLim = [-90 90];                       % set y limits
ax.XTick = [0 60 120 180 240 300 360];    % define x ticks
ax.YTick = [-90 -60 -30 0 30 60 90];      % define y ticks

Figure contains an axes object. The axes object contains an object of type contour.

데이터를 이미지로 보기

고도(Elevation) 데이터와 사용자 지정 컬러맵을 사용하여 지형 이미지를 생성할 수 있습니다. 지형 데이터는 사용자 지정 컬러맵에 대한 인덱스로 처리됩니다. 이미지의 CDataMapping'scaled'로 설정하면 데이터 값을 컬러맵의 범위로 선형적으로 스케일링할 수 있습니다. 이 컬러맵에서 녹색 셰이딩은 고도 데이터를 나타내고 파란색 셰이딩은 해수면 아래의 깊이를 나타냅니다.

image([0 360],[-90 90], flip(topo), 'CDataMapping', 'scaled')
colormap(topomap1)

axis equal                                % set axis units to be the same size

ax = gca;                                 % get current axis               
ax.XLim = [0 360];                        % set x limits
ax.YLim = [-90 90];                       % set y limits
ax.XTick = [0 60 120 180 240 300 360];    % define x ticks
ax.YTick = [-90 -60 -30 0 30 60 90];      % define y ticks

Figure contains an axes object. The axes object contains an object of type image.

텍스처 매핑 사용

텍스처 매핑은 2차원 이미지를 3차원 곡면 위에 매핑합니다. 지형을 구면(Spherical Surface)에 매핑하려면 CData 속성으로 지정된 곡면의 색을 지형 데이터로 설정하고 FaceColor 속성을 'texturemap'으로 설정하십시오.

clf
[x,y,z] = sphere(50);          % create a sphere 
s = surface(x,y,z);            % plot spherical surface

s.FaceColor = 'texturemap';    % use texture mapping
s.CData = topo;                % set color data to topographic data
s.EdgeColor = 'none';          % remove edges
s.FaceLighting = 'gouraud';    % preferred lighting for curved surfaces
s.SpecularStrength = 0.4;      % change the strength of the reflected light

light('Position',[-1 0 1])     % add a light

axis square off                % set axis to square and remove axis
view([-30,30])                 % set the viewing angle