Main Content


Add custom terrain data



addCustomTerrain(terrainName,files) adds terrain data specified by files for use with geographic plotting functions such as geoglobe. The terrain is named terrainName, and you can specify it by this name when calling a plotting function. Custom terrain data is available for current and future sessions of MATLAB®, until you call removeCustomTerrain.

addCustomTerrain(___,Name,Value) adds custom terrain data with additional options specified by one or more name-value pairs.


collapse all

Display a line from the surface of Gross Reservoir to a point above South Boulder Peak using custom terrain.

First, add terrain for an area around South Boulder Peak by calling addCustomTerrain and specifying a DTED file. Name the terrain 'southboulderpeak'.


Create a geographic globe. Specify the terrain by name, using the 'Terrain' argument of the geoglobe function. Preserve the terrain after plotting by calling the hold function. Then, plot the line. Tilt the view by holding Ctrl and dragging.

uif = uifigure;
g = geoglobe(uif,'Terrain','southboulderpeak');

lat = [39.95384 39.95];
lon = [-105.29916 -105.3608];
hTerrain = [10 0];
geoplot3(g,lat,lon,hTerrain,'y','HeightReference','Terrain', ...

A 3-D line plotted from the surface of a reservoir to a point above a peak.

Close the geographic globe and remove the custom terrain.


The DTED data used in this example is courtesy of the US Geological Survey.

Input Arguments

collapse all

User-defined identifier for terrain data, specified as a string scalar or a character vector.

Data Types: char | string

List of DTED files, specified as a string scalar, a character vector or a cell array of character vectors.


If you specify multiple files, they must combine to define a complete rectangular geographic region. If not, you must set the name-value pair 'FillMissing' to 'true'.

Data Types: char | string

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'FillMissing',true

Attribution of custom terrain data, specified as a character vector or a string scalar. Attributions display on geographic plots that use the custom terrain. By default, the attribution is empty.

Data Types: char | string

Fill data of missing files with value 0, specified as true or false. Missing file values are required to complete a rectangular geographic region with the input files.

Data Types: logical

Name of folder to write extracted terrain files to, specified as a character vector or a string scalar. The folder must exist and have write permissions. By default, addCustomTerrain writes extracted terrain files to a temporary folder that it generates using the tempname function.

Data Types: char | string


To deploy an application with custom terrain using MATLAB Compiler™, call addCustomTerrain in the application and include the DTED files in the deployed application package.

Introduced in R2020a