The Grid ASCII File Format
Incomplete
1. Introduction
There are a huge number of file formats for raster data. The Grid ASCII format, developed by ESRI, is one of the few that encodes the raster data as text. This is not the most efficient way to store raster data but it is very handy if we want to create the files from a scripting language.
2. The Format
The format is relatively simple as it contains a pre-defined header with the simplest possible information to define and georeference a raster image. A Grid file should be accompanied by a projection file ("PRJ") so it has a complete georeference. Below is an example of a REALLY simple ASCII grid file:
ncols 3 nrows 4 xllcorner -105.5 yllcorner 40.1 cellsize 100.0 NODATA_value -9999 12 34 23 -9999 32 37 -9999 28 17 -9999 -9999 20
The first six values define the contents of the raster data as defined in the table below. The remainder of the file is the raster data itself. The raster data must contain "nrows" of numbers arranged as "ncols" of values separated by spaces. Each number represents one pixel and the values can be integer or floating point. This format only supports 1-band data (i.e. only gray scale, RGB is not supported).
ncols | The width of the raster in pixels, the number of pixels in the raster horizontally. |
nrows | The height of the raster in pixels, the number of pixels in the raster vertically |
xllcorner | The value of the "x" portion of the coordinate of the lower-left corner of the raster. Typically the easting or longitude value for left-most pixel in the raster |
yllcorner | The values of the "y" portion of the coordinate o the lower-left corner of the raster. Typically the northing or latitude value for the bottom-most pixel in the raster. |
cellsize | The width, and height, of each pixel in the raster in map units. The units are typically defined in a PRJ file. |
NODATA_value | The value used for pixels that do not contain any valid data. These pixels are typically transparent in a GIS package. |
Additional Resources
WikiPedia: ESRI Grid Formats
ESRI Documentation: ArcInfo ASCII Grid Format