Unit 06 - Data export

Data produced by GRASS modules (like i.vi in Unit 05 - Simple computation) is stored always in the current mapset. It is simply a rule. Current mapset can be changed by Settings ‣ GRASS working environment ‣ Change mapset.

There are two fundamental modules for exporting data:

  • r.out.gdal for exporting raster data (File ‣ Export raster map ‣ Common export formats)
  • v.out.ogr for exporting vector data (File ‣ Export vector map ‣ Common export formats)

Both the modules are based on well-known GDAL library for reading and writing raster and vector geospatial data formats. Thanks to this library GRASS is able to export data into various GIS formats, see supported raster and vector formats.


Fig. 44 Export raster map in Layer Manager.


Remember that raster export module operates in a current computation region. So don’t forget to set desired computation region before exporting data. In this way, for example, you can easily export only subregion or a tile.


Fig. 45 Export NDVI raster into GeoTIFF format.

Try to load created raster in some GIS software like Esri ArcGIS or QGIS. Note that color table is not exported in the case of floating-point data, so you need to set up suitable color interpretation in your software on your own.


Fig. 46 NDVI TIFF file loaded in QGIS.

Useful notes

  • Most of vector formats are based on simple feature model. It means that GRASS export module converts topological primitives (lines, boundaries, centroids, areas, isles) into simple features (linestrings, polygons). Points have no topology, so no conversion is involved.
  • GRASS does not distinguish between single and multi parts (features and multifeatures). Attributes are simply linked to primitives (usually points, lines, or centroids) via so called “category”. More primitives can have the same category assigned, so the same attributes linked. This is a way how GRASS handles multiparts. By default v.out.ogr exports such primitives like single parts, ie. featutes. Multi parts (multifeatures) are written only when -m flag is given.
  • GRASS supports also one of few topological formats, PostGIS Topology, see v.out.postgis for details.
  • To increase interoperability with your Esri colleagues, GRASS data can be exported directly also to Esri File Geodatabase format. This requires GDAL with FileGDB support. But we highly recommend to use for data exchange open standards like OGC GeoPackage which Esri products can (usually) read. BTW, this format is default for v.out.ogr since GRASS 7.4.

Interoperability with Esri ArcGIS

GRASS is able to read data stored in Esri File Geodatabase out of the box thanks to GDAL library which comes with OpenFileGDB support. Note that only vector data (feature classes) are supported, it’s not possible to read raster data from this format. As already noted in Useful notes, vector data can be written to Esri File Geodatabase format only when GDAL is installed with proprietary-based FileGDB support.

In any case we recommend modern OGC-based OGC GeoPackage format for exchanging data between various GIS packages. This format allows to store multiple raster or vector layers in one file (GeoPackage is based on file-based SQLite DB format).

Output data in external formats (advanced)

GRASS environment can be set to produce data directly in external formats. It can be useful at the end of a workflow when final output data is produced. Writing output data directly to desired format saves one step, exporting data outside GRASS (r.out.gdal, v.out.ogr). External format can be set using r.external.out for raster outputs or by v.external.out in the case of vector outputs.

Example for our workflow (map names shorten):

g.region vector=oslo align=B04_10m
r.mask --overwrite -i vector=MaskFeature
r.external.out directory=/tmp format=GTiff extension=tif
i.vi --overwrite red=B04_10m output=ndvi nir=B08_10m

Produced data is stored directly (without any data conversion) in external format (GeoTIFF in this case). GRASS also creates automatically link to such data (similarly as r.external do), so you can access produced data as normal raster maps.