English

How To: Create a DEM from an ASCII file of xyz coordinates

Summary

You can create DEMs as ArcInfo TINs or grids from ASCII files containing coordinate definitions. These definitions may be comma delimited:

x,y,z
x,y,z
x,y,z
.
.

They can also be space delimited:

x y z
x y z
x y z
.
.

Procedure

 

  1. Use the CREATETIN's GENERATE subcommand to create a TIN.
     
    Arc: CREATETIN outtin
    Copyright (C) 1982-2000 Environmental Systems Research Institute, Inc.
    All rights reserved.
    CREATETIN Version 8.0.2 (Tue Feb 22 08:01:14 PST 2000)

    Createtin: GENERATE
    Usage: GENERATE {POINT | LINE} {sftype_item | sftype}
    {logical_expression} {weed_tolerance}
    Createtin: GENERATE infile.gen POINT

    This subcommand requires the number one to precede each coordinate entry in the ASCII file, and the keyword END to be the last line. The entries may be either comma or space delimited.
     
    1,x,y,z
    1,x,y,z
    1,x,y,z
    end  

    You can use AML to add the number one to the coordinate definitions.
     
    * aml_orw.aml
    /* USAGE: &RUN aml_orw.aml
    /*
    /* This AML opens an ASCII file, READs a record (line) from the file,
    /* adds a 1 to the beginning of each line of the file, opens a new ASCII
    /* file, and writes the line to the new file.

    &ARGS file
    &SETVAR o1 [OPEN %file% os1 -READ]
    &SETVAR r1 [READ %o1% rs1]
    &SETVAR o2 [OPEN newfile.pnt os2 -WRITE]
    &DO &UNTIL %rs1% = 102
    &SETVAR r2 [QUOTE 1,[UNQUOTE %r1%]] /* <-- This adds a 1 to each row
    &SETVAR w1 [WRITE %o2% %r2%]
    &SETVAR r1 [READ %o1% rs1]
    &END
    &SETVAR w1 [WRITE %o2% END]
    &SETVAR c1 [CLOSE %o1%]
    &SETVAR c2 [CLOSE %o2%]
    &RETURN
 
  • If the task calls for a grid/lattice, and the coordinate locations are not spaced at regular intervals in both the x and y dimensions, use the TINLATTICE command to interpolate a grid/lattice from the TIN created in step 1.
    Coordinates can represent a regularly spaced matrix of points or an irregularly spaced group of points.

    [O-Image] Regular and irregular mesh point spacing
    The output grid/lattice will not contain the exact values of the original ASCII file, since TINLATTICE is an interpolation process.
  • If the task calls for a grid/lattice, and the coordinate locations are spaced at regular intervals in both the x and y dimensions, and the spacing distance is known, you can use this method:

    a) Use DEFINE in Tables to create an empty INFO file with item definitions appropriate for the precision of the values in the ASCII file. Item definition using Floating point (F) items might be appropriate.
    b) SELECT the newly defined INFO file
    c) Use ADD FROM in Tables to import the original unedited ASCII file data into the empty INFO file.
    d) Type SELECT to close the new INFO file.
    e) Use ADDITEM to add an item called PTCOV-ID as a 4 5 B.
    f) SELECT the new INFO file again.
    g) Use CALC to set the PTCOV-ID to the value of the record number.
    h) Edit the ASCII file to comply with GENERATE input point format, as described in step 1.
    i) Use GENERATE at the Arc prompt to create a point coverage named PTCOV from the ASCII file.
    j) BUILD the new coverage for POINT.
    k) In Tables, SELECT the ptcov.pat file.
    l) CALC the ptcov-id = $recno
    m) At the Arc prompt, use JOINITEM to join the xyzinfo.dat file to the ptcov.pat. Use ptcov-id as the relate item.
    n) Use POINTGRID at the Arc prompt to convert the ptcov points to a grid based on the ptcov.pat item containing the z values. Be sure to specify the correct cell size.

    An example of this method.
    Code:
    Arc: tables
    Copyright (C) 1982-2000 Environmental Systems Research Institute, Inc.
    All rights reserved.
    TABLES Version 8.0.2 (Tue Feb 22 08:01:14 PST 2000)
    
    Tables: DEFINE xyzinfo.dat
    	1
    Item Name: x_coord,4,12,f,3
    	5
    Item Name: y_coord,4,12,f,3
    	9
    Item Name: z_value,4,12,f,3
    	13
    Item Name:
    Tables: SELECT xyzinfo.dat
    0 Records Selected.
    Tables: ADD FROM c:\users\demwork\originfile.txt
    Tables: SELECT
    File XYZINFO.DAT is now closed.
    Tables: ADDITEM xyzinfo.dat ptcov-id,4,5,b
    Tables: SELECT xyzinfo.dat
    9 Records Selected.
    Tables: CALC ptcov-id = $recno
    Arc: GENERATE ptcov
    Copyright (C) 1982-2000 Environmental Systems Research Institute, Inc.
    All rights reserved.
    GENERATE Version 8.0.2 (Tue Feb 22 08:01:14 PST 2000)
    
    Generate: INPUT newfile.txt
    Generate: POINT
    Creating points with coordinates loaded from newfile.txt
    Generate: QUIT
    
    Externalling BND and TIC...
    
    Arc: BUILD ptcov POINT
     Building points...
    Arc: TABLES
    Copyright (C) 1982-2000 Environmental Systems Research Institute, Inc.
    All rights reserved.
    TABLES Version 8.0.2 (Tue Feb 22 08:01:14 PST 2000)
    
    Tables: SELECT ptcov.pat
    9 Records Selected.
    Tables: CALC ptcov-id = $RECNO
    Tables: QUIT
    Leaving TABLES...
    Arc: JOINITEM ptcov.pat xyzinfo.dat ptcov.pat ptcov-id
    Joining ptcov.pat and xyzinfo.dat to create ptcov.pat
    Usage: POINTGRID {value_item} {lookup_table}
    	{weight_table}
    Arc: POINTGRID ptcov finalgrd z_value
     Converting points from ptcov to grid finalgrd
    Cell Size (square cell): 1 1
    Convert the Entire Coverage(Y/N)?: y
    Enter background value (NODATA | ZERO):
    Number of Rows = 3
    Number of Columns = 3

Related Information