# Displaying Topographic Data

This example shows several ways to represent the Earth's topography. The data used in this example are available from the National Geophysical Data Center, NOAA US Department of Commerce under data announcement 88-MGG-02.

The data file, `topo.mat`, contains topographic data. `topo` is the altitude data and `topomap1` is a colormap for the altitude.

```load topo topo topomap1 % load data whos('topo','topomap1')```
``` Name Size Bytes Class Attributes topo 180x360 518400 double topomap1 64x3 1536 double ```

### Create Contour Plot

One way to visualize topographic data is to create a contour plot. To show the outline of the Earth's continents, plot points that have zero altitude. The first three input arguments to `contour` specify the X, Y, and Z values on the contour plot. The fourth argument specifies the contour levels to plot.

```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``` ### View Data as Image

You can create an image of the topography using the elevation data and a custom colormap. The topography data is treated as an index into the custom colormap. Set the `CDataMapping` of the image to `'scaled'` to linearly scale the data values to the range of the colormap. In this colormap, the shades of green show the altitude data, and the shades of blue represent depth below sea level.

```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``` ### Use Texture Mapping

Texture mapping maps a 2-D image onto a 3-D surface. To map the topography to a spherical surface, set the color of the surface, specified by the `CData` property, to the topographic data and set the `FaceColor` property to `'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```
{"ft_lang_label":"__label__en","ft_lang_prob":0.54656553,"math_prob":0.96776897,"size":2619,"snap":"2020-24-2020-29","text_gpt3_token_len":707,"char_repetition_ratio":0.124282986,"word_repetition_ratio":0.22510822,"special_character_ratio":0.30775106,"punctuation_ratio":0.14018692,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9668026,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-11T14:48:56Z\",\"WARC-Record-ID\":\"<urn:uuid:62835342-a0cc-4639-b3ab-d52f69d8dfd7>\",\"Content-Length\":\"72169\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0df15920-2dcc-413b-9b1d-15417bef9a30>\",\"WARC-Concurrent-To\":\"<urn:uuid:5b8da2ec-b2b5-4d38-84b1-86934a541cb5>\",\"WARC-IP-Address\":\"23.32.68.178\",\"WARC-Target-URI\":\"https://de.mathworks.com/help/matlab/visualize/displaying-topographic-data.html\",\"WARC-Payload-Digest\":\"sha1:LHB726ZIH66HBNVUOGEWMNSL5NBRGLBD\",\"WARC-Block-Digest\":\"sha1:JKFNMRXMEPGG2OFOYSN4KOQTIRWTUJ32\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655933254.67_warc_CC-MAIN-20200711130351-20200711160351-00265.warc.gz\"}"}