Problem when loading GRASS 6 raster with large integer values
On Tue, Sep 16, 2008 at 6:38 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
On Tue, 16 Sep 2008, Rainer M Krug wrote:
Hi when I try to import a raster layer from grass with large integer values, I get wrong values in R (see below). When I change the datatype in GRASS to double, it works.
The underlying r.out.bin exports CELL rasters as short integers using two bytes only, and the 6.3 version of the module has no option or flag for setting this differently. So conversion to DCELL (or FCELL) is the only fix.
Thanks for the clarification. I will see what can be done from the GRASS side. Rainer
Roger
Thanks, Rainer GRASS 6.3.0 (grass):~/Documents/Projects/AlienSpread/R > r.stats -c input=tmpDispLocal 100% 0 39798 11 831 58 78 105 38 242 1652 889 816 2205 294 2310 56 3315 1171 4935 116 7875 9 8085 67 11550 6 13010 299 24675 2 30135 425 47702 1 48510 981 103635 1255 165375 8 177797 160 177870 6 379995 324 606375 8 662970 292 1416345 445 2260125 41 * 50661 [Raster MASK present] BUT:
seeds <- readRAST6(
+ "tmpDispLocal", + ignore.stderr=!Debug + ) Creating BIL support files... Header File = /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/tmpDispLocal.hdr World File = /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/tmpDispLocal.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
table(seeds[[1]])
-31233 -27437 -25447 -18811 -18738 -17834 -17026 -13221 0 11 58 8 1255 445 160 6 1 981 324 39798 831 78 105 242 889 2205 2310 3315 4935 7610 7875 8085 11550 38 1652 816 294 56 1171 116 292 9 67 6 13010 16551 24675 30135 31901 299 8 2 425 41
Additional info: GRASS 6.3.0 (grass):~/Documents/Projects/AlienSpread/R > r.info map=tmpDispLocal +----------------------------------------------------------------------------+ | Layer: tmpDispLocal Date: Tue Sep 16 16:45:35 2008 | | Mapset: simulation Login of Creator: rkrug | | Location: grass | | DataBase: /home/rkrug/Documents/Projects/AlienSpread/R/.. | | Title: ( tmpDispLocal ) | | Timestamp: none | |----------------------------------------------------------------------------| | | | Type of Map: raster Number of Categories: 2260125 | | Data Type: CELL | | Rows: 520 | | Columns: 192 | | Total Cells: 99840 | | Projection: UTM (zone -34) | | N: 6247000 S: 6195000 Res: 100 | | E: 270200 W: 251000 Res: 100 | | Range of data: min = 0 max = 2260125 | | | | Data Description: | | generated by r.mapcalc | | | | Comments: | | round(tmpDisp * 0.300000) | | | +----------------------------------------------------------------------------+ [Raster MASK present] GRASS 6.3.0 (grass):~/Documents/Projects/AlienSpread/R >
-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
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