User's Guide

DEM2LAS

Convert a USGS DEM file into LAS image format

Function:

DEM2LAS reads elevation data from either a traditional USGS ASCII-format DEM files (file extension ".dem") or a SDTS (Spatial Data Transfer Standard) file set packaged as a Unix tape archive (file extension ".tar"), converts them to a standard LAS image file, and extracts the header data from the input file. The header data are formatted into an ASCII listing which may be displayed, printed, and/or saved in a file.

Input data in the traditional USGS ASCII format may be in fixed-length 1024-character records (the standard for USGS 9-track tape files), or may contain records of up to 1024 characters each terminated by linefeeds (the format used by some ftp sources). When the input is in SDTS format, the separate data descriptive files (DDF) which contain the header and elevation data for the DEM must be packaged into a single ".tar" file in the format created by the Unix "tar" and GNU "gtar" utility. If the input is in Unix (.Z) or GNU (.gz) compressed format, DEM2LAS will uncompress it automatically.

Some shortcuts have been used in processing SDTS-format data. These may cause problems if the USGS uses alternative implementations of the SDTS standard. See User Note 3.

Parameters:

IN
Input DEM file. Name of file containing DEM data in either standard USGS ASCII format or in SDTS format. An ASCII format file may contain either fixed-length 1024-character records or variable-length records of up to 1024 characters each terminated by a linefeed. The input file may be in compressed form (either .Z or .gz) form, in which case it is automatically decompressed.

OUT
Name of output LAS image. The output image size is displayed to the user after the header record has been read.

FORMAT(--)
Format of input file. Normally inferred from the file extension, but may need to be specified explicitly if input does not follow standard naming conventions.


    "DEM"	Traditional USGS ASCII format (file extension ".dem")
    "SDTS"	Spatial data transfer standard (file extension ".tar"
		or ".sdts")

FILL(0)
Value for fill pixels. If the input DEM does not completely extend to the corners of the rectangular output image, the pixels for which DEM values are not available will be assigned the value specified by FILL.

VOID(0)
Value for void pixels. For the SDTS format, pixels are encoded as void if there is no value available for them even though they fall within the region nominally covered by the input DEM. For example, if the region extends across an international boundary, the points outside the U.S. may be encoded as void if DEM data are not available for them.

PRINT(TERM)
Destination(s) for text output. The program creates a listing of data from the DEM header records. This listing may be sent to one or more destinations as specifed by the value(s) entered for PRINT. Options are


    TERM:	Listing is displayed on the user's terminal.
    LP:		Listing is sent to the  printer defined by $PRINTER.
    filename:	Listing is stored in a file with the specified filename;
		the file extension ".prt" is appended to the filename
		specified by the user.

Examples:

  1. LAS> dem2las in="tyrone.dem" out=tyrone fill=100 print=term

    The DEM data for the Tyrone quadrangle in file tyrone.dem will be used to create a LAS image named tyrone. A formatted listing of the DEM header data will be displayed on the terminal. The ".dem" extension on the input file name indicates that it is in the traditional USGS ASCII DEM format.

    Since the input DEM coverage is defined by the latitude and longitude boudaries of a 7.5 minute map quadrangle, while the DEM data are on a rectangular UTM grid, the edges of the smallest rectangle in UTM coordinates which fully encloses the map quadrangle do not coincide with the edges of the quadrangle. As a result, there will be grid points near each corner for which no DEM values are supplied. These values will be assigned a value of 100 meters.

  2. LAS> dem2las in="mingoville_pa.tar.gz" out=mingoville print="(term,mingoville.hdr)

    The DEM data for the Mingoville quadrangle in file mingoville_pa.tar.gz will be used to create a LAS image named mingoville. A formatted listing of the DEM header data will be displayed on the terminal and also written to file mingoville.hdr. The ".tar.gz" extension indicates on the input file name indicates that it is in SDTS format, and needs to be uncompressed before processing begins.

Description/Algorithm:

For input in traditional USGS ASCII format, the file contains three types of records: A, B, and C. The "A" record contains the header information for the file. The "B" data records each contain elevation data for one south to north column of grid points. Each of the "B" records contains header information for the column and the data records. The "C" data record (if it exists) contains confirmation (quality) data for the file.

For SDTS-format input, the header information is distributed among a number of DDF (data descriptive) files, and the actual elevation data are in an additional DDF file; all of the DDF files are packaged in a single Unix tape-archive (.tar) file.

The program begins by getting the program arguments. If the input format (FORMAT) is not given explicitly, the input file extension is checked to determine this format. If the input file is in a compressed format, DEM2LAS then opens a pipe to uncompress the input file.

If the input is in traditional USGS ASCII format, the program first reads and interprets the "A" record header data and determines the size and projection coordinates of the output image rectangle needed to contain the input data. The "B" record data are then read and converted to 16-bit binary elevation values above mean sea level, and output in standard LAS image format. The information from the "C" record, if any, is merged with the header data from the "A" record.

For SDTS-format input, all the DDF files in the tar archive are checked. If a give DDF file contains header information needed for the output listing, the necessary fields are extracted from the DDF. If the DDF contains actual elevation values, the starting location of the DDF within the tar archive is saved. When all DDF files have been processed, the DEM array dimensions from the header fields are used to read the elevation data, convert them to 16-bit binary elevation values, and output them in standard LAS image format.

The header data are then used to build the LAS data descriptor record file (DDR) for the image. A formatted listing of the header data is also generated.

Nonfatal Error Messages:

  1. [dem2las-missent] Missing entry for profile xxx

    The specified profile had fewer values than specified in the B-record header. The input file may have become corrupted. After ten missing entries are encountered, DEM2LAS aborts.

  2. [dem2las-noCrec] C record expected but not found

    The input file header indicates that quality assessment data are provided in a type C record, but this record was not found. Input file may have become corrupted -- check that the output image and DDR files contain valid data.

  3. [dem2las-badrsnm] Invalid or missing value for <item> in <file:field:subfield>

    Either the specified item was missing from the specified SDTS file, field, and subfield, or it contained an unrecognized value. The archive file may have become corrupted or new options may have been added to the SDTS encoding which are not supported by the current verion of DEM2LAS.

  4. [dem2las-badcorn] Grid extends beyond specified region

    The coordinates of the upper left corner, from RSDF:SADR:X and Y or the coorindates of the lower right grid cell, computed from the upper left cell coordinates and the grid dimensions, do not fall within the maximum and minimum values of the corner coordinates specified by SPDM:DMSA:X and Y. The archive file may have become corrupted. As of June, 1999, the specification of the coordinates for the upper left grid cell in file RSDF for 7.5-minute DEMs was suspect, and often needed to be recomputed by DEM2LAS from the boundaries of the 7.5-minute quadrangle; in rare cases, this computation might be affected by roundoff errors. Use DSPDDR to verify the corner coordinates in the DDR.

Fatal Error Messages:

  1. [dem2las-fatal] Fatal error encountered

    DEM2LAS encountered a fatal error condition. The specific error condition is specifed by the error message immediately preceding this one. Messages identified by [dem2las-...] are explained below; other messages may be generated by a support function called by DEM2LAS.

  2. [dem2las-noinfile] Input file not found

    The file specified by variable IN was not found, with or without .Z or .gz extension. Check that file name and directory path were entered correctly.

  3. [dem2las-openpipe] Error opening pipe from DEM file

    An error was encountered while trying to open pipe for passing input data to main program. See the LAS system manager.

  4. [dem2las-openin] Error opening input DEM file

    An error was encountered while trying to open the input DEM file. See the LAS system manager.

  5. [dem2las-alloc] Error allocating dynamic memory

    An error was encountered while trying to allocate dynamic memory. See the LAS system manager.

  6. [dem2las-read1] Error reading first record of file

    No data were obtained from the input. The message immediately preceding this one may indicate the cause. Check that the input file is not empty; otherwise, see the LAS system manager.

  7. [dem2las-format] Data cannot be interpreted in DEM format

    The data from the input file are not in standard DEM ASCII format. Note that digital elevation data in other formats can be processed by program DEMENTER.

  8. [dem2las-random] Random data patterns are not supported

    The input header indicates that file contains data in random spatial patterns rather than regular columns. DEM2LAS does not support random data patterns. This message may also indicated that the header recore has been corrupted.

  9. [dem2las-units] Invalid units field -- not DEM format

    The units code of the input header record is invalid. The input file is not in valid DEM ASCII format.

  10. [dem2las-nocorn] Missing corner coordinates

    One or more corner-coordinate fields in the input header A record were missing. DEM cannot be georeferenced.

  11. [dem2las-nogridspc] Grid spacing not specified

    The x and y grid spacing is not specified or entered as zero in the input header A record. DEM resolution cannot be determined.

  12. [dem2las-rectang] Rectangular patches are not supported

    Input header specifies rectangular patches. The input file in not in standard USGS ASCII DEM format.

  13. [dem2las-read] Read error or premature EOF on input

    Input file may contain less input data than indicated by header record. Otherwise, see LAS system manager.

  14. [dem2las-badBhdr] Bad profile number in B record header

    The header for a profile data record (type B record) contained a profile number out of sequence or otherwise invalid. Input file may have become corrupted.

  15. [dem2las-badprfl] Profile starts below image frame

    The northing for the start of current profile is less than minimum northing specified in file header. Input file may have become corrupted.

  16. [dem2las-informat] Cannot determine input file format

    The input file format is not specified explicitly (by parameter FORMAT) and cannot be inferred from the file extension of the input filename. Check that filename is entered correctly; if filename extension does not indicate file format, enter value for FORMAT.

  17. [dem2las-cellfile] Cannot handle <filename> elevation data file

    The specified .DDF file in the tar archive appears to be of type "CEL", but is neither "CELL" nor "CEL0". The program does not know how to interpret this. Please inform the LAS system manager.

  18. [dem2las-nottar] Input not a tar file

    The input file specified for SDTS-format elevation data does not contain header records in standard tar archive format. Check that the correct file has been specified.

  19. [dem2las_dupddf] Duplicate DDF file type <filetype>

    There is more than one file in the SDTS tar archive whose name ends with the characters specified by <filetype>. The archive is not of a form which DEM2LAS can interpret.

  20. [dem2las-noddf] File type <filetype> missing from tar archive

    The SDTS tar archive does not contain any file whose name ends with the characters specified by <filetype>. DEM2LAS cannot complete processing of the data without this file.

  21. [dem2las-badldr] Bad record leader for field <fieldname>

    The SDTS tar archive contained a file with a record leader which could not be interpreted. This problem was encountered while searching for the field specified by <fieldname>. The archive file may have become corrupted.

  22. [dem2las-nofield] Cannot find field <field>

    DEM2LAS was unable to find the specified field in the expected SDTS file. The archive file may have become corrupted.

  23. [dem2las-nosubfld] Cannot find subfield <subfield> of field <field>

    DEM2LAS was unable to find the specified subfield in the SDTS file containing the specified field. The archive file may have become corrupted.

  24. [dem2las-outexist] Output file <filename> exists

    A file already exists with the specified output file name. Delete the file (and its associated .ddr and .his files, if any) or specify a different output file name.

  25. [dem2las-openout] Error opening output file

    An error occurred when trying to open the output file. A preceding message may give additional information.

  26. [dem2las-badrowno] Bad row number <value> for record <recno>

    The ROWI subfield of the specified SDTS elevation data record contained a value which does not match the record number. The archive file may have become corrupted.

  27. [dem2las-badcolno] Record <recno> has wrong number of columns

    The specified SDTS elevation data record has a length for the cell values subfield which does not match the length for the first record. The archive file may have become corrupted.

  28. [dem2las-write] Error writing output

    An error occurred while trying to write to the output file. A preceding message may give additional information.

  29. [dem2las-badlen] Bad file length for <filename>

    The specified SDTS file in the SDTS archive has internal index information which conflicts with the file length specified in the tar header record. The archive file may have become corrupted.

  30. [dem2las-badrsnm] Invalid or missing value for <item> in <file:field:subfield>

    Either the specified item was missing from the specified SDTS file, field, and subfield, or it contained an unrecognized value. The archive file may have become corrupted or new options may have been added to the SDTS encoding which are not supported by the current verion of DEM2LAS.

User Notes:

  1. The program DEM2LAS accepts only USGS DEM data, in either the traditional DEM format or SDTS (Spatial Data Transfer Standard) format. Additional types of digital elevation data may be read from tape using program DEMENTER.

  2. For further information on DEM data, consult the U. S. Geological Survey publication "Digital Elevation Models", (Data Users Guide 5, Reston, VA, 1990). More recent versions may be available.

  3. The SDTS format for DEMs is described in the draft document "The Spatial Data Transfer Standard Mapping of the USGS Digital Elevation Model", available (as of March, 1999) for download from the USGS SDTS site: ftp://sdts.er.usgs.gov/pub/sdts/datasets/raster/dem/demmap.XX where XX = "wp" for WordPerfect format, "pdf" for Adobe portable document format.

    The full SDTS standard uses the ISO 8211 (FIPS Pub. 123) encoding. This is supported by an extensive library for locating fields within records. The DEM2LAS implementation does not use this library, since the DEMs use a standard set of fields. However, different groups converting the DEMs to SDTS have used two different ways for encoding the actual elevation values and two different ways for encoding the X,Y coordinates at the upper left corner. DEM2LAS supports both of these options. However, it is possible that other options have been used for DEMs which were not available when testing was done.

  4. USGS DEM coverage available as of late 1993:

    
       SCALE          COVERAGE                      DESCRIPTION
       =====          ========                      ===========
    
    1:250,000     	Coverage of U.S.	3 x 3 arcsecond cell size
    (1 x 1 degree, 	nearing completion,	(3 x 6 in Alaska)
     2 or 3 files	including most of       No projection
     per map sheet)	Alaska			Elevation in meters
    					1201 lines x 1201 samples
                                            (601 samples in Alaska)
    
    1:24,000	On-going effort,	30 meter cell size
    (7.5 x 7.5	approaching 50%		UTM projection
     min., 1 file	completion		Elevation in meters
     per map sheet) 			~475 lines x 335 samples