English

How To: Convert a grid to a text file of x-, y- and z-values of the center of each cell with the SAMPLE function

Summary

While the ArcToolbox Conversion tool 'Grid to ASCII' produces an ASCII file that stores the z-values of each cell of a grid, there is no x and y coordinate for the center of each cell. Intstructions provided produce a text file that contains the x coordinate, the y coordinate, and the z-value of the center of every cell in a grid. Spatial Analyst is required to perform this operation.

Procedure

The following steps require the Spatial Analyst extension to be active and the Spatial Analyst toolbar to be turned on.

  1. Add the grid to ArcMap.
  2. Select the Raster Calculator option from the Spatial Analyst menu.
  3. Use the following expression in the Raster Calculator where [ingrid] is the name of the grid layer:

    Code:
    outfile.txt = SAMPLE([ingrid],[ingrid])

  4. The text file called outfile.txt is written to the working directory. The working directory can be determined or set from the Spatial Analyst > Options > General tab.

    Note:
    The format of the output text file may have to be modified to be compatible with specific needs. The first and last columns in the text file are the z-values.

    Note:
    ESRI does not provide the VBA code for the above procedure. The necessary code must be developed by the user.

Related Information