[GRASS-stats] spgrass problem importing category 999 when plugin is FALSE

Roger Bivand Roger.Bivand at nhh.no
Fri Apr 3 03:07:45 EDT 2009


On Fri, 3 Apr 2009, Jarek Jasiewicz wrote:

> Hi
>
> I during batch processing of couple of maps I found strange behaviour of 
> readRAST6 when I import cell map with value 999.
> Instead of 999 Na is imported (?? _
>
> It is for me completely strange, so I test it with folowing:

OK. This is a consequence of trying to guess the NODATA value to pass to 
r.out.gdal, and I don't see it in 0.5-19 (my local slightly changed from 
CRAN latest 0.5-18). For certain range values retrieved from r.info, 
NODATA is assigned the value 999 (R/bin_link.R, about line 113). Please 
try 0.5-18, I suspect that the condition was changed. Alternatively, set 
NODATA to a suitable value outside the range of the data. Note that I 
don't have a 6.5 GRASS, and if r.info output has changed format, the 
parsing will be wrong, and
(!is.numeric(lres$min) || !is.finite(as.double(lres$min)) will be
triggered, setting NODATA to 999.

What does r.info test_map look like in 6.5? In 6.3 it is:

> system("r.info test_map")

+----------------------------------------------------------------------------+
| Layer:    test_map                       Date: Fri Apr  3 08:41:58 2009    |
| Mapset:   rsb                            Login of Creator: rsb             |
| Location: spearfish60                                                      |
| DataBase: /home/rsb/topics/grassdata                                       |
| Title:     ( test_map )                                                    |
| Timestamp: none                                                            |
|----------------------------------------------------------------------------|
|                                                                            |
|   Type of Map:  raster               Number of Categories: 999             |
|   Data Type:    CELL                                                       |
|   Rows:         143                                                        |
|   Columns:      190                                                        |
|   Total Cells:  27170                                                      |
|        Projection: UTM (zone 13)                                           |
|            N:    4928010    S:    4913700   Res: 100.06993007              |
|            E:     609000    W:     589980   Res: 100.10526316              |
|   Range of data:    min = 999  max = 999                                   |
|                                                                            |
|   Data Description:                                                        |
|    generated by r.mapcalc                                                  |
|                                                                            |
|   Comments:                                                                |
|    999                                                                     |
|                                                                            |
+----------------------------------------------------------------------------+

I guess that there is a smarter way of getting the raster min/max too, 
isn't there?

Hope this helps,

Roger

>
> echo "test_map=999"|r.mapclac
> R
> library(spgrass6)
> testNoPlugin=readRAST6("test_map",plugin=FALSE)
>
> summary(testNoPlugin at data)
>
>    test      Min.   :    NA 1st Qu.:    NA Median :    NA Mean   :   NaN 3rd 
> Qu.:    NA Max.   :    NA NA's   :156740
>
> testPlugin=readRAST6("test_map",plugin=TRUE)
>
> summary(testPlugin at data)
>
>    test   Min.   :999 1st Qu.:999 Median :999 Mean   :999 3rd Qu.:999 Max. 
> :999 
>
> It is very strange for me but I tested it on several maps. I think someone 
> could try to reproduce this.
>
> Jarek
>
>
> BTW:
>
> R version 2.8.1 (2008-12-22)
>
>
> library(spgrass6)
> Loading required package: sp
> Loading required package: rgdal
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.5.3, released 2008/09/09
> GDAL_DATA: /usr/local/lib/R/site-library/rgdal/gdal
> Loaded PROJ.4 runtime: Rel. 4.6.1, 21 August 2008
> PROJ_LIB: /usr/local/lib/R/site-library/rgdal/proj
> GRASS GIS interface loaded with GRASS version: 6.5.svn
> and location: Rzeki
>
> Package: spgrass6
> Version: 0.5-16
> Date: 2008-11-13
> Built: R 2.8.1; ; 2009-01-02 14:02:31; unix
>
>
>
>
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

-- 
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



More information about the grass-stats mailing list