read_dem
Overview
read_dem converts a US Geological Survey (USGS) Digital Elevation Model (DEM)βstored either in classic ASCII Type A/B/C record format or as an uncompressed Spatial Data Transfer Standard (SDTS / ISO-8211) .tar archiveβinto a 16-bit signed integer binary band-sequential raster (<outbsq>) and a human-readable metadata report ([outhdr]).
Syntax & CLI Options
read_dem <indem> <outbsq> [outhdr] [nodataval]
| Argument | Description |
|---|---|
<indem> | Input USGS ASCII DEM file or uncompressed SDTS .tar archive. |
<outbsq> | Output 16-bit binary band-sequential raster file (nrows * ncols * 2 bytes). |
[outhdr] | Optional output text file for the formatted DEM header report (defaults to stdout). |
[nodataval] | Optional integer value assigned to nodata cells outside the quadrangle polygon (default: -32767). |
How It Works
- Auto-Detection (ASCII DEM vs. SDTS
.tar):- Checks whether
<indem>is a POSIX tar archive containing ISO-8211.DDFmodules (CATD.DDF,IREF.DDF,XREF.DDF,SPDM.DDF,LDEF.DDF,RSDF.DDF,DDSH.DDF,CELL.DDF) or a fixed/variable-record ASCII DEM.
- Checks whether
- Profile & Cell Assembly:
- For ASCII DEMs, reads the Type A header, determines the bounding northing/easting limits across the 4 quadrangle corners, allocates a rectangular
nrows x ncols16-bit grid initialized tonodataval, and populates each south-to-north Type B elevation profile into the north-up raster. - For SDTS
.tararchives, extracts the binary cell module (CELL.DDF) and maps void/fill values (-32766,-32767,32767) tonodataval.
- For ASCII DEMs, reads the Type A header, determines the bounding northing/easting limits across the 4 quadrangle corners, allocates a rectangular
- Output:
- Writes the binary 16-bit array to
<outbsq>and prints the full quadrangle metadata summary (origin, corner coordinates, projection/UTM zone, units, min/max elevation, and RMSE statistics) to[outhdr]orstdout.
- Writes the binary 16-bit array to
Examples
Convert an SDTS .tar DEM archive to a 16-bit binary raster and header file
read_dem 1601234.dem.sdts.tar quad.bsq quad.hdr -9999
Workflow Context
- Sibling Tool:
readUSGS_DEM(extendsread_demto also dump positive elevations aspos1 pos2 -zintothedata). - Related Tools:
USGS_30sec_to_JHC.