readUSGS_DEM
Overview
readUSGS_DEM reads a US Geological Survey (USGS) Digital Elevation Model (DEM)βeither in classic ASCII format (1024-byte fixed records or linefeed-delimited) or as an uncompressed Spatial Data Transfer Standard (SDTS / ISO-8211) .tar archiveβand writes a 16-bit signed integer binary raster (<outbsq>), an optional formatted header summary ([outhdr]), and an OMG 3-column ASCII point file named thedata containing all positive land elevations converted to negative-down meters (pos1 pos2 -elevation_m) ready for gridding with weigh_grid.
Syntax & CLI Options
readUSGS_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. |
[outhdr] | Optional output text file for the formatted Type A / Type C DEM metadata report (defaults to stdout). |
[nodataval] | Optional integer value for nodata cells in <outbsq> (default: -32767). |
How It Works
- Format Detection & Parsing:
- Inspects
<indem>to determine whether it is an uncompressed SDTS.tararchive (containingCATD.DDF,LDEF.DDF,RSDF.DDF,DDSH.DDF,CELL.DDF, etc.) or a traditional USGS ASCII DEM (Type A header record, Type B elevation profiles, and optional Type C accuracy record). - Assembles the full 2D elevation array (
short *data) oriented north-to-south, west-to-east, filling missing profile pads withnodata(default-32767).
- Inspects
- Binary & Header Output:
- Writes the 16-bit binary raster to
<outbsq>and formats the quadrangle corners, UTM zone, ground planimetric/elevation units, and resolution into[outhdr].
- Writes the 16-bit binary raster to
- OMG
thedataPoint Extraction:- Opens
thedatain the current working directory and iterates over every grid cell(r, c). - Converts raw elevation values to meters (
* 0.3048ifhdr.euni == 1[feet]). - Converts coordinates (
pos1,pos2) to kilometers (* 0.001) ifhdr.puni == 2(meters in UTM) or decimal degrees (/ 3600.0) ifhdr.puni == 3(arc-seconds in geographic). - Writes all non-zero, positive land elevations as
pos1 pos2 -elev_m(following the OMG positive-down depth convention) tothedata.
- Opens
Examples
Extract a 7.5-minute USGS DEM into a binary raster and thedata XYZ points
readUSGS_DEM portland_oe_e.dem portland.bsq portland.hdr
Workflow Context
- Sibling Tool:
read_dem(identical converter without writing thethedataASCII XYZ file). - Downstream:
weigh_grid(grids the generatedthedatapoint file onto an.r4mapsheet).