Skip to content

r.in.ascii

Converts a GRASS ASCII raster file to binary raster map.

r.in.ascii [-s] input=name output=name [type=string] [title=phrase] [multiplier=float] [null_value=string] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

r.in.ascii input=name output=name

grass.script.run_command("r.in.ascii", input, output, type=None, title=None, multiplier=None, null_value=None, flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("r.in.ascii", input="name", output="name")

Parameters

input=name [required]
    Name of input file to be imported
    '-' for standard input
output=name [required]
    Name for output raster map
type=string
    Type of raster map to be created
    Default: CELL for integer values, DCELL for floating-point values
    Allowed values: CELL, FCELL, DCELL
    CELL: Integer
    FCELL: Single precision floating point
    DCELL: Double precision floating point
title=phrase
    Title for resultant raster map
multiplier=float
    Multiplier for ASCII data
    Default: read from header
null_value=string
    String representing NULL value data cell
    Default: read from header
-s
    SURFER (Golden Software) ASCII file will be imported
--overwrite
    Allow output files to overwrite existing files
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

input : str, required
    Name of input file to be imported
    '-' for standard input
    Used as: input, file, name
output : str, required
    Name for output raster map
    Used as: output, raster, name
type : str, optional
    Type of raster map to be created
    Default: CELL for integer values, DCELL for floating-point values
    Allowed values: CELL, FCELL, DCELL
    CELL: Integer
    FCELL: Single precision floating point
    DCELL: Double precision floating point
title : str, optional
    Title for resultant raster map
    Used as: phrase
multiplier : float, optional
    Multiplier for ASCII data
    Default: read from header
null_value : str, optional
    String representing NULL value data cell
    Default: read from header
    Used as: string
flags : str, optional
    Allowed values: s
    s
        SURFER (Golden Software) ASCII file will be imported
overwrite: bool, optional
    Allow output files to overwrite existing files
    Default: False
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

r.in.ascii allows a user to create a (binary) GRASS raster map layer from an ASCII raster input file with (optional) TITLE.

The GRASS ASCII input file has a header section which describes the location and size of the data, followed by the data itself.

The header has 6 lines:

north:   xxxxxx.xx
south:   xxxxxx.xx
east:    xxxxxx.xx
west:    xxxxxx.xx
rows:    r
cols:    c

The north, south, east, and west field values entered are the coordinates of the edges of the geographic region. The rows and cols field values entered describe the dimensions of the matrix of data to follow. The data which follows is r rows of c integers.

Optionally the following parameters can be defined in the header section:

null: nn
type: float
multiplier: 2.

"null" defines a string or number to be converted to NULL value (no data).
"type" defines the data type (int, float double) and is not required.
"multiplier" is an optional parameter to multiply each cell value.

NOTES

The geographic coordinates north, south, east, and west describe the outer edges of the geographic region. They run along the edges of the cells at the edge of the geographic region and not through the center of the cells at the edges. The NW value occurs at the beginning of the first line of data, and the SW value occurs at the beginning of the last line of data.

The data (which follows the header section) must contain r x c values, but it is not necessary that all the data for a row be on one line. A row may be split over many lines.

The imported cell type can be forced using the type option, default is auto-detection.

The header information in ESRI Raster ASCII files differs from GRASS. To convert an Arc/Info (ArcView) ASCII grid file into GRASS, see r.in.gdal.

SURFER (Golden Software) ASCII files may be imported by passing the -s flag.

EXAMPLE

The following is a sample input file to r.in.ascii:

north:                   4299000.00
south:                   4247000.00
east:                     528000.00
west:                     500000.00
rows:                         10
cols:                         15
null:                      -9999

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

SEE ALSO

r.import, r.out.ascii, r.in.gdal, r.out.gdal, r.in.bin, r3.in.ascii

AUTHORS

Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
Surfer support by Roger Miller

SOURCE CODE

Available at: r.in.ascii source code (history)
Latest change: Friday Mar 07 07:39:48 2025 in commit e1e37d8