[R-sig-Geo] package raster: pb with setValues on a RasterLayer

lancelot renaud.lancelot at cirad.fr
Mon Jul 4 16:31:59 CEST 2011


Dear all,

I meet a pb when using setValues:

 > library(raster)
 > setwd("d:/analyses/abder")
 > r <- raster("rh.tif")
 > vals <- getValues(r)
 > summary(vals)
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
       0     244     440    1646     828   65540  166222
 > vals[!is.na(vals) & ((vals > 10000) | (vals == 0))] <- NA
 > summary(vals)
     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's
      1.0    241.0    434.0    683.7    798.0   6805.0 173141.0
 > r2 <- setValues(r, vals)
 > plot(r2)
Error in .local(.Object, ...) : empty file name

Any idea of what's going on and how to solve it?

####

Some additional info:

 > class(r)
[1] "RasterLayer"
attr(,"package")
[1] "raster"

 > summary(r)
Cells:  604902

Min.        0
1st Qu.   181
Median    538
Mean     3330
3rd Qu.  1303
Max.    65540
summary based on a sample of 1e+05 cells, which is 16.5316034663466 % of 
all cells

 > slot(slot(r, "file"), "name")
[1] "d:/analyses/abder/rh.tif"

 > slot(slot(r2, "file"), "name")
[1] ""

 > sessionInfo()
R version 2.13.0 Patched (2011-04-28 r55678)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgdal_0.6-33   raster_1.8-38  sp_0.9-84      fortunes_1.4-1

All the best,

Renaud

-- 
Renaud Lancelot
EDENext Project, coordinator: http://www.edenext.eu/

CIRAD, UMR15, Campus International de Baillarguet TA A-DIR / B
F34398 Montpellier

Tel.  +33 4 67 59 37 17  -  Fax  +33 4 67 59 37 95
Secr. +33 4 67 59 37 37  - Cell. +33 6 77 52 08 69



More information about the R-sig-Geo mailing list