Raster To ASCII (Conversion) |
|
|
Release 9.2
Last modified April 2, 2008 |
Print all topics in : "Tools" |
Converts a raster dataset to an ASCII file representing raster data.
Usage tips
Command line and Scripting
The input raster dataset can be any valid raster dataset.
The ASCII file consists of header information containing a set of keywords, followed by cell values in row-major order. The file format is
NCOLS xxx
NROWS xxx
XLLCENTER xxx | XLLCORNER xxx
YLLCENTER xxx | YLLCORNER xxx
CELLSIZE xxx
NODATA_VALUE xxx
row 1
row 2
.
.
.
row nwhere xxx is a number and the keyword NODATA_VALUE is optional and defaults to -9999.
The Raster To ASCII tool will only generate files where the location of the raster is based off the lower left corner (LLCORNER). Note that the Raster To ASCII tool supports both LLCENTER and LLCORNER. For example:
NCOLS 480
NROWS 450
XLLCORNER 378922
YLLCORNER 4072345
CELLSIZE 30
NODATA_VALUE -32768
43 2 45 7 3 56 2 5 23 65 34 6 32 54 57 34 2 2 54 6
35 45 65 34 2 6 78 4 2 6 89 3 2 7 45 23 5 8 4 1 62 ...
The NODATA_VALUE is the value in the ASCII file that will be assigned to the NoData cells in the input raster. This value is normally reserved for those cells whose true value is unknown.
The end of each row of data from the raster is terminated with a carriage return in the file.
Both integer and floating point rasters can be converted to an ASCII format.
The output will be an ASCII text file.
The following environments affect this tool: current workspace, scratch workspace, output coordinate system, and output extent.
Command line syntax
An overview of the Command Line window
RasterToASCII_conversion <in_raster> <out_ascii_file>
| Parameter | Explanation | Data Type |
| <in_raster> |
The input raster dataset. The raster can be integer or floating point. |
Composite Geodataset |
| <out_ascii_file> |
The output ASCII file. |
File |
RasterToASCII_conversion d:\images\Myraster.mdb\Flemming Flemming.txt
Scripting syntax
About getting started with writing geoprocessing scripts
RasterToASCII_conversion (in_raster, out_ascii_file)
| Parameter | Explanation | Data Type |
| in_raster (Required) |
The input raster dataset. The raster can be integer or floating point. |
Composite Geodataset |
| out_ascii_file (Required) |
The output ASCII file. |
File |
# RasterToASCII_sample.py
# Description:
# Converts a raster into an ASCII file representing raster data.
# Requirements: None
# Author: ESRI
# Date: Oct 20, 2005
# Import system modules
import arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
try:
# Set local variables
InRaster = "C:/data/raster1"
OutAsciiFile = "C:/data/raster2ascii.asc"
# Process: RasterToASCII_conversion
gp.RasterToASCII_conversion(InRaster, OutAsciiFile)
except:
# Print error message if an error occurs
print gp.GetMessages()
Map Algebra syntax
See GridASCII.
ArcObjects syntax
See ExportToASCII.