GRASS logo

Note: A new GRASS GIS stable version has been released: GRASS GIS 7. Go directly to the new manual page here

NAME - Export a raster map to a text file as x,y,z values based on cell centers.


raster, export

SYNOPSIS help input=name[,name,...] [output=name] [fs=character] [--verbose] [--quiet]


Name of input raster map
Name for output file (if omitted or "-" output to stdout)
Field separator
Default: |


The module exports a raster map as a list of x,y,z values into an ASCII text file.


This module will not export x,y coordinates for raster cells containing a NULL value. This includes cells masked by a raster MASK.

This module, as all GRASS raster modules, will export cells based on the current region settings. See the g.region module for details.

The r.out.ascii module should be used to export an array (of size row x column) containing z values. can combine several input raster maps, which can be convenient when it comes to e.g. produce ASCII point cloud files. is simply a front-end to "r.stats -1gn".


In this example, a LiDAR elevation map in the North Carolina sample dataset location is exported to CSV format.
g.region rast=elev_lid792_1m -p input=elev_lid792_1m output=elev_lid792_1m.csv fs=","

In this example, elevation data from the North Carolina dataset are exported along with R,G,B triplet of the related orthophoto into a combined file (requires the import of the supplementary high-resolution color orthophoto, here called "ortho2010_t792"):

g.region rast=elev_lid792_1m res=1 -a -p
# R=1, G=2, B=3 input=elev_lid792_1m,ortho2010_t792.1,ortho2010_t792.2,ortho2010_t792.3 \
        fs=space output=pointcloud.asc

# validate: X Y Z R G B
head -n 3 pointcloud.asc
638300.5 220749.5 126.338218689 78 84 71
638301.5 220749.5 126.3381958008 93 101 86
638302.5 220749.5 126.3414840698 68 77 59


Implement this script as a r.out.ascii option?


g.region, r.mask r.out.ascii, r.stats


M. Hamish Bowman
Dept. Marine Science
Otago University, New Zealand

Last changed: $Date: 2013-12-03 13:26:15 -0800 (Tue, 03 Dec 2013) $

Main index - raster index - Full index

© 2003-2016 GRASS Development Team