[GRASS-dev] Re: Problem when loading GRASS 6 raster with large integer values into R via r.out.bin

Rainer M Krug r.m.krug at gmail.com
Tue Sep 23 06:52:49 EDT 2008


OK - I finally got around to testing it.

I installed spgrass6 as well as rgdal from source, as spgrass6 needed
a newer version of rgdal then available in CRAN  (Error: package
'rgdal' 0.5-25 was found, but >= 0.5.26 is required by 'spgrass6').

It is working, when using useGDAL=TRUE. See output below:

In GRASS:
GRASS 6.3.0 (grass):~/Documents/Projects/AlienSpread/R > r.info -r
map=ros_2016.max
min=0
max=36852
[Raster MASK present]
GRASS 6.3.0 (grass):~/Documents/Projects/AlienSpread/R >

In R:

> x <- readRAST6("ros_2016.max",useGDAL=FALSE )
Creating BIL support files...
Header File =
/home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/ros_2016.max.hdr
World File =
/home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/ros_2016.max.wld
Exporting raster as integer values (bytes=2)
Using the current region settings...
north=6247000.000000
south=6195000.000000
east=270200.000000
west=251000.000000
r=520
c=192
 100%
> range(x[[1]], na.rm=TRUE)
[1] -31916  30755
> x <- readRAST6("ros_2016.max",useGDAL=TRUE )
ERROR 6: SetColorTable() only supported for Byte or UInt16 bands in TIFF format.
WARNING: Input raster map constains cells with NULL-value (no-data). The
         value 999 was used to represent no-data values in the input
         map.You can specify nodata value by nodata parameter.
/home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/ros_2016.max
has GDAL driver GTiff
and has 520 rows and 192 columns
> range(x[[1]], na.rm=TRUE)
[1]     0 36852
>

I would suggest that you proceed as suggested below.

Thanks

Rainer




On Thu, Sep 18, 2008 at 11:01 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
> Roger Bivand <Roger.Bivand <at> nhh.no> writes:
>
>>
>> Markus Neteler <neteler <at> osgeo.org> writes:
>>
>> >
>> > On Wed, Sep 17, 2008 at 10:49 AM, Roger Bivand <Roger.Bivand <at>
>> > nhh.no> wrote:
>> > > Markus Neteler <neteler <at> osgeo.org> writes:
>> > >
>> > means:
>> > - the GDAL plugin is no option here since it does not respect current
>> >   region settings
>> > - r.out.gdal is good since it does the job (AFAIK). Written in C
>
>> I can revisit this in relation to using r.out.gdal for GRASS >= 6.3
>> instead of r.out.bin - in which case I can make r.out.gdal use 32
>> bits for integers and 64 bits for float/doubles.
>
> Committed on R-spatial sourceforge CVS, new flag useGDAL=FALSE for now
> default, uses Int32 for CELL, so maybe could be tried to see if it works
> better than r.out.bin.
>
> If it does, I'll change writeRAST6() too, change the default to TRUE, and
> release.
>
> Roger
>
>>
>> Roger
>>
>> > Perhaps you mean r.out.gdal.sh?
>> >
>> > Best
>> > Markus
>> >
>>
>
>
>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>



-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Faculty of Science
Natural Sciences Building
Private Bag X1
University of Stellenbosch
Matieland 7602
South Africa


More information about the grass-dev mailing list