This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Read USGS 7.5 minute (30 meter or 10 meter) Digital Elevation Models


[lat,lon,Z] = usgs24kdem
[lat,lon,Z] = usgs24kdem(filename)
[lat,lon,Z] = usgs24kdem(filename,samplefactor)
[lat,lon,Z] = usgs24kdem(filename,samplefactor,latlim,lonlim)
[lat,lon,Z] = usgs24kdem(filename,samplefactor,latlim,lonlim,gsize)
[lat,lon,Z,header,profile] = usgs24kdem(___)


[lat,lon,Z] = usgs24kdem reads a USGS 1:24,000 digital elevation map (DEM) file in standard format. You select the file interactively. usgs24kdem reads the entire file, subsampled by a factor of 5, returning a geolocated data grid with a latitude array, lat, longitude array, lon, and an elevation array, Z. Horizontal units are in degrees, vertical units might vary. The 1:24,000 series of DEMs store data as a grid of elevations spaced either at 10 or 30 meters apart. The number of points in a file varies with the geographic location.

[lat,lon,Z] = usgs24kdem(filename) reads the USGS DEM specified by filename and returns the result as a geolocated data grid.


[lat,lon,Z] = usgs24kdem(filename,samplefactor) reads a subset of the DEM data from filename, where samplefactor is a scalar integer that specifies the sample frequency.

[lat,lon,Z] = usgs24kdem(filename,samplefactor,latlim,lonlim) reads the subset of the elevation data from filename specified by the two-element vectors latlim and lonlim. You specify the latitude and longitude limits in degrees. Elements in the vectors must be in ascending order. The data might extend outside the requested area.

[lat,lon,Z] = usgs24kdem(filename,samplefactor,latlim,lonlim,gsize) specifies the graticule size in gsize. gsize is a two-element vector specifying the number of rows and columns in the latitude and longitude coordinated grid.

[lat,lon,Z,header,profile] = usgs24kdem(___) also returns the contents of the header and raw profiles of the DEM file. The header structure contains descriptions of the data from the file header. The profile structure is the raw profile data from which the geolocated data grid is constructed.


collapse all

This example shows how to read a USGS 24K Digital Elevation Model file.

Unzip a USGS 24K DEM file. The toolbox includes a DEM file sanfranciscos.dem.gz .

filenames = gunzip('sanfranciscos.dem.gz', tempdir);
demFilename = filenames{1};

Read every other point of the 1:24,000 DEM file.

[lat,lon,Z,header,profile] = usgs24kdem(demFilename,2);

Delete the temporary gunzipped file.


As no negative elevations exist, move all points at sea level to -1 to color them blue.

Z(Z==0) = -1;

Compute the latitude and longitude limits for the DEM.

latlim = [min(lat(:)) max(lat(:))]
lonlim = [min(lon(:)) max(lon(:))]
latlim =

   37.6249   37.7504

lonlim =

 -122.5008 -122.3740

Display the DEM values.

usamap(latlim, lonlim)
geoshow(lat, lon, Z, 'DisplayType','surface')

Examine the metadata in the header.

header = 

  struct with fields:

                    Quadranglename: 'SAN FRANCISCO SOUTH, CA  BIG BASIN DEM  '
                       TextualInfo: 'WMC                             CTOG    '
                            Filler: ''
                       ProcessCode: ''
                           Filler2: ''
                SectionalIndicator: ''
                      MCoriginCode: ''
                      DEMlevelCode: 2
              ElevationPatternCode: 'regular'
    PlanimetricReferenceSystemCode: 'UTM'
                              Zone: 10
              ProjectionParameters: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
                   HorizontalUnits: 'meters'
                    ElevationUnits: 'feet'
               NsidesToBoundingBox: 4
                       BoundingBox: [1×8 double]
                  MinMaxElevations: [0 1314]
                     RotationAngle: 0
                      AccuracyCode: 'accuracy information in record C'
                    XYZresolutions: [30 30 1]
                         NrowsCols: [1 371]
                    MaxPcontourInt: NaN
                SourceMaxCintUnits: 'unknown'
                   SmallestPrimary: NaN
                SourceMinCintUnits: 'unknown'
                    DataSourceDate: NaN
                   DataInspRevDate: NaN
                       InspRevFlag: ''
                DataValidationFlag: 'unknown'
                   SuspectVoidFlag: 'unknown'
                     VerticalDatum: 'unknown'
                   HorizontalDatum: 'unknown'
                       DataEdition: NaN
                       PercentVoid: NaN

Input Arguments

collapse all

Name of file containing the digital elevation map, specified as a character array.

Data Types: char

Data sampling factor, specified as a scalar integer. For example, if samplefactor is equal to 1, usgs24kdem reads the data at its full resolution, that is, every pixel. If you specify a samplefactor value n that is greater than 1, usgs24kdem reads every nth point.

Data Types: double

Limits of the desired data, specified as a two-element vector, in degrees. The limits must be in ascending order. The data might extend outside the requested area.

Data Types: double

Limits of desired data, specifed as a two-element vector, in degrees.

Data Types: double

Graticule size, specified as a two-element vector. gsize specifies the number of rows and columns in the latitude and longitude coordinated grid. If omitted, usgs24kdem returns a graticule the same size as the geolocated data grid. To specify the coordinated grid size without specifying the geographic limits, use empty matrices for latlim and lonlim.

Data Types: double

Output Arguments

collapse all

Latitude array, returned as a matrix of class double.

Longitude array, returned as a matrix of class double.

Elevation array, returned as a matrix of class double.

Descriptions of the data from the file header, returned as a struct.

Raw profile data from which the geolocated data grid is constructed, returned as a struct.


  • The U.S. Geological Survey has created a series of digital elevation models based on their paper 1:24,000 scale maps. The grid spacing for these elevations models is either 10 meters or 30 meters on a Universal Transverse Mercator grid. Each file covers a 7.5-minute quadrangle. The map and data series are available for much of the conterminous United States, Hawaii, and Puerto Rico. The data has been released in several formats. This function reads the data in the "standard" file format.

  • This function reads USGS DEM files stored in the UTM projection. The function unprojects the grid back to latitude and longitude. Use usgsdem for data stored in geographic grids.

  • The number of points in a file varies with the geographic location. Unlike the USGS DEM products, which use an equal-angle grid, the UTM projection grid DEMs cannot simply be concatenated to cover larger areas. There can be data gaps between DEMs.

  • You can obtain the data files from the U.S. Geological Survey and from commercial vendors . Other agencies have made some local area data available online. See Finding Geospatial Data. The DEM files are ASCII files, and can be transferred as text. Line-ending conversion is not necessarily required.

Introduced before R2006a

Was this topic helpful?