[GRASS-user] r.out format

Glynn Clements glynn at gclements.plus.com
Thu Mar 8 00:24:54 EST 2007


Tyler Smith wrote:

> I'm having some trouble with r.out.{ascii,gdal}. I need to convert a
> number of raster maps to ascii grids. I have done this successfully
> with GRASS 6.0.2, using (I think) r.out.ascii. I have just upgraded to
> GRASS 6.2.1 (and gdal1.3.2-4), from the Debian repository at 
> deb http://debian.gfoss.it/ etch main
> 
> Now I'm getting problems. The output from r.out.ascii from GRASS 6.0.2 has
> the header:
> 
> ncols 5956
> nrows 3502
> xllcorner -108.976860
> yllcorner 24.187389
> cellsize 0.008334
> NODATA_value -9999

This matches the output from r.out.arc; AFAICT, r.out.ascii has never
been able to produce that format.

> This file was formatted correctly for use with another program (Maxent
> by Stephen Philips). When I tried to repeat the export with GRASS
> 6.2.1 I get a file with the following header:
> 
> north: 49:24:18.796644N
> south: 25:50:41.471736N
> east: 59:33:29.28636W
> west: 101:21:56.86362W
> rows: 2827
> cols: 5017

This is what I would expect from r.out.ascii.

> The difference in rows and cols is correct, as I had altered the
> region for this conversion to get a subset of the raster data. I tried
> again with r.out.gdal format=AAIGrid, and I got the following:
> 
> ncols        5956
> nrows        3502
> xllcorner    -108.976860000000
> yllcorner    24.189671187374
> dx           0.008333776360
> dy           0.008334428041
> NODATA_value      0
> 
> This is almost right, and it works in Maxent after I manually remove
> the dx and dy lines, and replace them with a cellsize line. However,
> the ncols, nrows and corners are wrong - they are from the full raster map, not
> the region that I am using. Note that the r.out.gdal command was
> issued immediately following the r.out.ascii command, so they should
> have the same extent.

In 6.2.1, r.out.gdal is a script which uses gdal_translate, which
ignores the region. The current CVS head (6.3) version has a "real"
r.out.gdal program which will respect the current region.

> What do I need to do to export in the first format above, and to do so
> in such a way that only the current region is exported, not the whole
> raster map?

r.out.arc, probably.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list