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?

  • 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 May 6 '17 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 ? – Luís de Sousa May 8 '17 at 9:19
1

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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