Main Content

usgs24kdem

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

usgs24kdem has been removed. Use readgeoraster instead. For more information, see Compatibility Considerations.

Description

[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.

example

[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.

Examples

collapse all

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

Unzip a USGS 24K DEM file.

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.

delete(demFilename)

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.

figure
usamap(latlim,lonlim)
geoshow(lat,lon,Z,'DisplayType','surface')
demcmap(Z)
daspectm('m',1)

Map of DEM values

Input Arguments

collapse all

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

Data Types: char | string

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, specified 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.

Tips

  • 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.

  • 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. The DEM files are ASCII files, and can be transferred as text. Line-ending conversion is not necessarily required.

Version History

Introduced before R2006a

expand all

R2023b: Removed

The usgs24kdem function, which returns latitude-longitude grids, has been removed. Instead, use the readgeoraster function, which returns a map raster reference object. Reference objects have several advantages over latitude-longitude grids.

  • Unlike latitude-longitude grids, reference objects have properties that document the size of the associated raster, its limits, and the direction of its rows and columns. For more information about reference object properties, see MapCellsReference and MapPostingsReference.

  • You can manipulate the limits of rasters associated with reference objects using the mapcrop function.

  • You can manipulate the size and resolution of rasters associated with reference objects using the mapresize function.

Get metadata about files using the georasterinfo function.

This table shows some typical usages of usgs24kdem and how to update your code to use readgeoraster.

RemovedRecommended
[latgrat,longrat,z] = usgs24kdem(filename);
[Z,R] = readgeoraster(filename);
[latgrat,longrat,z] = usgs24kdem(filename,samplefactor);
[Z,R] = readgeoraster(filename);
[Z,R] = georesize(Z,R,1/samplefactor);
[latgrat,longrat,z] = usgs24kdem(filename,samplefactor,latlim,lonlim);
[Z,R] = readgeoraster(filename);
[Z,R] = geocrop(Z,R,latlim,lonlim);
[Z,R] = georesize(Z,R,1/samplefactor);
[latgrat,longrat,z,header,profile] = usgs24kdem(filename);
[Z,R] = readgeoraster(filename);
info = georasterinfo(filename);

The readgeoraster function returns data using the native data type embedded in the file. Return a different data type by specifying the 'OutputType' name-value pair. For example, use [Z,R] = readgeoraster(filename,'OutputType','double').

The readgeoraster function does not automatically replace missing data with NaN values. If your data set uses large negative numbers to indicate missing data, replace them with NaN values using the standardizeMissing function.

[Z,R] = readgeoraster('MtWashington-ft.grd');
info = georasterinfo('MtWashington-ft.grd');
m = info.MissingDataIndicator;
Z = standardizeMissing(Z,m);