2

I need to export a raster I produced with GRASS. The Map Display portraits this raster like this:

enter image description here

The metadata of this raster also looks pretty normal:

> r.info map=blenddem
 +----------------------------------------------------------------------------+
 | Map:      blenddem                       Date: Fri May  5 11:35:05 2017    |
 | Mapset:   DEMs                           Login of Creator: desouslu        |
 | Location: Luzern                                                           |
 | DataBase: /home/desouslu/maps/grass              |
 | Title:                                                                     |
 | Timestamp: none                                                            |
 |----------------------------------------------------------------------------|
 |                                                                            |
 |   Type of Map:  raster               Number of Categories: 0               |
 |   Data Type:    DCELL                                                      |
 |   Rows:         3369                                                       |
 |   Columns:      3110                                                       |
 |   Total Cells:  10477590                                                   |
 |        Projection: CH1903+ / LV95                                          |
 |            N:   210553.5    S:     208869   Res:   0.5                     |
 |            E:     668202    W:     666647   Res:   0.5                     |
 |   Range of data:    min = 430.691497802734  max = 600.981266929298         |
 |                                                                            |
 |   Data Description:                                                        |
 |    generated by r.patch                                                    |
 |                                                                            |
 |   Comments:                                                                |
 |    r.patch input="tmp_3151920,uavdem" output="blenddem"                    |
 |                                                                            |
 +----------------------------------------------------------------------------+

I am using r.out.gdal to export this raster, and apparently everything goes on fine:

> r.out.gdal input=blenddem output=/home/desouslu/maps/blenddem.asc format=AAIGrid --overwrite -c
Driver <AAIGrid> does not support direct writing. Using MEM driver for
intermediate dataset.
Checking GDAL data type and nodata value...
 100%
Using GDAL data type <Float64>
Input raster map contains cells with NULL-value (no-data). The value -nan
will be used to represent no-data values in the input map. You can specify
a nodata value with the nodata option.
Exporting raster data to AAIGrid format...
 100%
r.out.gdal complete. File
</home/desouslu/maps/blenddem.asc> created.

However, the resulting raster is actually empty:

> cat /home/desouslu/maps/blenddem.asc
ncols        1
nrows        1
xllcorner    0.000000000000
yllcorner    0.000000000000
cellsize     1.000000000000
NODATA_value  -nan
 -nan

What is exactly going on here? Am I using r.out.gdal incorrectly?

2
  • 1
    did you remember to set the region? (I always forget to do this as I tend to run Grass from inside QGIS, which does that for you)
    – Steven Kay
    Commented May 6, 2017 at 19:43
  • Steven, you are correct. For some reason the region was reset by one of the various operations I did prior to export. Can you please add in an answer with g.region raster=blenddem ? Commented May 8, 2017 at 9:19

1 Answer 1

2

I find this usually happens if I forget to set the region on the raster (or the region is unset)

If you use g.region you should be able to set the region e.g. g.region raster=blenddem

Or you could run GRASS from inside the QGIS Processing pipeline, which does this for you.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.