ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Raster to ASCII

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Converts a raster dataset to an ASCII text file representing raster data.

Usage

  • The input raster dataset can be any valid raster dataset.

  • The structure of the ASCII file consists of header information containing a set of keywords, followed by cell values in row-major order.

    The format of the file in general is:

        NCOLS xxx
        NROWS xxx
        XLLCORNER xxx
        YLLCORNER xxx
        CELLSIZE xxx
        NODATA_VALUE xxx
        row 1
        row 2
        .
        .
        row n

    The definitions of the keywords are as follows:

    • NCOLS and NROWS are the number of columns and rows in the raster defined by the ASCII file.

    • XLLCORNER and YLLCORNER are the coordinates of the lower left corner of the lower left cell.

    • CELLSIZE is the cell size of the raster.

    • NODATA_VALUE is the value that is to represent NoData cells.

    • In the data stream of cell values, row 1 of the data is the top of the raster, row 2 is just under row 1, and so on.

  • An example of an ASCII raster file is:

        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
        35 45 65 34 2 6 78 4 2 6 89 3 2 7 45 23 5 ...
  • The NODATA_VALUE is the value in the ASCII file that will represent cells that are NoData 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 character in the file.

  • Both integer and floating point rasters can be converted to an ASCII raster file.

  • This tool only writes the origin as the lower left corner of the lower left cell. The ASCII to Raster tool also supports the origin as the center of the lower left cell.

Syntax

RasterToASCII_conversion (in_raster, out_ascii_file)
ParameterExplanationData Type
in_raster

The input raster dataset.

The raster can be integer or floating-point type.

Raster Layer
out_ascii_file

The output ASCII raster file.

File

Code sample

RasterToASCII example (Python window)

Converts a raster dataset to an ASCII file representing raster data.

import arcpy
from arcpy import env
env.workspace = "c:/data"
arcpy.RasterToASCII_conversion("elevation", "c:/output/sa500.asc")
RasterToASCII example (stand-alone script)

Converts a raster dataset to an ASCII file representing raster data.

# Name: RasterToASCII_Ex_02.py
# Description: Converts a raster dataset to an ASCII file representing 
#    raster data. 
# Requirements: None

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"

# Set local variables
inRaster = "elevation"
outASCII = "c:/output/elevation.asc"

# Execute RasterToASCII
arcpy.RasterToASCII_conversion(inRaster, outASCII)

Environments

  • Auto Commit
  • Cell Size
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Output CONFIG Keyword
  • Output Coordinate System
  • Scratch Workspace

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • About converting from raster data
  • ASCII to Raster

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal