Convert a grid to a text file of x-, y- and z-values of the center of each cell with the Grid to Features function in the Spatial Analyst toolbar

Last Published: April 26, 2020


While the ArcToolbox Conversion tool 'Grid to ASCII' will produce 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. This article describes a method that will produce a text file that contains the x coordinate, the y coordinate, and the z-value of the center of every cell a grid. Spatial Analyst is required to perform this operation.

The advantages of using this method are that it provides control over the precision of the values returned for the x and y coordinates and the format of the txt file generated. The disadvantages to this method are that only integer grids can be used, because floating-point grids do not have a VAT, and it can be time consuming.


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

Add the grid to ArcMap

  1. Select the Convert option under the Spatial Analyst menu.
  2. Select the Raster to features option.
  3. Select the field for the z-values in the text file. Typically, this is the Value field.
  4. Set the Output Geometry type to points.
  5. Select an output shapefile or feature class.
  6. Click OK. This generates a layer with a point at the center of each cell. The value in the field GRID_CODE is the z-value of the cell.

Populate the table of the new layer

  1. Add x and y fields to the table of the layer.
  2. Populate the x and y fields with the values from the point. Refer to the following technical article for further details: How To: Calculate X, Y, and Z values in an attribute table using Field Calculator.
  3. Close the table.

Configure layer properties

  1. Right-click the layer, select Properties, and click the Fields tab.
  2. If necessary, turn off fields that shouldn’t be in the final text file by selecting them one at a time from the list and removing the checkmark next to 'visible'.
  3. Click OK in the layer Properties dialog to accept the changes to the table.
  4. Right-click the layer, and select the Open Attribute Table option.
  5. Click Options and select the Export option.
  6. Click the Browse button.
  7. In the Saving data dialog box, select Text file from the Save as type drop-down list.
  8. Navigate to a directory to save the file and select an appropriate name.
  9. Click Save and OK.

Article ID:000006797

  • ArcMap 8 x
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic