ASCII To Raster (Conversion) |
|
Release 9.2
Last modified April 2, 2008 |
![]() ![]() ![]() Print all topics in : "Tools" |
Converts an ASCII file representing raster data to a raster dataset.
Usage tips
Command line and Scripting
The ASCII file must consist 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 n
Note: xxx is a number and the keyword nodata_value is optional and defaults to -9999. Row 1 of the data is at the top of the grid, row 2 is just under row 1, and so on.LLCENTER will use the center of the lowest left cell to provide a location for the raster. LLCORNER will use the lower left corner of the lowest left cell. Note that Raster To ASCII will only generate LLCORNER ASCII files. For example:
ncols 480 nrows 450 xllcorner 378923 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 to be assigned to those cells whose true value is unknown. In the raster, they will be assigned to NoData.
Cell values should be delimited by spaces. No carriage returns are necessary at the end of each row in the grid. The number of columns in the header is used to determine when a new row begins.
The number of cell values must be equal to the number of rows times the number of columns, or an error will be returned.
The output data type can be either float or integer.
The following environments affect this tool: current workspace, scratch workspace, output coordinate system, output extent, output has Z values, Z resolution, output CONFIG keyword, output spatial grid 1,2,3, output XY domain, output Z domain, output XY domain, output Z domain, cell size, pyramid, raster statistics, compression, and tile size.
Command line syntax
An overview of the Command Line window
ASCIIToRaster_conversion <in_ascii_file> <out_raster> {INTEGER | FLOAT}
Parameter | Explanation | Data Type |
<in_ascii_file> |
The input ASCII file to be converted. |
File |
<out_raster> |
The output raster dataset to be created. When not saving to a geodatabase, specify .tif for a TIFF file format, .img for an ERDAS IMAGINE file format, or no extension for a GRID file format. |
Raster Dataset |
{INTEGER | FLOAT} |
The data type of the output raster dataset.
|
String |
ASCIIToRaster d:\data\whitehorse.mdb\surveys.txt d:\Newdata.mdb\surveys.tif INTEGER
Scripting syntax
About getting started with writing geoprocessing scripts
ASCIIToRaster_conversion (in_ascii_file, out_raster, data_type)
Parameter | Explanation | Data Type |
in_ascii_file (Required) |
The input ASCII file to be converted. |
File |
out_raster (Required) |
The output raster dataset to be created. When not saving to a geodatabase, specify .tif for a TIFF file format, .img for an ERDAS IMAGINE file format, or no extension for a GRID file format. |
Raster Dataset |
data_type (Optional) |
The data type of the output raster dataset.
|
String |
# ASCIIToRaster_sample.py # Description: # Converts an ASCII file representing raster data to a raster. # Requirements: None # Author: ESRI # Date: Oct 20, 2005 # Import system modules import arcgisscripting # Create the Geoprocessor object gp = arcgisscripting.create() try: # Set local variables InAsciiFile = "C:/data/raster2ascii.asc" OutRaster = "C:/data/raster1" # Process: ASCIIToRaster_conversion gp.ASCIIToRaster_conversion(InAsciiFile, OutRaster, "INTEGER") except: # Print error message if an error occurs print gp.GetMessages()
Map Algebra syntax
See ASCIIGrid.
ArcObjects syntax
See ImportFromASCII.