Main Content

addCustomTerrain

R2026b

Add custom terrain data

Since R2022a

Description

addCustomTerrain(terrainName,files) adds terrain data specified by files for use with the trackingGlobeViewer object. You can add the terrain to the trackingGlobeViewer object through its Terrain property. Custom terrain data is available for current and future sessions of MATLAB® until you call removeCustomTerrain.

addCustomTerrain(___,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments in the previous syntax. For example, specify the location to write the terrain data by using the WriteLocation argument.

Input Arguments

collapse all

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

Data Types: char | string

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

  • To add custom terrain from one DTED file, specify files as a string scalar or a character vector.

  • To add custom terrain from multiple DTED files, specify files as a string vector or a cell array of character vectors. If you specify multiple files that do not cover a complete rectangular geographic region, you must set the FillMissing name-value argument to true.

The way you specify each file depends on the location of the file.

  • If the file is in your current folder or in a folder on the MATLAB path, then specify the name of the file, such as "myFile.dt1".

  • If the file is not in the current folder or in a folder on the MATLAB path, then specify the full or relative path name, such as "C:\myfolder\myFile.dt1" or "dataDir\myFile.dt1".

The horizontal datum code of each DTED file must be "WGS84". The vertical datum code of each DTED file must be "E96", "MSL", or "W84". You can query the datum codes of a DTED file by using the georasterinfo (Mapping Toolbox) function. This code stores the horizontal datum code in hDatum and the vertical datum code in vDatum.

info = georasterinfo("n39_w106_3arc_v2.dt1");
hDatum = info.Metadata.DTED_HorizontalDatum;
vDatum = info.Metadata.DTED_VerticalDatum;

Data Types: char | string | cell

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: addCustomTerrain(terrainName,files,Attribution="My attribution") specifies the attribution for the custom terrain.

Since R2026b

Behavior when the terrain name already exists, specified as one of these options. The function applies this behavior when terrainName matches the name of a custom terrain already in the list.

  • "overwrite" — Overwrite the existing terrain data. This option is useful when you want to change the terrain data that terrainName represents.

  • "preserve" — Preserve the existing terrain data and do not add the new terrain data. This option is useful when you want to avoid overwriting terrain that already exists.

  • "error" — Issue an error.

The addCustomTerrain function compares terrainName with the names of existing custom terrains. The comparison is case-insensitive. The function does not compare the data associated with the names.

When terrainName does not match the name of an existing custom terrain, the function adds new terrain, regardless of the value of NameExistsRule.

Attribution of custom terrain data, specified as a character vector or a string scalar. The attribution is displayed on the tracking globe viewer. By default, the value 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

Tips

  • You can find and download DTED files by using EarthExplorer, a data portal provided by the US Geological Survey (USGS). From the list of data sets, search for DTED files by selecting Digital Elevation, SRTM, and then SRTM 1 Arc-Second Global and SRTM Void Filled.

Version History

Introduced in R2022a

expand all

See Also

| (Mapping Toolbox) |